From 79370b5c5f077a509880e4fc3639800c19ada73f Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Wed, 27 Sep 2023 16:38:20 +0200 Subject: [PATCH] [Writable] only allow writable definitions to be saved --- .../EventListener/PimcoreSettingsListener.php | 3 +-- .../Resources/config/serializer/Model.ExportDefinition.yml | 5 +++++ .../Resources/config/serializer/Model.ImportDefinition.yml | 5 +++++ .../Resources/public/pimcore/js/export/item.js | 2 +- .../Resources/public/pimcore/js/import/item.js | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php b/src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php index 82e8bab9..9b48546d 100644 --- a/src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php +++ b/src/DataDefinitionsBundle/EventListener/PimcoreSettingsListener.php @@ -24,7 +24,6 @@ class PimcoreSettingsListener { public function indexSettings(IndexActionSettingsEvent $settingsEvent): void { - $settingsEvent->addSetting('data-definitions-import-definition-writeable', (new ImportDefinition())->isWriteable()); - $settingsEvent->addSetting('data-definitions-export-definition-writeable', (new ExportDefinition())->isWriteable()); + } } diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml index fb48406b..30e861c6 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ExportDefinition.yml @@ -14,3 +14,8 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ExportDefinition: expose: true type: boolean groups: [ Detailed ] + virtual_properties: + isWriteable: + exp: object.isWriteable() + type: boolean + serialized_name: isWriteable \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml index 1ec31c51..df9641c6 100755 --- a/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml +++ b/src/DataDefinitionsBundle/Resources/config/serializer/Model.ImportDefinition.yml @@ -50,3 +50,8 @@ Wvision\Bundle\DataDefinitionsBundle\Model\ImportDefinition: expose: true type: boolean groups: [ Detailed ] + virtual_properties: + isWriteable: + exp: object.isWriteable() + type: boolean + serialized_name: isWriteable \ No newline at end of file diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js index 890ba4aa..1e1b2799 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/export/item.js @@ -25,7 +25,7 @@ pimcore.plugin.datadefinitions.export.item = Class.create(pimcore.plugin.datadef providers: [], saveDisabled: function () { - return !pimcore.settings['data-definitions-export-definition-writeable']; + return !this.data.isWriteable; }, getSettings: function () { diff --git a/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js b/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js index 2bbf0843..b10f623a 100644 --- a/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js +++ b/src/DataDefinitionsBundle/Resources/public/pimcore/js/import/item.js @@ -26,7 +26,7 @@ pimcore.plugin.datadefinitions.import.item = Class.create(pimcore.plugin.datadef providers: [], saveDisabled: function () { - return !pimcore.settings['data-definitions-import-definition-writeable']; + return !this.data.isWriteable; }, getSettings: function () {