From 9c06220f9bd232a85b9aaca22ea65fcca0951e02 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 20 Jun 2018 15:00:32 -0300 Subject: [PATCH] el containercssclass prevenia mostrar el dropdown en multiple:false https://github.com/yourlabs/django-autocomplete-light/pull/1015 --- app/assets/javascripts/select2.js | 5 ----- app/models/post/template_field.rb | 10 ++++++++++ app/views/posts/template_field/_select.haml | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/select2.js b/app/assets/javascripts/select2.js index 07eff9fe..200e84c4 100644 --- a/app/assets/javascripts/select2.js +++ b/app/assets/javascripts/select2.js @@ -1,11 +1,6 @@ $(document).on('turbolinks:load', function() { $('.select2').select2({ - tags: true, - tokenSeparators: [','], - allowClear: true, - placeholder: '', theme: 'bootstrap', - containerCssClass: ':all:', width: '' }); }); diff --git a/app/models/post/template_field.rb b/app/models/post/template_field.rb index adf4ba13..c5e7342e 100644 --- a/app/models/post/template_field.rb +++ b/app/models/post/template_field.rb @@ -15,6 +15,16 @@ class Post complex? ? contents.dig('value') : contents end + def max + return 0 if simple? + contents.fetch('max', 0) + end + + def min + return 0 if simple? + contents.fetch('min', 0) + end + def type return @type if @type diff --git a/app/views/posts/template_field/_select.haml b/app/views/posts/template_field/_select.haml index 29c1c4e3..b808123d 100644 --- a/app/views/posts/template_field/_select.haml +++ b/app/views/posts/template_field/_select.haml @@ -4,6 +4,8 @@ multiple: template.multiple?, required: template.required?, data: { tags: template.open?, - placeholder: t('posts.select.placeholder')}} + placeholder: t('posts.select.placeholder'), + 'allow-clear': template.multiple?, + 'maximum-selection-length': template.max }} - if template.open? %small.text-muted.form-text= t('posts.open')