From f11c393e5ca8bfd9ff95aa6befacce81f2af3ae3 Mon Sep 17 00:00:00 2001 From: Khadim Date: Fri, 15 Sep 2023 19:03:49 +0200 Subject: [PATCH] :) --- web/assets/init-admin.js | 9 +++++-- .../course/manage/edit-video-sections.gohtml | 7 +++--- web/ts/api/admin-lecture-list.ts | 9 ++++++- web/ts/data-store/admin-lecture-list.ts | 2 +- web/ts/edit-course.ts | 25 +++++++++++-------- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/web/assets/init-admin.js b/web/assets/init-admin.js index 6628576c0..518f41ffd 100644 --- a/web/assets/init-admin.js +++ b/web/assets/init-admin.js @@ -181,6 +181,10 @@ document.addEventListener("alpine:init", () => { const [changeSetExpression, fieldName = null] = expression.split("."); const changeSet = evaluate(changeSetExpression); + if (!changeSet) { + return; + } + const onChangeSetUpdateHandler = (data) => { const value = fieldName != null ? data[fieldName] : data; if (modifiers.includes("text")) { @@ -217,10 +221,11 @@ document.addEventListener("alpine:init", () => { * x-on-change-set-update.init="$el.innerText = friendlySectionTimestamp(sectionEditChangeSet.get())"> * */ - Alpine.directive("on-change-set-update", (el, { expression, modifiers }, { evaluateLater, cleanup }) => { + Alpine.directive("on-change-set-update", (el, { expression, modifiers }, { evaluate, evaluateLater, cleanup }) => { const onUpdate = evaluateLater(expression); const onChangeSetUpdateHandler = (e) => { + console.log(el, "trigger"); const isDirty = e.detail.changeSet.isDirty(); if (modifiers.includes("clean") && isDirty) { @@ -234,7 +239,7 @@ document.addEventListener("alpine:init", () => { el.addEventListener(nativeEventName, onChangeSetUpdateHandler); if (modifiers.includes("init")) { - onUpdate(); + evaluate(expression); } cleanup(() => { diff --git a/web/template/partial/course/manage/edit-video-sections.gohtml b/web/template/partial/course/manage/edit-video-sections.gohtml index a1d8047b3..461e1aaa0 100644 --- a/web/template/partial/course/manage/edit-video-sections.gohtml +++ b/web/template/partial/course/manage/edit-video-sections.gohtml @@ -74,7 +74,7 @@