From: Vincent Vanwaelscappel Date: Wed, 12 Jun 2019 12:01:16 +0000 (+0200) Subject: wip #2810 @10 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d573dd02029b1291a173a9ce59dcba12301d5a06;p=pmi.git wip #2810 @10 --- diff --git a/app/Http/Controllers/Admin/CategoryCrudController.php b/app/Http/Controllers/Admin/CategoryCrudController.php index 526898b..b5d26a5 100644 --- a/app/Http/Controllers/Admin/CategoryCrudController.php +++ b/app/Http/Controllers/Admin/CategoryCrudController.php @@ -8,8 +8,8 @@ class CategoryCrudController extends CubistMagicNestedController { protected $_modelNamespace = 'App\Models\Category'; protected $_routeURL = 'catalog_category'; - protected $_singular = 'category'; - protected $_plural = 'categories'; + protected $_singular = 'catégorie'; + protected $_plural = 'catégories'; protected $_clonable = true; protected $_bulk = true; } diff --git a/app/Http/Controllers/Admin/ProductCrudController.php b/app/Http/Controllers/Admin/ProductCrudController.php index 32de144..cae233a 100644 --- a/app/Http/Controllers/Admin/ProductCrudController.php +++ b/app/Http/Controllers/Admin/ProductCrudController.php @@ -8,8 +8,8 @@ class ProductCrudController extends CubistMagicController { protected $_modelNamespace = 'App\Models\Product'; protected $_routeURL = 'product'; - protected $_singular = 'product'; - protected $_plural = 'products'; + protected $_singular = 'produit'; + protected $_plural = 'produits'; protected $_clonable = true; protected $_bulk = true; } diff --git a/app/Http/Controllers/Admin/ProductTypeCrudController.php b/app/Http/Controllers/Admin/ProductTypeCrudController.php index 67e2e60..883dfee 100644 --- a/app/Http/Controllers/Admin/ProductTypeCrudController.php +++ b/app/Http/Controllers/Admin/ProductTypeCrudController.php @@ -8,8 +8,8 @@ class ProductTypeCrudController extends CubistMagicController { protected $_modelNamespace = 'App\Models\ProductType'; protected $_routeURL = 'producttype'; - protected $_singular = 'product type'; - protected $_plural = 'product types'; + protected $_singular = 'type de produit'; + protected $_plural = 'types de produit'; protected $_clonable = true; protected $_bulk = true; } diff --git a/app/Http/Controllers/Admin/SpecificationCrudController.php b/app/Http/Controllers/Admin/SpecificationCrudController.php index 263bb59..0eddf87 100644 --- a/app/Http/Controllers/Admin/SpecificationCrudController.php +++ b/app/Http/Controllers/Admin/SpecificationCrudController.php @@ -8,8 +8,8 @@ class SpecificationCrudController extends CubistMagicController { protected $_modelNamespace = 'App\Models\Specification'; protected $_routeURL = 'specification'; - protected $_singular = 'specification'; - protected $_plural = 'specifications'; + protected $_singular = 'spécification'; + protected $_plural = 'spécifications'; protected $_clonable = true; protected $_bulk = true; } diff --git a/app/Models/Product.php b/app/Models/Product.php index 7b2072b..850cae8 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -81,6 +81,10 @@ class Product extends CubistMagicModel $params['type'] = 'Range'; } else if ($spec->type == 'text') { $params['type'] = 'Text'; + } else if ($spec->type == 'numeric_list') { + $params['type'] = 'Table'; + $params['entity_singular'] = 'valeur'; + $params['columns'] = ['value' => 'Value']; } else { $params['type'] = 'SelectFromArray'; $options = []; @@ -138,9 +142,20 @@ class Product extends CubistMagicModel $this->addField(['name' => 'images', 'label' => 'Images du produit', - 'type' => 'Images', + 'type' => 'Files', + 'maxFiles' => 6, 'tab' => 'Média']); + $documents = ['technical_sheet' => 'Fiche technique', 'documentation' => 'Documentation']; + foreach ($documents as $name => $label) { + $this->addField(['name' => $name, + 'label' => $label, + 'type' => 'Files', + 'mime_types' => 'application/pdf', + 'maxFiles' => 1, + 'tab' => 'Documents']); + } + $this->addField(['name' => 'dimensions', 'label' => 'Dimensions', 'type' => 'Markdown', diff --git a/app/Models/Producttype.php b/app/Models/Producttype.php index cc2f408..5834b9f 100644 --- a/app/Models/Producttype.php +++ b/app/Models/Producttype.php @@ -22,7 +22,7 @@ class ProductType extends CubistMagicModel 'column' => true]); $this->addField([ - 'name' => 'type', + 'name' => 'type', 'label' => 'Famille de produits', 'type' => 'SelectFromArray', 'options' => ['captor' => 'Captor', 'system' => 'System'], @@ -36,16 +36,16 @@ class ProductType extends CubistMagicModel 'column' => false, 'default' => 1]); - $this->addField(['name' => 'filters', - 'label' => 'Spécifications utilisées comme filtre', - 'type' => 'SelectFromModelMultiple', - 'model' => 'App\Models\Specification']); - $this->addField(['name' => 'specifications', - 'label' => 'Autre spécifications', + 'label' => 'Spécifications', 'type' => 'SelectFromModelMultiple', 'model' => "App\Models\Specification", ]); + + $this->addField(['name' => 'filters', + 'label' => 'Spécifications utilisées comme filtre', + 'type' => 'SelectFromModelMultiple', + 'model' => 'App\Models\Specification']); } public function specifications() diff --git a/app/Models/Specification.php b/app/Models/Specification.php index fac4b39..95f3b35 100644 --- a/app/Models/Specification.php +++ b/app/Models/Specification.php @@ -20,13 +20,18 @@ class Specification extends CubistMagicModel $this->addField(['name' => 'name', 'label' => 'Nom de la spécification', 'type' => 'Text', - 'column' => true]); + 'column' => true, + 'translatable' => false]); + + $this->addField(['name' => 'label', + 'label' => 'Label (texte affiché sur le site)', + 'type' => 'Text']); $this->addField(['name' => 'type', 'label' => 'Type', 'type' => 'SelectFromArray', 'column' => true, - 'options' => ['numeric' => 'Numeric value', 'range' => 'Numeric range', 'list' => 'Value in a list', 'text' => 'Text value']]); + 'options' => ['numeric' => 'Valeur numérique', 'range' => 'Intervale numérique', 'numeric_list' => 'Liste de valeurs numériques', 'list' => 'Valeur à choisir dans une liste', 'text' => 'Texte libre']]); $this->addField(['name' => 'options', 'label' => 'Options', @@ -45,11 +50,19 @@ class Specification extends CubistMagicModel 'when' => ['type' => 'numeric'] ]); + $this->addField(['name' => 'separator', + 'label' => 'Séparateur', + 'type' => 'SelectFromArray', + 'options' => [',' => ', (virgule)', '/' => '/ (Slash)', '-' => '- (tiret)'], + 'when' => ['type' => 'numeric_list'] + ]); + $this->addField(['name' => 'unit', 'label' => 'Unité', 'type' => 'Text', - 'when' => ['type' => ['numeric', 'interval']], + 'when' => ['type' => ['numeric', 'range', 'numeric_list']], 'translatable' => false, + 'column'=>true, ]); } diff --git a/composer.json b/composer.json index 5028853..4dd58ff 100644 --- a/composer.json +++ b/composer.json @@ -64,6 +64,7 @@ }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.6", - "filp/whoops": "^2.3" + "filp/whoops": "^2.3", + "laravel/tinker": "^1.0" } } diff --git a/routes/backpack/custom.php b/routes/backpack/custom.php index d12a933..84591e8 100644 --- a/routes/backpack/custom.php +++ b/routes/backpack/custom.php @@ -4,8 +4,24 @@ Route::group([ 'middleware' => ['web', config('backpack.base.middleware_key', 'admin')], 'namespace' => 'App\Http\Controllers\Admin', ], function () { // custom admin routes - CRUD::resource('catalog_category', 'CategoryCrudController'); - CRUD::resource('product', 'ProductCrudController'); - CRUD::resource('producttype', 'ProductTypeCrudController'); - CRUD::resource('specification', 'SpecificationCrudController'); + CRUD::resource('catalog_category', 'CategoryCrudController')->with(function () { + Route::match(['post'], 'catalog_category/{id}/media', 'CategoryCrudController@uploadMedia'); + Route::match(['delete'], 'catalog_category/{id}/media/{mediaId}', 'CategoryCrudController@deleteMedia'); + Route::match(['post'], 'catalog_category/{id}/media/reorder', 'CategoryCrudController@reorderMedia'); + }); + CRUD::resource('product', 'ProductCrudController')->with(function () { + Route::match(['post'], 'product/{id}/media', 'ProductCrudController@uploadMedia'); + Route::match(['delete'], 'product/{id}/media/{mediaId}', 'ProductCrudController@deleteMedia'); + Route::match(['post'], 'product/{id}/media/reorder', 'ProductCrudController@reorderMedia'); + }); + CRUD::resource('producttype', 'ProductTypeCrudController')->with(function () { + Route::match(['post'], 'producttype/{id}/media', 'ProductTypeCrudController@uploadMedia'); + Route::match(['delete'], 'producttype/{id}/media/{mediaId}', 'ProductTypeCrudController@deleteMedia'); + Route::match(['post'], 'producttype/{id}/media/reorder', 'ProductTypeCrudController@reorderMedia'); + }); + CRUD::resource('specification', 'SpecificationCrudController')->with(function () { + Route::match(['post'], 'specification/{id}/media', 'SpecificationCrudController@uploadMedia'); + Route::match(['delete'], 'specification/{id}/media/{mediaId}', 'SpecificationCrudController@deleteMedia'); + Route::match(['post'], 'specification/{id}/media/reorder', 'SpecificationCrudController@reorderMedia'); + }); }); // this should be the absolute last line of this file