filter builder: adds field selector

parent 13fdaa74
......@@ -18,6 +18,8 @@ class ConfigurationMenuAdmin extends ConfigurationAbstractAdmin
{
$dm = $this->getModelManager()->getDocumentManager('App\Document\Configuration');
$config = $dm->getRepository('App\Document\Configuration')->findConfiguration();
$apiProperties = $dm->getRepository('App\Document\Element')->findAllCustomProperties();
$propertiesText = implode($apiProperties, ',');
$featureStyle = ['class' => 'col-md-6 col-lg-3 gogo-feature'];
$featureFormOption = ['delete' => false, 'required' => false, 'label_attr' => ['style' => 'display:none']];
......@@ -34,8 +36,8 @@ class ConfigurationMenuAdmin extends ConfigurationAbstractAdmin
->add('menu.displayNumberOfElementForEachCategory', CheckboxType::class, ['label' => "Pour chaque catégorie, afficher le nombre d'élément ayant cette catégorie", 'required' => false])
->add('menu.displayNumberOfElementRoundResults', CheckboxType::class, ['label' => 'Arrondir les résultat (afficher 300+ au lieu de 326)', 'label_attr' => ['title' => "Valable uniquement si \"afficher le nombre d'éléments par catégorie\" est coché"], 'required' => false])
->end()
->with('Les filtres', ['description' => "Un peu d'aide"])
->add('menu.filtersJson', HiddenType::class, ['attr' => ['class' => 'gogo-filters-builder']])
->with('Personnalisez les filtres dans le menu', ['description' => ""])
->add('menu.filtersJson', HiddenType::class, ['attr' => ['class' => 'gogo-filters-builder', 'dataproperties' => $propertiesText]])
->end()
->end()
->tab('Recherche')
......
......@@ -381,7 +381,7 @@ class ElementRepository extends DocumentRepository
$formProperties = $this->findFormProperties();
return array_merge($allProperties, $formProperties);
return array_unique(array_merge($allProperties, $formProperties));
}
public function findFormProperties()
......
......@@ -9,6 +9,12 @@
<script>
var formBuilder;
var allFields = "{{ form.vars.attr.dataproperties|raw }}".split(',');
var fieldsChoices = {}
for (var i = 0; i < allFields.length; i++) {
fieldsChoices[allFields[i]] = allFields[i];
}
console.log("fields", allFields)
if (!formBuilderInitialized) {
formBuilderInitialized = true;
jQuery(function($) {
......@@ -25,11 +31,11 @@
return { field: result };
}
var templates = {
taxonomy: function(fieldData) { return { field: '' }; },
taxonomy: function(fieldData) { return { field: 'Personnaliser ce filtre dans le menu des catégories' }; },
gogo_date: displayFilter,
gogo_number: displayFilter,
};
var fieldAttr = { label: "Nom du champ à utiliser", type: 'autocomplete'}
var fieldAttr = { label: "Nom du champ à utiliser", options: fieldsChoices}
var contractedAttr = { label: "Filtre replié par defaut", type: 'checkbox'}
var dateViews = { "day": "Jour", "week": "Semaine", "month": "Mois", "year": "Année", "range": "Plage" }
......@@ -120,6 +126,11 @@
}
.gogo_date-field .views-wrap { display: none; }
.form-wrap.form-builder .frmb .field-label {
color: inherit;
font-weight: 600;
}
/* Fix conflict betwwen slect 2 and form-builder */
.select2-choice>span:first-child, .select2-chosen,
.select2-container .select2-choices .select2-search-field input {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment