]> _ Git - pmi.git/commitdiff
wip #2810 @10
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 12 Jun 2019 12:01:16 +0000 (14:01 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 12 Jun 2019 12:01:16 +0000 (14:01 +0200)
app/Http/Controllers/Admin/CategoryCrudController.php
app/Http/Controllers/Admin/ProductCrudController.php
app/Http/Controllers/Admin/ProductTypeCrudController.php
app/Http/Controllers/Admin/SpecificationCrudController.php
app/Models/Product.php
app/Models/Producttype.php
app/Models/Specification.php
composer.json
routes/backpack/custom.php

index 526898bbc22a15e5acf00b7ffca9900388098b67..b5d26a5320fe8a88e10c6add4849e34a041f3ea6 100644 (file)
@@ -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;
 }
index 32de144a5e419286d18329e6baf7731b6049ec9b..cae233a4ed99eb9d05a2641e95f49f4019b4e980 100644 (file)
@@ -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;
 }
index 67e2e60eb25320552213ef94b1cc4937d3729647..883dfeed340ea951eee6e2b93662f3fdeea4e89e 100644 (file)
@@ -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;
 }
index 263bb590a3f8349ec342555c42299343b7fbd1d3..0eddf875319159026a0632fb119436188c36a3d9 100644 (file)
@@ -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;
 }
index 7b2072b2d4443ec09576b18176c4f79abcdcfcc0..850cae8f10c2efd5723c791c45ad0be16245a8bb 100644 (file)
@@ -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',
index cc2f40858f39b0f22f77e7f72018bd198c72488f..5834b9f9af30650dc06c8f658dbb7d5371b4ff2e 100644 (file)
@@ -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()
index fac4b390bd5d0461862e80ffdbe16328cedfa1a0..95f3b35684bd7b5a853f187e7000927b23fab6b8 100644 (file)
@@ -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,
         ]);
     }
 
index 5028853862a31762957b09fd4b1c9a067563b64a..4dd58ffa0f55269357072ce1cece81621f82f6c4 100644 (file)
@@ -64,6 +64,7 @@
     },
     "require-dev": {
         "barryvdh/laravel-ide-helper": "^2.6",
-        "filp/whoops": "^2.3"
+        "filp/whoops": "^2.3",
+        "laravel/tinker": "^1.0"
     }
 }
index d12a933b773b3d515d3c5214d53f32249d836e9b..84591e82a919e304421a0fd85f67c2131c89eb78 100644 (file)
@@ -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