From 07c4d6e3b32d3f7f99cbef59efa8cf9d6dacc63d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 17 Mar 2020 17:03:32 +0100 Subject: [PATCH] wip #3506 @1.5 --- app/Models/Product.php | 10 +++++----- app/Models/Specification.php | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Models/Product.php b/app/Models/Product.php index 3466a37..2394b98 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -209,18 +209,18 @@ class Product extends CubistMagicPageModel $params['suffix'] = $spec->unit; } - if ($spec->type == 'numeric') { + if ($spec->type === 'numeric') { $params['type'] = 'Number'; - } else if ($spec->type == 'range') { + } else if ($spec->type === 'range') { $params['type'] = 'Range'; - } else if ($spec->type == 'text') { + } else if ($spec->type === 'text') { $params['type'] = 'Text'; - } else if ($spec->type == 'numeric_list') { + } else if ($spec->type === 'numeric_list') { $params['type'] = 'Tags'; // $params['entity_singular'] = 'valeur'; // $params['columns'] = ['value' => 'Value']; } else { - $params['type'] = 'SelectFromArray'; + $params['type'] = $spec->type === 'list' ? 'SelectFromArray' : 'SelectFromArrayMultiple'; $options = []; if (is_string($spec->options)) { $decoded = []; diff --git a/app/Models/Specification.php b/app/Models/Specification.php index 3647f1c..e1085c7 100644 --- a/app/Models/Specification.php +++ b/app/Models/Specification.php @@ -31,14 +31,19 @@ class Specification extends CubistMagicTranslatableModel 'label' => 'Type', 'type' => 'SelectFromArray', 'column' => true, - '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']]); + 'options' => ['numeric' => 'Valeur numérique', + 'range' => 'Intervale numérique', + 'numeric_list' => 'Liste de valeurs numériques', + 'list' => 'Valeur à choisir dans une liste', + 'mlist' => 'Plusieurs valeurs à choisir dans une liste', + 'text' => 'Texte libre']]); $this->addField(['name' => 'options', 'label' => 'Options', 'type' => 'Table', 'entity_singular' => 'option', 'columns' => array_merge(['id' => '#'], config('backpack.crud.locales')), - 'when' => ['type' => 'list'], + 'when' => ['type' => ['list','mlist']], 'translatable' => false, ]); -- 2.39.5