Improve task filters and tag collections
This commit is contained in:
+14
-3
@@ -156,19 +156,26 @@ class CollectionForm(forms.ModelForm):
|
||||
|
||||
def clean(self):
|
||||
cleaned = super().clean()
|
||||
if cleaned.get('mode') == Collection.Mode.TAGS and not cleaned.get('filter_tags'):
|
||||
self.add_error('filter_tags', _('Select at least one tag for a tag collection.'))
|
||||
if cleaned.get('mode') == Collection.Mode.TAGS:
|
||||
if not cleaned.get('filter_tags'):
|
||||
self.add_error('filter_tags', _('Select at least one tag for a tag collection.'))
|
||||
if not any(cleaned.get(field) for field in ['include_notes', 'include_todos', 'include_links', 'include_journal']):
|
||||
self.add_error('include_notes', _('Select at least one entry type for a tag collection.'))
|
||||
return cleaned
|
||||
|
||||
class Meta:
|
||||
model = Collection
|
||||
fields = ['title', 'description', 'visibility', 'mode', 'team', 'filter_tags']
|
||||
fields = ['title', 'description', 'visibility', 'mode', 'team', 'filter_tags', 'include_notes', 'include_todos', 'include_links', 'include_journal']
|
||||
labels = {
|
||||
'title': _('Title'),
|
||||
'description': _('Description'),
|
||||
'visibility': _('Visibility'),
|
||||
'mode': _('Collection type'),
|
||||
'filter_tags': _('Content tags'),
|
||||
'include_notes': _('Notes'),
|
||||
'include_todos': _('Tasks'),
|
||||
'include_links': _('Links'),
|
||||
'include_journal': _('Journal'),
|
||||
}
|
||||
widgets = {
|
||||
'title': forms.TextInput(attrs={'class': 'form-control'}),
|
||||
@@ -176,6 +183,10 @@ class CollectionForm(forms.ModelForm):
|
||||
'visibility': forms.Select(attrs={'class': 'form-select'}),
|
||||
'mode': forms.Select(attrs={'class': 'form-select', 'x-model': 'mode'}),
|
||||
'filter_tags': forms.CheckboxSelectMultiple(),
|
||||
'include_notes': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
||||
'include_todos': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
||||
'include_links': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
||||
'include_journal': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user