Le formulaire d'édition d'événements ne permet de sélectionner que des étiquettes
existantes, et avec l'interface "moderne"
This commit is contained in:
parent
28f5b2a01b
commit
e3c14437ac
@ -90,6 +90,15 @@ class CategorisationRuleImportForm(ModelForm):
|
||||
class EventForm(ModelForm):
|
||||
old_local_image = CharField(widget=HiddenInput(), required=False)
|
||||
|
||||
tags = MultipleChoiceField(
|
||||
label=_("Tags"),
|
||||
initial=None,
|
||||
choices=[],
|
||||
help_text=_('Optional. If you offer labels, they''ll make it easier for your girlfriends to find your event.'),
|
||||
required=False
|
||||
)
|
||||
|
||||
|
||||
class Meta:
|
||||
model = Event
|
||||
exclude = [
|
||||
@ -119,7 +128,6 @@ class EventForm(ModelForm):
|
||||
"other_versions": HiddenInput(),
|
||||
"uuids": MultipleHiddenInput(),
|
||||
"reference_urls": DynamicArrayWidgetURLs(),
|
||||
"tags": DynamicArrayWidgetTags(),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -131,6 +139,7 @@ class EventForm(ModelForm):
|
||||
self.fields['category'].queryset = self.fields['category'].queryset.order_by('name')
|
||||
self.fields['category'].empty_label = None
|
||||
self.fields['category'].initial = Category.get_default_category()
|
||||
self.fields['tags'].choices = Tag.get_tag_groups(all=True)
|
||||
|
||||
def is_clone_from_url(self):
|
||||
return self.cloning
|
||||
|
@ -82,5 +82,33 @@ Création d'une copie de {% else %}
|
||||
const element = document.querySelector('#id_exact_location');
|
||||
const choices = new Choices(element);
|
||||
|
||||
show_firstgroup = {
|
||||
choice(classes, choice) {
|
||||
const i = Choices.defaults.templates.choice.call(this, classes, choice);
|
||||
if (this.first_group !== null && choice.groupId == this.first_group)
|
||||
i.classList.add("visible");
|
||||
return i;
|
||||
},
|
||||
choiceGroup(classes, group) {
|
||||
const g = Choices.defaults.templates.choiceGroup.call(this, classes, group);
|
||||
if (this.first_group === undefined && group.value == "Suggestions")
|
||||
this.first_group = group.id;
|
||||
if (this.first_group !== null && group.id == this.first_group)
|
||||
g.classList.add("visible");
|
||||
return g;
|
||||
}
|
||||
};
|
||||
const tags = document.querySelector('#id_tags');
|
||||
const choices_tags = new Choices(tags,
|
||||
{
|
||||
placeholderValue: 'Sélectionner les étiquettes à ajouter',
|
||||
allowHTML: true,
|
||||
delimiter: ',',
|
||||
removeItemButton: true,
|
||||
shouldSort: false,
|
||||
callbackOnCreateTemplates: () => (show_firstgroup)
|
||||
}
|
||||
);
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user