From fd6c2e33597908b3d261941a3eaead517fc40035 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Wed, 9 Oct 2024 01:58:49 -0400 Subject: [PATCH] Fix saving sitemap definitions (#19) Fixes #15 Addresses wintercms/winter#1219, wintercms/winter#1222 Replaces #18 --- assets/js/sitemap-definitions.js | 5 +++-- formwidgets/SitemapItems.php | 8 -------- formwidgets/sitemapitems/partials/_sitemapitems.htm | 1 + 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/assets/js/sitemap-definitions.js b/assets/js/sitemap-definitions.js index f69e10c..82b745c 100644 --- a/assets/js/sitemap-definitions.js +++ b/assets/js/sitemap-definitions.js @@ -49,11 +49,12 @@ return result } - data.options.data['itemData'] = iterator($items) + const fieldName = $('div[data-control=sitemap-item-editor]').data('fieldName') + data.options.data[fieldName] = iterator($items); } $(document).ready(function(){ $.wn.sitemapDefinitions = new SitemapDefinitions() }) -}(window.jQuery); \ No newline at end of file +}(window.jQuery); diff --git a/formwidgets/SitemapItems.php b/formwidgets/SitemapItems.php index 55595d8..063cedf 100644 --- a/formwidgets/SitemapItems.php +++ b/formwidgets/SitemapItems.php @@ -75,14 +75,6 @@ protected function loadAssets() $this->addJs('js/sitemap-items-editor.js', 'core'); } - /** - * {@inheritDoc} - */ - public function getSaveValue($value) - { - return post('itemData'); - } - // // Methods for the internal use // diff --git a/formwidgets/sitemapitems/partials/_sitemapitems.htm b/formwidgets/sitemapitems/partials/_sitemapitems.htm index 8d6acd4..658bff8 100644 --- a/formwidgets/sitemapitems/partials/_sitemapitems.htm +++ b/formwidgets/sitemapitems/partials/_sitemapitems.htm @@ -3,6 +3,7 @@ data-control="sitemap-item-editor" data-alias="alias ?>" data-item-properties="" + data-field-name="getFieldName() ?>" >