Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
FEATURE: added ability for user to selected watched categories in wizard
Dieser Commit ist enthalten in:
Ursprung
b196acf151
Commit
f4a9cf86f2
7 geänderte Dateien mit 68 neuen und 22 gelöschten Zeilen
|
@ -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'),
|
||||||
|
|
|
@ -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: [
|
||||||
|
|
|
@ -283,6 +283,29 @@
|
||||||
</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}}
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Laden …
In neuem Issue referenzieren