From a6bbf2c41d42cd6e6a1591b7f76e058be6d9bba3 Mon Sep 17 00:00:00 2001 From: Thomas Templeton Date: Sun, 16 Jun 2024 16:44:11 +1000 Subject: [PATCH] Prevent accidentally saving Neo field as different type #21 --- CHANGELOG.md | 5 +++++ client/src/scripts/FieldModal.ts | 24 ++++++++++++++++++++++++ client/src/styles/modal.scss | 4 ++++ src/controllers/QuickFieldController.php | 21 +-------------------- src/resources/css/main.css | 2 +- src/resources/css/main.css.map | 2 +- src/resources/js/main.js | 2 +- src/resources/js/main.js.map | 2 +- src/translations/en/quick-field.php | 1 + 9 files changed, 39 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8505abd..4033cd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +### Changed +- The Neo field type is now listed in the field type selection dropdown, and the save buttons replaced with a message indicating lack of support for saving the field type, preventing the possibility of accidentally saving a Neo field as a different field type + ## 2.0.7 - 2023-10-16 ### Fixed diff --git a/client/src/scripts/FieldModal.ts b/client/src/scripts/FieldModal.ts index 3e87e5e..b77055e 100644 --- a/client/src/scripts/FieldModal.ts +++ b/client/src/scripts/FieldModal.ts @@ -16,8 +16,10 @@ interface FieldModalInterface extends GarnishModal { $deleteBtn: JQuery $deleteSpinner: JQuery $loadSpinner: JQuery + $cancelBtn: JQuery $saveBtn: JQuery $saveCopyBtn: JQuery + $unsupportedMessage: JQuery $saveSpinner: JQuery $observed: JQuery executedJs: Record @@ -44,6 +46,10 @@ interface SettingsEvent extends Event { $css: JQuery } +const unsupportedFieldTypes = [ + 'benf\\neo\\Field' +] + /** * FieldModal class * Handles the modal window for creating new fields. @@ -129,6 +135,7 @@ const FieldModal = Garnish.Modal.extend({ this.$cancelBtn = $('
').text(Craft.t('quick-field', 'Cancel')).appendTo(this.$rightButtons) this.$saveBtn = $('
').text(Craft.t('quick-field', 'Save')).appendTo(this.$rightButtons) this.$saveCopyBtn = $('