diff --git a/lib/classes/databox/field.class.php b/lib/classes/databox/field.class.php index bf8fab28aa..c49e350e60 100644 --- a/lib/classes/databox/field.class.php +++ b/lib/classes/databox/field.class.php @@ -574,6 +574,10 @@ class databox_field implements cache_cacheableInterface { $this->Business = ! ! $boolean; + if($this->Business) { + $this->thumbtitle = '0'; + } + return $this; } @@ -666,6 +670,10 @@ class databox_field implements cache_cacheableInterface { $this->thumbtitle = $value; + if($this->thumbtitle != '0') { + $this->Business = false; + } + return $this; } diff --git a/templates/web/admin/databox/doc_structure.twig b/templates/web/admin/databox/doc_structure.twig index bb4ab22d28..cbcca3dac6 100644 --- a/templates/web/admin/databox/doc_structure.twig +++ b/templates/web/admin/databox/doc_structure.twig @@ -150,12 +150,12 @@ - {{ _self.thumbtitle_selector(field.get_thumbtitle()) }} - + {% endfor %} @@ -224,6 +224,34 @@ return false; }); + $('select.thumbtitle', container).bind('change', function(){ + if($(this).val() == '') { + return; + } + + var id = $(this).attr('name').split('_').pop(); + var business = $('input[name="business_' + id + '"]'); + + if(business.attr('checked')) { + $(this).val('0'); + alert('{% trans 'A field can not be set both as title and business field. Remove business field flag before setting title' %}'); + } + }); + + $('input.business', container).bind('change', function(){ + if(!$(this).attr('checked')) { + return; + } + + var id = $(this).attr('name').split('_').pop(); + var thumbtitle = $('select[name="thumbtitle_' + id + '"]'); + + if(thumbtitle.val() != '0') { + $(this).removeAttr('checked'); + alert('{% trans 'A field can not be set both as title and business field. Remove the title before setting the business flag' %}'); + } + }); + $("#field_chooser").autocomplete({ source: "/admin/description/metadatas/search/", minLength: 2,