From 8fb44749f5229ccfbe261ca1fa46927a6eda5ca0 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 16 Jul 2020 15:25:06 +1000 Subject: [PATCH] Add create_group --- .../components/wizard-custom-action.js.es6 | 1 + .../components/wizard-custom-field.js.es6 | 2 +- .../discourse/lib/wizard-schema.js.es6 | 11 ++ .../components/wizard-custom-action.hbs | 165 ++++++++++++++++++ config/locales/client.en.yml | 11 ++ controllers/custom_wizard/admin/wizard.rb | 11 +- lib/custom_wizard/action.rb | 2 - 7 files changed, 199 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 index af80d30c..c661db3e 100644 --- a/assets/javascripts/discourse/components/wizard-custom-action.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-action.js.es6 @@ -21,6 +21,7 @@ export default Component.extend(UndoChanges, { addToGroup: equal('action.type', 'add_to_group'), routeTo: equal('action.type', 'route_to'), createCategory: equal('action.type', 'create_category'), + createGroup: equal('action.type', 'create_group'), apiEmpty: empty('action.api'), groupPropertyTypes: selectKitContent(['id', 'name']), hasAdvanced: or('hasCustomFields', 'routeTo'), diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 9251f433..bd44fde0 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -17,7 +17,7 @@ export default Component.extend(UndoChanges, { isText: equal('field.type', 'text'), isTextarea: equal('field.type', 'textarea'), isUrl: equal('field.type', 'url'), - showPrefill: or('isCategory', 'isTag', 'isGroup', 'isDropdown'), + showPrefill: or('isText', 'isCategory', 'isTag', 'isGroup', 'isDropdown'), showContent: or('isCategory', 'isTag', 'isGroup', 'isDropdown'), showLimit: or('isCategory', 'isTag'), showMinLength: or('isText', 'isTextarea', 'isUrl', 'isComposer'), diff --git a/assets/javascripts/discourse/lib/wizard-schema.js.es6 b/assets/javascripts/discourse/lib/wizard-schema.js.es6 index b21142d2..c377d3b9 100644 --- a/assets/javascripts/discourse/lib/wizard-schema.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-schema.js.es6 @@ -165,6 +165,17 @@ const action = { text_color: "FFFFFF", parent_category_id: null, permissions: null + }, + create_group: { + name: null, + full_name: null, + title: null, + bio_raw: null, + grant_trust_level: null, + mentionable_level: null, + messageable_level: null, + visibility_level: null, + members_visibility_level: null } }, mapped: [ diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 3f69f8f1..2cf5e446 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -340,6 +340,171 @@ {{/if}} +{{#if createGroup}} +
+
+ +
+ +
+ {{wizard-mapper + inputs=action.name + property='name' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.full_name + property='full_name' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.title + property='title' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.bio_raw + property='bio_raw' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.grant_trust_level + property='grant_trust_level' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.mentionable_level + property='mentionable_level' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.messageable_level + property='messageable_level' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.visibility_level + property='visibility_level' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+
+
+ +
+ +
+ {{wizard-mapper + inputs=action.members_visibility_level + property='members_visibility_level' + onUpdate=(action 'mappedFieldUpdated') + options=(hash + textSelection=true + wizardFieldSelection=true + userFieldSelection=true + context='action' + )}} +
+
+{{/if}} + {{#if createCategory}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index ed522795..9a7503f5 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -249,6 +249,17 @@ en: text_color: Text color parent_category: Parent Category permissions: Permissions + create_group: + label: Create Group + name: Name + full_name: Full Name + title: Title + bio_raw: About + grant_trust_level: Automatic Trust Level + mentionable_level: Mentionable Level + messageable_level: Messageable Level + visibility_level: Visibility Level + members_visibility_level: Members Visibility Level submissions: nav_label: "Submissions" diff --git a/controllers/custom_wizard/admin/wizard.rb b/controllers/custom_wizard/admin/wizard.rb index 865821ad..70ec764a 100644 --- a/controllers/custom_wizard/admin/wizard.rb +++ b/controllers/custom_wizard/admin/wizard.rb @@ -136,7 +136,16 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController color: mapped_params, text_color: mapped_params, parent_category_id: mapped_params, - permissions: mapped_params + permissions: mapped_params, + full_name: mapped_params, + bio_raw: mapped_params, + title: mapped_params, + bio_raw: mapped_params, + grant_trust_level: mapped_params, + mentionable_level: mapped_params, + messageable_level: mapped_params, + visibility_level: mapped_params, + members_visibility_level: mapped_params ] ) end diff --git a/lib/custom_wizard/action.rb b/lib/custom_wizard/action.rb index 26346741..8ee1f8a4 100644 --- a/lib/custom_wizard/action.rb +++ b/lib/custom_wizard/action.rb @@ -297,8 +297,6 @@ class CustomWizard::Action def create_category guardian.ensure_can_create!(Category) - byebug - category = begin Category.new(new_category_params.merge(user: user))