This commit is contained in:
@@ -5,12 +5,19 @@ function clearEditState() {
|
|||||||
toggleAbsenceEdit(false);
|
toggleAbsenceEdit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearButtonState() {
|
||||||
|
for (let b of document.querySelectorAll(".change-button-component")) {
|
||||||
|
b.type = "button";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function editWorkday(element, event, id, isWorkDay) {
|
function editWorkday(element, event, id, isWorkDay) {
|
||||||
console.log("editWorkday called", isWorkDay);
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let form = document.getElementById(id);
|
let form = document.getElementById(id);
|
||||||
if (form == null) {
|
if (form == null) {
|
||||||
form = element.closest(".grid-sub").querySelector(".all-booking-component > form");
|
form = element
|
||||||
|
.closest(".grid-sub")
|
||||||
|
.querySelector(".all-booking-component > form");
|
||||||
}
|
}
|
||||||
|
|
||||||
clearEditState();
|
clearEditState();
|
||||||
@@ -19,10 +26,12 @@ function editWorkday(element, event, id, isWorkDay) {
|
|||||||
|
|
||||||
if (isWorkDay) {
|
if (isWorkDay) {
|
||||||
element.classList.add("edit");
|
element.classList.add("edit");
|
||||||
if (element.classList.contains("edit")) {
|
if (element.type == "button") {
|
||||||
for (let input of form.querySelectorAll("input, select")) {
|
for (let input of form.querySelectorAll("input, select")) {
|
||||||
input.disabled = false;
|
input.disabled = false;
|
||||||
}
|
}
|
||||||
|
clearButtonState();
|
||||||
|
element.type = "submit";
|
||||||
} else {
|
} else {
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
@@ -30,10 +39,21 @@ function editWorkday(element, event, id, isWorkDay) {
|
|||||||
const absenceForm = document.getElementById("absence_form");
|
const absenceForm = document.getElementById("absence_form");
|
||||||
|
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
absenceForm.querySelector("[name=date_from]").value = form.id.replace("time-", "");
|
absenceForm.querySelector("[name=date_from]").value = form.id.replace(
|
||||||
absenceForm.querySelector("[name=date_to]").value = form.id.replace("time-", "");
|
"time-",
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
absenceForm.querySelector("[name=date_to]").value = form.id.replace(
|
||||||
|
"time-",
|
||||||
|
"",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
syncFields(form, absenceForm, ["date_from", "date_to", "aw_type", "aw_id"]);
|
syncFields(form, absenceForm, [
|
||||||
|
"date_from",
|
||||||
|
"date_to",
|
||||||
|
"aw_type",
|
||||||
|
"aw_id",
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.924
|
// templ: version: v0.3.943
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.924
|
// templ: version: v0.3.943
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.924
|
// templ: version: v0.3.943
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.924
|
// templ: version: v0.3.943
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ templ lineComponent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
templ changeButtonComponent(id string, workDay bool) {
|
templ changeButtonComponent(id string, workDay bool) {
|
||||||
<button class="btn w-auto group/button" type="submit" onclick={ templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), id, workDay) }>
|
<button class="change-button-component btn w-auto group/button" type="button" onclick={ templ.JSFuncCall("editWorkday", templ.JSExpression("this"), templ.JSExpression("event"), id, workDay) }>
|
||||||
<p class="hidden md:block group-[.edit]/button:hidden">Ändern</p>
|
<p class="hidden md:block group-[.edit]/button:hidden">Ändern</p>
|
||||||
<p class="hidden group-[.edit]/button:md:block">Absenden</p>
|
<p class="hidden group-[.edit]/button:md:block">Absenden</p>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="w-4 h-4 md:hidden">
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="w-4 h-4 md:hidden">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.924
|
// templ: version: v0.3.943
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
@@ -69,7 +69,7 @@ func changeButtonComponent(id string, workDay bool) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<button class=\"btn w-auto group/button\" type=\"submit\" onclick=\"")
|
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<button class=\"change-button-component btn w-auto group/button\" type=\"button\" onclick=\"")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.3.924
|
// templ: version: v0.3.943
|
||||||
package templates
|
package templates
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
|||||||
Reference in New Issue
Block a user