diff --git a/combo/apps/wcs/forms.py b/combo/apps/wcs/forms.py index 12425205..33608c6a 100644 --- a/combo/apps/wcs/forms.py +++ b/combo/apps/wcs/forms.py @@ -50,7 +50,9 @@ class WcsFormForLinkListCellForm(WcsFormCellForm): class WcsCardsCellForm(forms.ModelForm): - with_user = forms.BooleanField(label=_('Restrict to cards accessible to the user'), required=False) + with_user = forms.BooleanField( + label=_('Restrict to cards accessible to the user'), required=False, initial=True + ) class Meta: model = WcsCardsCell @@ -72,7 +74,9 @@ class WcsCardsCellForm(forms.ModelForm): class WcsCardInfoCellForm(forms.ModelForm): - with_user = forms.BooleanField(label=_('Restrict to cards accessible to the user'), required=False) + with_user = forms.BooleanField( + label=_('Restrict to cards accessible to the user'), required=False, initial=True + ) customize_display = forms.BooleanField(label=_('Customize display'), required=False) related_card_path = forms.ChoiceField(label=_('Card Identifier'), required=False) @@ -116,6 +120,7 @@ class WcsCardInfoCellForm(forms.ModelForm): self.fields['related_card_path'].choices += [ ('--', _('Identifier from page URL')), ] + self.fields['related_card_path'].initial = '--' if not self.instance.card_ids and not self.instance.related_card_path: self.initial['related_card_path'] = '--' self.fields['related_card_path'].choices += [ diff --git a/combo/data/forms.py b/combo/data/forms.py index 96a4059a..f26e69c4 100644 --- a/combo/data/forms.py +++ b/combo/data/forms.py @@ -62,6 +62,8 @@ class LinkListCellForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + if self.instance.get_items_with_prefetch(): + self.is_not_default = True class ConfigJsonForm(forms.ModelForm): diff --git a/combo/data/models.py b/combo/data/models.py index c08f3f58..99bdb2a5 100644 --- a/combo/data/models.py +++ b/combo/data/models.py @@ -1784,7 +1784,9 @@ class LinkListCell(CellBase): ) def get_items_with_prefetch(self): - return self.get_items(prefetch_validity_info=True) + if not hasattr(self, '_items_with_prefetch_cache'): + self._items_with_prefetch_cache = self.get_items(prefetch_validity_info=True) + return self._items_with_prefetch_cache def get_additional_label(self): title = self.title diff --git a/combo/manager/forms.py b/combo/manager/forms.py index ddd44514..949f92a0 100644 --- a/combo/manager/forms.py +++ b/combo/manager/forms.py @@ -60,6 +60,19 @@ def get_template_name_choices(with_models=False): return templates +def build_tab_is_not_default(form): + if getattr(form, 'is_not_default', None) is True: + return True + for field_name, field in form.fields.items(): + if field.initial is not None: + if field.initial != form.initial.get(field_name): + return True + else: + if bool(form.initial.get(field_name)): + return True + return False + + class PageDuplicateForm(forms.Form): title = forms.CharField(label=_('New title'), max_length=150, required=False) @@ -274,6 +287,7 @@ class CellVisibilityForm(forms.Form): ('groups-any', _('Users with one of these groups')), ('groups-none', _('Users with none of these groups')), ], + initial='all', ) groups = forms.MultipleChoiceField(label=_('Groups'), required=False, choices=get_groups_as_choices) diff --git a/combo/manager/static/js/combo.manager.js b/combo/manager/static/js/combo.manager.js index caf2e59d..00a44cc4 100644 --- a/combo/manager/static/js/combo.manager.js +++ b/combo/manager/static/js/combo.manager.js @@ -275,10 +275,10 @@ $(function() { $button.attr('disabled', null); for (const tab_slug in data.tabs) { var $tab_content = $form.find('[data-tab-slug="' + tab_slug + '"]'); - if (data.tabs[tab_slug].indexOf('ckeditortype') == -1) { + if (data.tabs[tab_slug].form.indexOf('ckeditortype') == -1) { /* update form with new content, unless it has a ckeditor, as * this causes an unpleasant flickering */ - $tab_content.html(data.tabs[tab_slug]); + $tab_content.html(data.tabs[tab_slug].form); } else { for (const error in data.errorlist[tab_slug]) { var $widget_p = $('[name="' + data.prefix + '-' + error).closest('p'); @@ -289,6 +289,11 @@ $(function() { $widget_p.before($widget_ul); } } + if (data.tabs[tab_slug].is_not_default) { + $('#tab-' + $cell.data('cell-reference') + '-' + tab_slug).addClass('pk-tabs--button-marker'); + } else { + $('#tab-' + $cell.data('cell-reference') + '-' + tab_slug).removeClass('pk-tabs--button-marker'); + } } // update title labels $cell.find('.visibility-summary').removeClass( diff --git a/combo/manager/templates/combo/manager_edit_cell_block.html b/combo/manager/templates/combo/manager_edit_cell_block.html index 48ef634a..d3e7b7fe 100644 --- a/combo/manager/templates/combo/manager_edit_cell_block.html +++ b/combo/manager/templates/combo/manager_edit_cell_block.html @@ -5,19 +5,20 @@ {% for tab in manager_tabs %} + aria-controls="panel-{{ cell.get_reference }}-{{ tab.slug }}" + id="tab-{{ cell.get_reference }}-{{ tab.slug }}" + tabindex="{{ forloop.first|yesno:"0,-1" }}" + {% if tab.is_not_default %}class="pk-tabs--button-marker"{% endif %}>{{ tab.name }} {% endfor %}