Skip to content
Snippets Groups Projects
Commit a0e8d5de authored by Nadja Geisler's avatar Nadja Geisler :sunny:
Browse files

Merge branch 'feature-time-input' into 'main'

Provide alternative input for availabilities/slots (in addition to calendar view) and improve default slot input

Closes #174 and #124

See merge request !151
parents 9056f6e6 7ccd63a3
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,8 @@ class AvailabilitiesFormMixin(forms.Form): ...@@ -20,7 +20,8 @@ class AvailabilitiesFormMixin(forms.Form):
availabilities = forms.CharField( availabilities = forms.CharField(
label=_('Availability'), label=_('Availability'),
help_text=_( help_text=_(
'Click and drag to mark the availability during the event, double-click to delete.' # Adapted help text 'Click and drag to mark the availability during the event, double-click to delete. '
'Or use the start and end inputs to add entries to the calendar view.' # Adapted help text
), ),
widget=forms.TextInput(attrs={'class': 'availabilities-editor-data'}), widget=forms.TextInput(attrs={'class': 'availabilities-editor-data'}),
required=False, required=False,
......
...@@ -112,7 +112,8 @@ class DefaultSlotEditorForm(AdminIntermediateForm): ...@@ -112,7 +112,8 @@ class DefaultSlotEditorForm(AdminIntermediateForm):
availabilities = forms.CharField( availabilities = forms.CharField(
label=_('Default Slots'), label=_('Default Slots'),
help_text=_( help_text=_(
'Click and drag to mark the availability during the event, double-click to delete.' # Adapted help text 'Click and drag to add default slots, double-click to delete. '
'Or use the start and end inputs to add entries to the calendar view.'
), ),
widget=forms.TextInput(attrs={'class': 'availabilities-editor-data'}), widget=forms.TextInput(attrs={'class': 'availabilities-editor-data'}),
required=True, required=True,
......
...@@ -2,7 +2,7 @@ msgid "" ...@@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-27 00:33+0100\n" "POT-Creation-Date: 2022-12-28 01:03+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -81,23 +81,24 @@ msgstr "Constraintverletzungen auf Level \"Warning\" setzen" ...@@ -81,23 +81,24 @@ msgstr "Constraintverletzungen auf Level \"Warning\" setzen"
msgid "Availability" msgid "Availability"
msgstr "Verfügbarkeit" msgstr "Verfügbarkeit"
#: AKModel/availability/forms.py:23 AKModel/forms.py:115 #: AKModel/availability/forms.py:23
msgid "" msgid ""
"Click and drag to mark the availability during the event, double-click to " "Click and drag to mark the availability during the event, double-click to "
"delete." "delete. Or use the start and end inputs to add entries to the calendar view."
msgstr "" msgstr ""
"Klicken und ziehen um die Verfügbarkeiten während des Events zu markieren. " "Klicken und ziehen um die Verfügbarkeiten während des Events zu markieren. "
"Doppelt klicken um Einträge zu löschen." "Doppelt klicken um Einträge zu löschen. Oder Start- und End-Eingabe "
"verwenden, um der Kalenderansicht neue Einträge hinzuzufügen."
#: AKModel/availability/forms.py:87 #: AKModel/availability/forms.py:88
msgid "The submitted availability does not comply with the required format." msgid "The submitted availability does not comply with the required format."
msgstr "Die eingetragenen Verfügbarkeit haben nicht das notwendige Format." msgstr "Die eingetragenen Verfügbarkeit haben nicht das notwendige Format."
#: AKModel/availability/forms.py:100 #: AKModel/availability/forms.py:101
msgid "The submitted availability contains an invalid date." msgid "The submitted availability contains an invalid date."
msgstr "Die eingegebene Verfügbarkeit enthält ein ungültiges Datum." msgstr "Die eingegebene Verfügbarkeit enthält ein ungültiges Datum."
#: AKModel/availability/forms.py:123 AKModel/availability/forms.py:133 #: AKModel/availability/forms.py:124 AKModel/availability/forms.py:134
msgid "Please fill in your availabilities!" msgid "Please fill in your availabilities!"
msgstr "Bitte Verfügbarkeiten eintragen!" msgstr "Bitte Verfügbarkeiten eintragen!"
...@@ -212,11 +213,20 @@ msgstr "" ...@@ -212,11 +213,20 @@ msgstr ""
msgid "Default Slots" msgid "Default Slots"
msgstr "Standardslots" msgstr "Standardslots"
#: AKModel/forms.py:124 #: AKModel/forms.py:115
msgid ""
"Click and drag to add default slots, double-click to delete. Or use the "
"start and end inputs to add entries to the calendar view."
msgstr ""
"Klicken und ziehen um Standardslots hinzuzufügen, doppelt klicken um "
"Einträge zu löschen. Oder Start- und End-Eingabe verwenden, um der "
"Kalenderansicht neue Einträge hinzuzufügen."
#: AKModel/forms.py:125
msgid "New rooms" msgid "New rooms"
msgstr "Neue Räume" msgstr "Neue Räume"
#: AKModel/forms.py:125 #: AKModel/forms.py:126
msgid "" msgid ""
"Enter room details in CSV format. Required colum is \"name\", optional " "Enter room details in CSV format. Required colum is \"name\", optional "
"colums are \"location\", \"capacity\", and \"url\" for online/hybrid rooms. " "colums are \"location\", \"capacity\", and \"url\" for online/hybrid rooms. "
...@@ -226,7 +236,7 @@ msgstr "" ...@@ -226,7 +236,7 @@ msgstr ""
"Spalten sind \"location\", \"capacity\", und \"url\" for Online-/" "Spalten sind \"location\", \"capacity\", und \"url\" for Online-/"
"HybridräumeTrennzeichen: Semikolon" "HybridräumeTrennzeichen: Semikolon"
#: AKModel/forms.py:136 #: AKModel/forms.py:137
msgid "CSV must contain a name column" msgid "CSV must contain a name column"
msgstr "CSV muss eine name-Spalte enthalten" msgstr "CSV muss eine name-Spalte enthalten"
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
'{{ event.timezone }}', '{{ event.timezone }}',
'{{ LANGUAGE_CODE }}', '{{ LANGUAGE_CODE }}',
'{{ event.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}', '{{ event.start | timezone:event.timezone | date:"Y-m-d H:i:s" }}',
'{{ event.end | timezone:event.timezone | date:"Y-m-d H:i:s" }}' '{{ event.end | timezone:event.timezone | date:"Y-m-d H:i:s" }}',
'00:15:00'
); );
}); });
</script> </script>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// It was significantly changed to deal with the newer fullcalendar version, event specific timezones, // It was significantly changed to deal with the newer fullcalendar version, event specific timezones,
// to remove the dependency to moments timezone and improve the visualization of deletion // to remove the dependency to moments timezone and improve the visualization of deletion
function createAvailabilityEditors(timezone, language, startDate, endDate) { function createAvailabilityEditors(timezone, language, startDate, endDate, slotResolution='00:30:00') {
$("input.availabilities-editor-data").each(function () { $("input.availabilities-editor-data").each(function () {
const eventColor = '#28B62C'; const eventColor = '#28B62C';
...@@ -16,6 +16,20 @@ function createAvailabilityEditors(timezone, language, startDate, endDate) { ...@@ -16,6 +16,20 @@ function createAvailabilityEditors(timezone, language, startDate, endDate) {
data_field.after(editor); data_field.after(editor);
data_field.hide(); data_field.hide();
// Add inputs to add slots without the need to click and drag
let manualSlotAdderSource = "<form id='formManualAdd'><table class='table table-responsive mb-0'><tr>" +
"<td style='vertical-align: middle;'><input type='datetime-local' id='inputStart' value='" + startDate + "' min='" + startDate + "' max='" + endDate + "'></td>" +
"<td style='vertical-align: middle;'><i class=\"fas fa-long-arrow-alt-right\"></i></td>" +
"<td style='vertical-align: middle;'><input type='datetime-local' id='inputEnd' value='" + endDate + "' min='" + startDate + "' max='" + endDate + "'></td>" +
"<td><button class='btn btn-primary' type='submit'><i class=\"fas fa-plus\"></i></button></td></tr></table></form>";
let manualSlotAdder = $(manualSlotAdderSource);
editor.after(manualSlotAdder);
$('#formManualAdd').submit(function(event) {
add($('#inputStart').val(), $('#inputEnd').val());
event.preventDefault();
});
let editable = !Boolean(data_field.attr("disabled")); let editable = !Boolean(data_field.attr("disabled"));
let data = JSON.parse(data_field.attr("value")); let data = JSON.parse(data_field.attr("value"));
let events = data.availabilities.map(function (e) { let events = data.availabilities.map(function (e) {
...@@ -58,15 +72,7 @@ function createAvailabilityEditors(timezone, language, startDate, endDate) { ...@@ -58,15 +72,7 @@ function createAvailabilityEditors(timezone, language, startDate, endDate) {
events: data.availabilities, events: data.availabilities,
eventBackgroundColor: eventColor, eventBackgroundColor: eventColor,
select: function (info) { select: function (info) {
resetDeletionCandidate(); add(info.start, info.end);
plan.addEvent({
title: "",
start: info.start,
end: info.end,
id: 'new' + newEventsCounter
})
newEventsCounter++;
save_events();
}, },
eventClick: function (info) { eventClick: function (info) {
if (eventMarkedForDeletion !== undefined && (eventMarkedForDeletion.id === info.event.id)) { if (eventMarkedForDeletion !== undefined && (eventMarkedForDeletion.id === info.event.id)) {
...@@ -84,9 +90,22 @@ function createAvailabilityEditors(timezone, language, startDate, endDate) { ...@@ -84,9 +90,22 @@ function createAvailabilityEditors(timezone, language, startDate, endDate) {
selectOverlap: false, selectOverlap: false,
eventOverlap: false, eventOverlap: false,
eventChange: save_events, eventChange: save_events,
slotDuration: slotResolution,
}); });
plan.render(); plan.render();
function add(start, end) {
resetDeletionCandidate();
plan.addEvent({
title: "",
start: start,
end: end,
id: 'new' + newEventsCounter
})
newEventsCounter++;
save_events();
}
function makeDeletionCandidate(el) { function makeDeletionCandidate(el) {
el.classList.add("deleteEvent"); el.classList.add("deleteEvent");
$(el).find(".fc-event-title").html("<i class='fas fa-trash'></i> <i class='fas fa-question'></i>"); $(el).find(".fc-event-title").html("<i class='fas fa-trash'></i> <i class='fas fa-question'></i>");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment