diff --git a/assets/javascripts/discourse/components/wizard-subscription-container.js.es6 b/assets/javascripts/discourse/components/wizard-subscription-container.js.es6
index 5cc6b17c..3a1eac9c 100644
--- a/assets/javascripts/discourse/components/wizard-subscription-container.js.es6
+++ b/assets/javascripts/discourse/components/wizard-subscription-container.js.es6
@@ -7,7 +7,7 @@ export default Component.extend(Subscription, {
@discourseComputed("subscribed")
subscribedIcon(subscribed) {
- return subscribed ? "check" : "dash";
+ return subscribed ? "check" : "times";
},
@discourseComputed("subscribed")
diff --git a/assets/javascripts/discourse/routes/custom-wizard-step.js.es6 b/assets/javascripts/discourse/routes/custom-wizard-step.js.es6
index dd7b8be8..a882340b 100644
--- a/assets/javascripts/discourse/routes/custom-wizard-step.js.es6
+++ b/assets/javascripts/discourse/routes/custom-wizard-step.js.es6
@@ -1,6 +1,8 @@
import I18n from "I18n";
import { getCachedWizard } from "../models/custom-wizard";
import Route from "@ember/routing/route";
+import { scrollTop } from "discourse/mixins/scroll-top";
+import { action } from "@ember/object";
export default Route.extend({
beforeModel() {
@@ -48,4 +50,10 @@ export default Route.extend({
controller.setProperties(props);
},
+
+ @action
+ didTransition() {
+ scrollTop();
+ return true;
+ },
});
diff --git a/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs b/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs
index 303b3f6d..7fe0fd21 100644
--- a/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs
+++ b/assets/javascripts/discourse/templates/admin-wizards-api-show.hbs
@@ -32,13 +32,19 @@
- {{input type="checkbox" checked=wizard.after_signup}}
+
{{i18n "admin.wizard.after_signup_label"}}
@@ -88,7 +99,10 @@
- {{input type="checkbox" checked=wizard.prompt_completion}}
+
{{i18n "admin.wizard.prompt_completion_label"}}
@@ -98,7 +112,10 @@
- {{input type="checkbox" checked=wizard.after_time}}
+
{{i18n "admin.wizard.after_time_label"}}
{{d-button
action=(action "setNextSessionScheduled")
@@ -114,7 +131,10 @@
- {{input type="checkbox" checked=wizard.required}}
+
{{i18n "admin.wizard.required_label"}}
@@ -124,7 +144,10 @@
- {{input type="checkbox" checked=wizard.restart_on_revisit}}
+
{{i18n "admin.wizard.restart_on_revisit_label"}}
diff --git a/assets/javascripts/discourse/templates/components/custom-field-input.hbs b/assets/javascripts/discourse/templates/components/custom-field-input.hbs
index c0bdaaff..8c532cc9 100644
--- a/assets/javascripts/discourse/templates/components/custom-field-input.hbs
+++ b/assets/javascripts/discourse/templates/components/custom-field-input.hbs
@@ -20,9 +20,10 @@
)}}
- {{input
- value=field.name
- placeholder=(i18n "admin.wizard.custom_field.name.select")}}
+
|
{{multi-select
diff --git a/assets/javascripts/discourse/templates/components/custom-wizard-editor.hbs b/assets/javascripts/discourse/templates/components/custom-wizard-editor.hbs
index 5c1cc45b..6350594c 100644
--- a/assets/javascripts/discourse/templates/components/custom-wizard-editor.hbs
+++ b/assets/javascripts/discourse/templates/components/custom-wizard-editor.hbs
@@ -40,7 +40,12 @@
{{conditional-loading-spinner condition=loading}}
- {{textarea tabindex=tabindex value=value class="d-editor-input" placeholder=placeholder}}
+
{{/if}}
diff --git a/assets/javascripts/discourse/templates/components/custom-wizard-field-composer.hbs b/assets/javascripts/discourse/templates/components/custom-wizard-field-composer.hbs
index 2c966d24..5e54636b 100644
--- a/assets/javascripts/discourse/templates/components/custom-wizard-field-composer.hbs
+++ b/assets/javascripts/discourse/templates/components/custom-wizard-field-composer.hbs
@@ -15,6 +15,6 @@
{{#if field.char_counter}}
- {{char-counter field.value field.max_length}}
+ {{wizard-char-counter field.value field.max_length}}
{{/if}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
index 8763d3a5..6777c9db 100644
--- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
@@ -79,7 +79,10 @@
)}}
- {{input type="checkbox" checked=action.post_builder}}
+
{{i18n "admin.wizard.action.post_builder.checkbox"}}
@@ -408,7 +411,10 @@
- {{input type="checkbox" checked=action.wizard_user}}
+
@@ -477,7 +483,10 @@
- {{input type="checkbox" checked=action.wizard_user}}
+
@@ -877,7 +886,10 @@
- {{input type="checkbox" checked=action.skip_redirect}}
+
{{i18n "admin.wizard.action.skip_redirect.description" type="topic"}}
@@ -891,7 +903,10 @@
- {{input type="checkbox" checked=action.suppress_notifications}}
+
{{i18n "admin.wizard.action.suppress_notifications.description" type="topic"}}
@@ -907,7 +922,7 @@
- {{input value=action.code}}
+
{{/if}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs
index 6273f9a9..038d22fb 100644
--- a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs
@@ -11,7 +11,10 @@
- {{input name="label" value=field.label}}
+
@@ -22,7 +25,10 @@
{{i18n "admin.wizard.field.required_label"}}
- {{input type="checkbox" checked=field.required}}
+
@@ -31,7 +37,10 @@
- {{textarea name="description" value=field.description}}
+
@@ -78,11 +87,12 @@
- {{input
- type="number"
+
@@ -92,11 +102,12 @@
- {{input
- type="number"
+
@@ -107,9 +118,10 @@
{{i18n "admin.wizard.field.char_counter_placeholder"}}
- {{input
- type="checkbox"
- checked=field.char_counter}}
+
@@ -119,10 +131,11 @@
- {{textarea
+
{{/if}}
@@ -134,7 +147,11 @@
- {{textarea name="preview-template" value=field.preview_template class="preview-template"}}
+
{{/if}}
@@ -146,7 +163,10 @@
- {{input value=field.file_types class="medium"}}
+
{{/if}}
@@ -158,7 +178,11 @@
- {{input type="number" value=field.limit class="small"}}
+
{{/if}}
@@ -170,7 +194,10 @@
- {{input value=field.format class="medium"}}
+
@@ -229,9 +256,10 @@
- {{input
- type="checkbox"
- checked=field.can_create_tag}}
+
{{/if}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs
index 40ac09e0..c1aadd4b 100644
--- a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs
@@ -3,9 +3,10 @@
- {{input
+
@@ -51,7 +52,10 @@
{{i18n "admin.wizard.step.force_final.label"}}
- {{input type="checkbox" checked=step.force_final}}
+
{{i18n "admin.wizard.step.force_final.description"}}
@@ -77,7 +81,9 @@
{{i18n "admin.wizard.step.required_data.not_permitted_message"}}
- {{input value=step.required_data_message}}
+
{{/if}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs b/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs
index cb94b7ae..8ab5ea37 100644
--- a/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-mapper-selector.hbs
@@ -21,11 +21,12 @@
{{#if showText}}
- {{input
- type="text"
- value=value
- placeholder=(i18n placeholderKey)
- change=(action "changeInputValue")}}
+
{{/if}}
{{#if showComboBox}}
diff --git a/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs b/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs
index 8269d6ca..c01b3095 100644
--- a/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-realtime-validations.hbs
@@ -7,7 +7,10 @@
{{i18n (concat "admin.wizard.field.validations." type)}}
- {{input type="checkbox" checked=props.status}}
+
{{i18n "admin.wizard.field.validations.enabled"}}
@@ -27,7 +30,11 @@
- {{input type="number" class="time-n-value" value=props.time_n_value}}
+
{{combo-box
value=(readonly props.time_unit)
content=timeUnits
diff --git a/lib/custom_wizard/action.rb b/lib/custom_wizard/action.rb
index 34f81455..ac0799f3 100644
--- a/lib/custom_wizard/action.rb
+++ b/lib/custom_wizard/action.rb
@@ -456,11 +456,16 @@ class CustomWizard::Action
if new_group_params[:usernames].present?
user_ids = get_user_ids(new_group_params[:usernames])
+ if user_ids.count < new_group_params[:usernames].count
+ log_error("Warning, group creation: some users were not found!")
+ end
user_ids -= owner_ids if owner_ids
user_ids.each { |user_id| group.group_users.build(user_id: user_id) }
end
- log_success("Group created", group.name)
+ if group.save
+ log_success("Group created", group.name)
+ end
result.output = group.name
else
diff --git a/plugin.rb b/plugin.rb
index 4e7c8aef..342b781e 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
-# version: 2.2.20
+# version: 2.3.2
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech
# subscription_url: https://coop.pavilion.tech
-gem 'liquid', '5.0.1', require: true
-register_asset 'stylesheets/common/admin.scss'
-register_asset 'stylesheets/common/wizard.scss'
+gem "liquid", "5.0.1", require: true
+register_asset "stylesheets/common/admin.scss"
+register_asset "stylesheets/common/wizard.scss"
enabled_site_setting :custom_wizard_enabled
@@ -111,7 +111,7 @@ after_initialize do
Liquid::Template.register_filter(::CustomWizard::LiquidFilter::FirstNonEmpty)
add_to_class(:topic, :wizard_submission_id) do
- custom_fields['wizard_submission_id']
+ custom_fields["wizard_submission_id"]
end
add_class_method(:wizard, :user_requires_completion?) do |user|
@@ -123,7 +123,6 @@ after_initialize do
if user &&
user.first_seen_at.blank? &&
wizard = CustomWizard::Wizard.after_signup(user)
-
if !wizard.completed?
custom_redirect = true
CustomWizard::Wizard.set_user_redirect(wizard.id, user)
@@ -134,8 +133,8 @@ after_initialize do
end
add_to_class(:user, :redirect_to_wizard) do
- if custom_fields['redirect_to_wizard'].present?
- custom_fields['redirect_to_wizard']
+ if custom_fields["redirect_to_wizard"].present?
+ custom_fields["redirect_to_wizard"]
else
nil
end
@@ -160,10 +159,10 @@ after_initialize do
end
add_to_class(:application_controller, :redirect_to_wizard_if_required) do
- @excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/']
+ @excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split("|") + ["/w/"]
url = request.referer || request.original_url
excluded_route = @excluded_routes.any? { |str| /#{str}/ =~ url }
- not_api = request.format === 'text/html'
+ not_api = request.format === "text/html"
if not_api && !excluded_route
wizard_id = current_user.redirect_to_wizard
@@ -203,7 +202,7 @@ after_initialize do
full_path = "#{Rails.root}/plugins/discourse-custom-wizard/assets/stylesheets/wizard/wizard_custom.scss"
if Stylesheet::Importer.respond_to?(:plugin_assets)
- Stylesheet::Importer.plugin_assets['wizard_custom'] = Set[full_path]
+ Stylesheet::Importer.plugin_assets["wizard_custom"] = Set[full_path]
else
# legacy method, Discourse 2.7.0.beta5 and below
DiscoursePluginRegistry.register_asset(full_path, {}, "wizard_custom")
diff --git a/spec/components/custom_wizard/action_spec.rb b/spec/components/custom_wizard/action_spec.rb
index 79c64520..c450582d 100644
--- a/spec/components/custom_wizard/action_spec.rb
+++ b/spec/components/custom_wizard/action_spec.rb
@@ -2,6 +2,7 @@
describe CustomWizard::Action do
fab!(:user) { Fabricate(:user, name: "Angus", username: 'angus', email: "angus@email.com", trust_level: TrustLevel[2]) }
+ fab!(:user1) { Fabricate(:user, name: "Angus One", username: 'angus1', email: "angus_one@email.com", trust_level: TrustLevel[2]) }
fab!(:category) { Fabricate(:category, name: 'cat1', slug: 'cat-slug') }
fab!(:tag) { Fabricate(:tag, name: 'tag1') }
fab!(:group) { Fabricate(:group) }
@@ -12,6 +13,7 @@ describe CustomWizard::Action do
let(:watch_categories) { get_wizard_fixture("actions/watch_categories") }
let(:watch_tags) { get_wizard_fixture("actions/watch_tags") }
let(:create_group) { get_wizard_fixture("actions/create_group") }
+ let(:create_group_with_nonexistent_user) { get_wizard_fixture("actions/create_group_bad_user") }
let(:add_to_group) { get_wizard_fixture("actions/add_to_group") }
let(:send_message) { get_wizard_fixture("actions/send_message") }
let(:send_message_multi) { get_wizard_fixture("actions/send_message_multi") }
@@ -350,7 +352,25 @@ describe CustomWizard::Action do
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(wizard.steps[0].id, step_1_field_1: "Text input").update
+ group_id = Group.where(name: wizard.current_submission.fields['action_9']).first.id
+ user_id = User.find_by(username: wizard_template['actions'][4]['usernames'][0]["output"][0]).id
+
expect(Group.where(name: wizard.current_submission.fields['action_9']).exists?).to eq(true)
+ expect(GroupUser.where(group_id: group_id, user_id: user_id).exists?).to eq(true)
+ end
+
+ it '#create_group completes successfully when user included in usernames does not exist but excludes users who do not exist and includes warning in log' do
+ wizard_template['actions'] << create_group_with_nonexistent_user
+ update_template(wizard_template)
+
+ wizard = CustomWizard::Builder.new(@template[:id], user).build
+ wizard.create_updater(wizard.steps[0].id, step_1_field_1: "Text input").update
+
+ group_id = Group.where(name: wizard.current_submission.fields['action_9']).first.id
+
+ expect(CustomWizard::Log.list_query.all.last.value.include? "some users were not found").to eq(true)
+ expect(Group.where(name: wizard.current_submission.fields['action_9']).exists?).to eq(true)
+ expect(GroupUser.where(group_id: group_id).count).to eq(1)
end
it '#add_to_group' do
diff --git a/spec/fixtures/actions/create_group_bad_user.json b/spec/fixtures/actions/create_group_bad_user.json
new file mode 100644
index 00000000..96d6796d
--- /dev/null
+++ b/spec/fixtures/actions/create_group_bad_user.json
@@ -0,0 +1,104 @@
+{
+ "id": "action_9",
+ "run_after": "step_1",
+ "type": "create_group",
+ "title": [
+ {
+ "type": "assignment",
+ "output": "New Group Member",
+ "output_type": "text",
+ "output_connector": "set"
+ }
+ ],
+ "custom_fields": [
+ {
+ "type": "association",
+ "pairs": [
+ {
+ "index": 0,
+ "key": "group_custom_field",
+ "key_type": "text",
+ "value": "step_3_field_1",
+ "value_type": "wizard_field",
+ "connector": "association"
+ }
+ ]
+ }
+ ],
+ "name": [
+ {
+ "type": "assignment",
+ "output": "step_1_field_1",
+ "output_type": "wizard_field",
+ "output_connector": "set"
+ }
+ ],
+ "full_name": [
+ {
+ "type": "assignment",
+ "output": "step_1_field_1",
+ "output_type": "wizard_field",
+ "output_connector": "set"
+ }
+ ],
+ "usernames": [
+ {
+ "type": "assignment",
+ "output_type": "user",
+ "output_connector": "set",
+ "output": [
+ "angus3"
+ ]
+ }
+ ],
+ "owner_usernames": [
+ {
+ "type": "assignment",
+ "output_type": "user",
+ "output_connector": "set",
+ "output": [
+ "angus"
+ ]
+ }
+ ],
+ "grant_trust_level": [
+ {
+ "type": "assignment",
+ "output": "3",
+ "output_type": "text",
+ "output_connector": "set"
+ }
+ ],
+ "mentionable_level": [
+ {
+ "type": "assignment",
+ "output": "1",
+ "output_type": "text",
+ "output_connector": "set"
+ }
+ ],
+ "messageable_level": [
+ {
+ "type": "assignment",
+ "output": "2",
+ "output_type": "text",
+ "output_connector": "set"
+ }
+ ],
+ "visibility_level": [
+ {
+ "type": "assignment",
+ "output": "3",
+ "output_type": "text",
+ "output_connector": "set"
+ }
+ ],
+ "members_visibility_level": [
+ {
+ "type": "assignment",
+ "output": "99",
+ "output_type": "text",
+ "output_connector": "set"
+ }
+ ]
+}
\ No newline at end of file
|