Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-26 02:50:28 +01:00
Added notification level dropdown to allow admin to specify which level of tracking will be chosen during action
Dieser Commit ist enthalten in:
Ursprung
355d1abc54
Commit
c4471fa15f
7 geänderte Dateien mit 50 neuen und 3 gelöschten Zeilen
|
@ -5,6 +5,7 @@ import { computed } from "@ember/object";
|
||||||
import wizardSchema from '../lib/wizard-schema';
|
import wizardSchema from '../lib/wizard-schema';
|
||||||
import UndoChanges from '../mixins/undo-changes';
|
import UndoChanges from '../mixins/undo-changes';
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { notificationLevels } from '../lib/wizard';
|
||||||
|
|
||||||
export default Component.extend(UndoChanges, {
|
export default Component.extend(UndoChanges, {
|
||||||
componentType: 'action',
|
componentType: 'action',
|
||||||
|
@ -32,6 +33,12 @@ export default Component.extend(UndoChanges, {
|
||||||
name: I18n.t(`admin.wizard.action.${type}.label`)
|
name: I18n.t(`admin.wizard.action.${type}.label`)
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
availableNotificationLevels: notificationLevels.map((type, index) => {
|
||||||
|
return {
|
||||||
|
id: type,
|
||||||
|
name: I18n.t(`admin.wizard.action.watch_categories.notification_level.${type}`)
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
messageUrl: 'https://thepavilion.io/t/2810',
|
messageUrl: 'https://thepavilion.io/t/2810',
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,7 @@ const action = {
|
||||||
},
|
},
|
||||||
watch_categories: {
|
watch_categories: {
|
||||||
categories: null,
|
categories: null,
|
||||||
|
notification_level: null,
|
||||||
mute_remainder: null
|
mute_remainder: null
|
||||||
},
|
},
|
||||||
add_to_group: {
|
add_to_group: {
|
||||||
|
@ -164,6 +165,7 @@ const action = {
|
||||||
'group',
|
'group',
|
||||||
'url',
|
'url',
|
||||||
'categories',
|
'categories',
|
||||||
|
// 'notification_level',
|
||||||
'mute_remainder'
|
'mute_remainder'
|
||||||
],
|
],
|
||||||
advanced: [
|
advanced: [
|
||||||
|
@ -186,7 +188,8 @@ const wizardSchema = {
|
||||||
wizard,
|
wizard,
|
||||||
step,
|
step,
|
||||||
field,
|
field,
|
||||||
action
|
action,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildFieldTypes(types) {
|
export function buildFieldTypes(types) {
|
||||||
|
|
|
@ -49,6 +49,14 @@ const userProperties = [
|
||||||
'trust_level'
|
'trust_level'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const notificationLevels = [
|
||||||
|
'regular',
|
||||||
|
'watching',
|
||||||
|
'tracking',
|
||||||
|
'watching_first_post',
|
||||||
|
'muted'
|
||||||
|
];
|
||||||
|
|
||||||
function listProperties(type, opts={}) {
|
function listProperties(type, opts={}) {
|
||||||
let properties = Object.keys(wizardSchema[type].basic);
|
let properties = Object.keys(wizardSchema[type].basic);
|
||||||
|
|
||||||
|
@ -106,5 +114,6 @@ export {
|
||||||
snakeCase,
|
snakeCase,
|
||||||
userProperties,
|
userProperties,
|
||||||
listProperties,
|
listProperties,
|
||||||
|
notificationLevels,
|
||||||
wizardFieldList
|
wizardFieldList
|
||||||
};
|
};
|
|
@ -303,6 +303,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.watch_categories.notification_level.label"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{combo-box
|
||||||
|
value=action.notification_level
|
||||||
|
content=availableNotificationLevels
|
||||||
|
onChange=(action (mut action.notification_level))
|
||||||
|
options=(hash
|
||||||
|
isDisabled=action.custom_title_enabled
|
||||||
|
none='admin.wizard.action.watch_categories.select_a_notification_level'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="setting">
|
<div class="setting">
|
||||||
<div class="setting-label">
|
<div class="setting-label">
|
||||||
<label>{{i18n "admin.wizard.action.watch_categories.mute_remainder"}}</label>
|
<label>{{i18n "admin.wizard.action.watch_categories.mute_remainder"}}</label>
|
||||||
|
|
|
@ -210,8 +210,16 @@ en:
|
||||||
key: "field"
|
key: "field"
|
||||||
watch_categories:
|
watch_categories:
|
||||||
label: "Watch Categories"
|
label: "Watch Categories"
|
||||||
mute_remainder: "Mute Remainder"
|
|
||||||
categories: "Categories"
|
categories: "Categories"
|
||||||
|
mute_remainder: "Mute Remainder"
|
||||||
|
notification_level:
|
||||||
|
label: "Notification Level"
|
||||||
|
regular: "Normal"
|
||||||
|
watching: "Watching"
|
||||||
|
tracking: "Tracking"
|
||||||
|
watching_first_post: "Watching First Post"
|
||||||
|
muted: "Muted"
|
||||||
|
select_a_notification_level: "Select level"
|
||||||
post_builder:
|
post_builder:
|
||||||
checkbox: "Post Builder"
|
checkbox: "Post Builder"
|
||||||
label: "Builder"
|
label: "Builder"
|
||||||
|
|
|
@ -116,6 +116,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
||||||
:post,
|
:post,
|
||||||
:post_builder,
|
:post_builder,
|
||||||
:post_template,
|
:post_template,
|
||||||
|
:notification_level,
|
||||||
title: mapped_params,
|
title: mapped_params,
|
||||||
category: mapped_params,
|
category: mapped_params,
|
||||||
tags: mapped_params,
|
tags: mapped_params,
|
||||||
|
|
|
@ -141,6 +141,8 @@ class CustomWizard::Action
|
||||||
user: user
|
user: user
|
||||||
).perform
|
).perform
|
||||||
|
|
||||||
|
notification_level = action['notification_level']
|
||||||
|
|
||||||
mute_remainder = CustomWizard::Mapper.new(
|
mute_remainder = CustomWizard::Mapper.new(
|
||||||
inputs: action['mute_remainder'],
|
inputs: action['mute_remainder'],
|
||||||
data: data,
|
data: data,
|
||||||
|
@ -149,7 +151,7 @@ class CustomWizard::Action
|
||||||
|
|
||||||
Category.all.each do |category|
|
Category.all.each do |category|
|
||||||
if watched_categories.include?(category.id.to_s)
|
if watched_categories.include?(category.id.to_s)
|
||||||
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:watching], category.id)
|
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[notification_level.to_sym], category.id)
|
||||||
elsif mute_remainder
|
elsif mute_remainder
|
||||||
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id)
|
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id)
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren