From 1dfe93ee24d5cd8c876b405edbeb436ee1596c45 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Mon, 10 Oct 2022 14:04:55 +0200 Subject: [PATCH] Add explicit locations plugin support --- app/controllers/custom_wizard/admin/wizard.rb | 3 ++- .../components/wizard-custom-action.js.es6 | 7 ++++++- .../discourse/lib/wizard-schema.js.es6 | 2 ++ .../components/wizard-custom-action.hbs | 21 ++++++++++++++++++- config/locales/client.en.yml | 1 + 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/controllers/custom_wizard/admin/wizard.rb b/app/controllers/custom_wizard/admin/wizard.rb index 7a316c84..c778bc7e 100644 --- a/app/controllers/custom_wizard/admin/wizard.rb +++ b/app/controllers/custom_wizard/admin/wizard.rb @@ -164,7 +164,8 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController messageable_level: mapped_params, visibility_level: mapped_params, members_visibility_level: mapped_params, - add_event: mapped_params + add_event: mapped_params, + add_location: mapped_params ] ) end diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index 2b6b35b4..c9c2c4c9 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -94,7 +94,12 @@ export default Component.extend(UndoChanges, { }, @discourseComputed("fieldTypes") - hasEventsField(fieldTypes) { + hasEventField(fieldTypes) { return fieldTypes.map((ft) => ft.id).includes("event"); }, + + @discourseComputed("fieldTypes") + hasLocationField(fieldTypes) { + return fieldTypes.map((ft) => ft.id).includes("location"); + }, }); diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index e9622c45..69254695 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -99,6 +99,7 @@ const action = { skip_redirect: null, suppress_notifications: null, add_event: null, + add_location: null, }, send_message: { title: null, @@ -196,6 +197,7 @@ const action = { "visibility_level", "members_visibility_level", "add_event", + "add_location", ], required: ["id", "type"], dependent: {}, diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 3b2222a0..51ff000e 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -161,7 +161,7 @@ - {{#if hasEventsField}} + {{#if hasEventField}}
@@ -179,6 +179,25 @@
{{/if}} + + {{#if hasLocationField}} +
+
+ +
+ +
+ {{wizard-mapper + inputs=action.add_location + property="add_location" + onUpdate=(action "mappedFieldUpdated") + options=(hash + wizardFieldSelection=true + context="action" + )}} +
+
+ {{/if}} {{/if}} {{#if sendMessage}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index f140dea7..267f099f 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -358,6 +358,7 @@ en: tags: "Tags" visible: "Visible" add_event: "Add Event (Events Plugin)" + add_location: "Add Location (Locations Plugin)" open_composer: label: "Open Composer" update_profile: