0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 10:40:28 +01:00

FEATURE: added ability for user to selected watched categories in wizard

Dieser Commit ist enthalten in:
Robert Barrow 2020-05-22 23:42:26 +01:00
Ursprung b196acf151
Commit f4a9cf86f2
7 geänderte Dateien mit 68 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -12,6 +12,7 @@ export default Component.extend(UndoChanges, {
visible: computed('currentActionId', function() { return this.action.id === this.currentActionId }),
createTopic: equal('action.type', 'create_topic'),
updateProfile: equal('action.type', 'update_profile'),
watchCategories: equal('action.type', 'watch_categories'),
sendMessage: equal('action.type', 'send_message'),
openComposer: equal('action.type', 'open_composer'),
sendToApi: equal('action.type', 'send_to_api'),

Datei anzeigen

@ -141,6 +141,10 @@ const action = {
profile_updates: null,
custom_fields: null
},
watch_categories: {
category: null,
mute_remainder: null
},
add_to_group: {
group: null
},
@ -158,6 +162,7 @@ const action = {
'recipient',
'profile_updates',
'group',
'mute_remainder',
'url'
],
advanced: [

Datei anzeigen

@ -10,7 +10,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.type"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.type
@ -26,7 +26,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.run_after.label"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.run_after
@ -45,7 +45,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.title"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.title
@ -102,7 +102,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.category"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.category
@ -123,7 +123,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.tags"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.tags
@ -146,7 +146,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_message.recipient"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.recipient
@ -170,7 +170,7 @@
<div class="setting-label">
<label>{{i18n 'admin.wizard.action.update_profile.setting'}}</label>
</div>
{{wizard-mapper
inputs=action.profile_updates
property='profile_updates'
@ -191,7 +191,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_to_api.api"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.api
@ -208,7 +208,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_to_api.endpoint"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.api_endpoint
@ -225,7 +225,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_to_api.body"}}</label>
</div>
<div class="setting-value">
{{wizard-text-editor
value=action.api_body
@ -242,7 +242,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.group"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.group
@ -265,7 +265,7 @@
<div class="setting-label">
<label>{{i18n "admin.wizard.action.route_to.url"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.url
@ -283,18 +283,41 @@
</div>
{{/if}}
{{#if watchCategories}}
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.watch_categories.mute_remainder"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.mute_remainder
property='mute_remainder'
onUpdate=(action 'mappedFieldUpdated')
options=(hash
context='action'
wizardFieldSelection=true
userFieldSelection='key,value'
groupSelection='key,value'
categorySelection='key,value'
userSelection='key,value'
)}}
</div>
</div>
{{/if}}
{{#if showAdvanced}}
{{wizard-advanced-toggle showAdvanced=action.showAdvanced}}
{{#if action.showAdvanced}}
<div class="advanced-settings">
{{#if hasCustomFields}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.action.custom_fields.label'}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.custom_fields
@ -310,13 +333,13 @@
</div>
</div>
{{/if}}
{{#if sendMessage}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.required'}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.required
@ -332,23 +355,23 @@
</div>
</div>
{{/if}}
{{#if showSkipRedirect}}
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.skip_redirect.label"}}</label>
</div>
<div class="setting-value">
{{input type='checkbox' checked=action.skip_redirect}}
<span>
{{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}}
</span>
</div>
</div>
{{/if}}
{{#if routeTo}}
<div class="setting">
<div class="setting-label">

Datei anzeigen

@ -208,6 +208,9 @@ en:
label: "Update Profile"
setting: "Fields"
key: "field"
watch_categories:
label: "Watch Categories"
mute_remainder: "Mute Remainder"
post_builder:
checkbox: "Post Builder"
label: "Builder"

Datei anzeigen

@ -122,6 +122,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
custom_fields: mapped_params,
required: mapped_params,
recipient: mapped_params,
mute_remainder: mapped_params,
profile_updates: mapped_params,
group: mapped_params,
url: mapped_params

Datei anzeigen

@ -133,6 +133,18 @@ class CustomWizard::Action
end
end
def watch_categories
key, watched_categories = data.first
mute_remainder = data.values[1]
Category.all.each do |category|
if watched_categories.include?(category.id.to_s)
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:watching], category.id)
elsif mute_remainder
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id)
end
end
end
def send_to_api
api_body = nil

Datei anzeigen

@ -3,6 +3,7 @@ class CustomWizard::Mapper
USER_FIELDS = ['name', 'username', 'email', 'date_of_birth', 'title', 'locale', 'trust_level']
PROFILE_FIELDS = ['location', 'website', 'bio_raw']
CATEGORY_NOTIFICATION_LEVELS = ['regular','watching', 'tracking', 'watching_first_post','muted']
def self.user_fields
USER_FIELDS + PROFILE_FIELDS
@ -115,10 +116,10 @@ class CustomWizard::Mapper
end
end
end
def validation_result(key, value, operator)
result = nil
if operator.is_a?(Hash) && (operator = operator[value.to_sym]).present?
if value == "present"
result = key.public_send(operator)