0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +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:
Robert Barrow 2020-05-25 14:59:31 +01:00
Ursprung 355d1abc54
Commit c4471fa15f
7 geänderte Dateien mit 50 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -5,6 +5,7 @@ import { computed } from "@ember/object";
import wizardSchema from '../lib/wizard-schema';
import UndoChanges from '../mixins/undo-changes';
import Component from "@ember/component";
import { notificationLevels } from '../lib/wizard';
export default Component.extend(UndoChanges, {
componentType: 'action',
@ -32,6 +33,12 @@ export default Component.extend(UndoChanges, {
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',

Datei anzeigen

@ -143,6 +143,7 @@ const action = {
},
watch_categories: {
categories: null,
notification_level: null,
mute_remainder: null
},
add_to_group: {
@ -164,6 +165,7 @@ const action = {
'group',
'url',
'categories',
// 'notification_level',
'mute_remainder'
],
advanced: [
@ -186,7 +188,8 @@ const wizardSchema = {
wizard,
step,
field,
action
action,
}
export function buildFieldTypes(types) {

Datei anzeigen

@ -49,6 +49,14 @@ const userProperties = [
'trust_level'
];
const notificationLevels = [
'regular',
'watching',
'tracking',
'watching_first_post',
'muted'
];
function listProperties(type, opts={}) {
let properties = Object.keys(wizardSchema[type].basic);
@ -106,5 +114,6 @@ export {
snakeCase,
userProperties,
listProperties,
notificationLevels,
wizardFieldList
};

Datei anzeigen

@ -303,6 +303,23 @@
</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-label">
<label>{{i18n "admin.wizard.action.watch_categories.mute_remainder"}}</label>

Datei anzeigen

@ -210,8 +210,16 @@ en:
key: "field"
watch_categories:
label: "Watch Categories"
mute_remainder: "Mute Remainder"
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:
checkbox: "Post Builder"
label: "Builder"

Datei anzeigen

@ -116,6 +116,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
:post,
:post_builder,
:post_template,
:notification_level,
title: mapped_params,
category: mapped_params,
tags: mapped_params,

Datei anzeigen

@ -141,6 +141,8 @@ class CustomWizard::Action
user: user
).perform
notification_level = action['notification_level']
mute_remainder = CustomWizard::Mapper.new(
inputs: action['mute_remainder'],
data: data,
@ -149,7 +151,7 @@ class CustomWizard::Action
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)
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[notification_level.to_sym], category.id)
elsif mute_remainder
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id)
end