From 576b8f8c48d1eb6316a16d5b7d9284173a529405 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 13 Mar 2023 13:33:03 -0700 Subject: [PATCH 1/4] adds translations to edit and index of categories --- app/Helpers/Helper.php | 28 +++++++++++++++---- .../Transformers/CategoriesTransformer.php | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 1913c86286..4d862d8627 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -532,15 +532,33 @@ class Helper { $category_types = [ '' => '', - 'accessory' => 'Accessory', - 'asset' => 'Asset', - 'consumable' => 'Consumable', - 'component' => 'Component', - 'license' => 'License', + 'accessory' => trans('general.accessories'), + 'asset' => trans('general.asset'), + 'consumable' => trans('general.consumable'), + 'component' => trans('general.component'), + 'license' => trans('general.license'), ]; return $category_types; } + public static function categoryType($category_type){ + + switch ($category_type) { + case ('accessory'): + return trans('general.accessory'); + break; + case ('consumable'): + return trans('general.consumable'); + break; + case ('component'): + return trans('general.component'); + break; + case ('asset'): + return trans('general.asset'); + case ('license'): + return trans('general.license'); + } + } /** * Get the list of custom fields in an array to make a dropdown menu diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index 5ea8ee3e01..84c1aad8ca 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -47,7 +47,7 @@ class CategoriesTransformer 'id' => (int) $category->id, 'name' => e($category->name), 'image' => ($category->image) ? Storage::disk('public')->url('categories/'.e($category->image)) : null, - 'category_type' => ucwords(e($category->category_type)), + 'category_type' => Helper::categoryType($category->category_type), 'has_eula' => ($category->getEula() ? true : false), 'use_default_eula' => ($category->use_default_eula=='1' ? true : false), 'eula' => ($category->getEula()), From 371e142bae986a97f529d7e890f4066b7deb8d3e Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 15 Mar 2023 15:57:45 -0700 Subject: [PATCH 2/4] removes unnecessary function --- app/Helpers/Helper.php | 25 ++++--------------- .../Transformers/CategoriesTransformer.php | 2 +- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 4d862d8627..c77e0f8f27 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -528,7 +528,7 @@ class Helper * @since [v2.5] * @return array */ - public static function categoryTypeList() + public static function categoryTypeList($selection=null) { $category_types = [ '' => '', @@ -539,27 +539,12 @@ class Helper 'license' => trans('general.license'), ]; + if($selection != null){ + return $category_types[$selection]; + } + else return $category_types; } - public static function categoryType($category_type){ - - switch ($category_type) { - case ('accessory'): - return trans('general.accessory'); - break; - case ('consumable'): - return trans('general.consumable'); - break; - case ('component'): - return trans('general.component'); - break; - case ('asset'): - return trans('general.asset'); - case ('license'): - return trans('general.license'); - } - } - /** * Get the list of custom fields in an array to make a dropdown menu * diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index 84c1aad8ca..35dac986dd 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -47,7 +47,7 @@ class CategoriesTransformer 'id' => (int) $category->id, 'name' => e($category->name), 'image' => ($category->image) ? Storage::disk('public')->url('categories/'.e($category->image)) : null, - 'category_type' => Helper::categoryType($category->category_type), + 'category_type' => Helper::categoryTypeList($category->category_type), 'has_eula' => ($category->getEula() ? true : false), 'use_default_eula' => ($category->use_default_eula=='1' ? true : false), 'eula' => ($category->getEula()), From 16dcc2d3ed32bc77794a7d5a20a44d9653918634 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 24 Mar 2023 06:57:43 -0700 Subject: [PATCH 3/4] Fixed #12641 - add JSON to mimes Signed-off-by: snipe --- app/Http/Requests/AssetFileRequest.php | 2 +- resources/views/modals/upload-file.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/AssetFileRequest.php b/app/Http/Requests/AssetFileRequest.php index f8631f23ba..697b49f3d6 100644 --- a/app/Http/Requests/AssetFileRequest.php +++ b/app/Http/Requests/AssetFileRequest.php @@ -24,7 +24,7 @@ class AssetFileRequest extends Request $max_file_size = \App\Helpers\Helper::file_upload_max_size(); return [ - 'file.*' => 'required|mimes:png,gif,jpg,svg,jpeg,doc,docx,pdf,txt,zip,rar,xls,xlsx,lic,xml,rtf,webp|max:'.$max_file_size, + 'file.*' => 'required|mimes:png,gif,jpg,svg,jpeg,doc,docx,pdf,txt,zip,rar,xls,xlsx,lic,xml,rtf,json,webp|max:'.$max_file_size, ]; } } diff --git a/resources/views/modals/upload-file.blade.php b/resources/views/modals/upload-file.blade.php index 5f4ab989ed..f87e3e4962 100644 --- a/resources/views/modals/upload-file.blade.php +++ b/resources/views/modals/upload-file.blade.php @@ -19,7 +19,7 @@ From 150a2b572e334df87cb408d58b1174424ef19f4b Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 24 Mar 2023 07:14:02 -0700 Subject: [PATCH 4/4] =?UTF-8?q?Use=20single=20=E2=80=9Caccessory=E2=80=9D?= =?UTF-8?q?=20translation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snipe --- app/Helpers/Helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 1f1228bb0a..c85564fc3c 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -536,7 +536,7 @@ class Helper { $category_types = [ '' => '', - 'accessory' => trans('general.accessories'), + 'accessory' => trans('general.accessory'), 'asset' => trans('general.asset'), 'consumable' => trans('general.consumable'), 'component' => trans('general.component'),