1
0
Fork 0

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 }), visible: computed('currentActionId', function() { return this.action.id === this.currentActionId }),
createTopic: equal('action.type', 'create_topic'), createTopic: equal('action.type', 'create_topic'),
updateProfile: equal('action.type', 'update_profile'), updateProfile: equal('action.type', 'update_profile'),
watchCategories: equal('action.type', 'watch_categories'),
sendMessage: equal('action.type', 'send_message'), sendMessage: equal('action.type', 'send_message'),
openComposer: equal('action.type', 'open_composer'), openComposer: equal('action.type', 'open_composer'),
sendToApi: equal('action.type', 'send_to_api'), sendToApi: equal('action.type', 'send_to_api'),

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -133,6 +133,18 @@ class CustomWizard::Action
end end
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 def send_to_api
api_body = nil api_body = nil

Datei anzeigen

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