Procházet zdrojové kódy

Reset scheduled publishing fields when dialog is closed

Sage Abdullah před 2 roky
rodič
revize
41c8512789

+ 10 - 0
client/src/entrypoints/admin/schedule-publishing.js

@@ -0,0 +1,10 @@
+document.addEventListener('DOMContentLoaded', () => {
+  const dialog = document.getElementById('schedule-publishing-dialog');
+
+  dialog.addEventListener('hide', () => {
+    const goLiveAt = document.getElementById('id_go_live_at');
+    const expireAt = document.getElementById('id_expire_at');
+    goLiveAt.value = goLiveAt.defaultValue;
+    expireAt.value = expireAt.defaultValue;
+  });
+});

+ 1 - 0
client/webpack.config.js

@@ -47,6 +47,7 @@ module.exports = function exports(env, argv) {
       'page-editor',
       'preview-panel',
       'privacy-switch',
+      'schedule-publishing',
       'sidebar',
       'task-chooser-modal',
       'task-chooser',

+ 7 - 0
wagtail/admin/panels.py

@@ -18,6 +18,7 @@ from modelcluster.models import get_serializable_data_for_fields
 
 from wagtail.admin import compare
 from wagtail.admin.forms.comments import CommentForm
+from wagtail.admin.staticfiles import versioned_static
 from wagtail.admin.templatetags.wagtailadmin_tags import avatar_url, user_display_name
 from wagtail.admin.ui.components import Component
 from wagtail.admin.widgets import AdminPageChooser
@@ -1094,6 +1095,12 @@ class PublishingPanel(MultiFieldPanel):
         def show_panel_furniture(self):
             return False
 
+        @property
+        def media(self):
+            return super().media + Media(
+                js=[versioned_static("wagtailadmin/js/schedule-publishing.js")],
+            )
+
 
 class CommentPanel(Panel):
     def get_form_options(self):