|
|
@@ -343,23 +343,13 @@ module.exports = function(crowi, app) {
|
|
|
// break;
|
|
|
default:
|
|
|
logger.error('GlobalNotificationSetting Type Error: undefined type');
|
|
|
- req.flash('errorMessage', 'Error occurred in create a new global notification setting: undefined notification type');
|
|
|
- break;
|
|
|
+ req.flash('errorMessage', 'Error occurred in creating a new global notification setting: undefined notification type');
|
|
|
+ return res.redirect('/admin/notification#global-notification');
|
|
|
}
|
|
|
|
|
|
- let triggerEvents = [];
|
|
|
- const triggerEventKeys = Object.keys(form).filter(key => key.match(/^triggerEvent/));
|
|
|
- triggerEventKeys.forEach(key => {
|
|
|
- if (form[key]) {
|
|
|
- triggerEvents.push(form[key]);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if (setting) {
|
|
|
- setting.triggerPath = form.triggerPath;
|
|
|
- setting.triggerEvents = triggerEvents;
|
|
|
- setting.save();
|
|
|
- }
|
|
|
+ setting.triggerPath = form.triggerPath;
|
|
|
+ setting.triggerEvents = getNotificationEvents(form);
|
|
|
+ setting.save();
|
|
|
|
|
|
return res.redirect('/admin/notification#global-notification');
|
|
|
};
|
|
|
@@ -377,9 +367,18 @@ module.exports = function(crowi, app) {
|
|
|
// break;
|
|
|
default:
|
|
|
logger.error('GlobalNotificationSetting Type Error: undefined type');
|
|
|
- break;
|
|
|
+ req.flash('errorMessage', 'Error occurred in updating the global notification setting: undefined notification type');
|
|
|
+ return res.redirect('/admin/notification#global-notification');
|
|
|
}
|
|
|
|
|
|
+ setting.triggerPath = form.triggerPath;
|
|
|
+ setting.triggerEvents = getNotificationEvents(form);
|
|
|
+ setting.save();
|
|
|
+
|
|
|
+ return res.redirect('/admin/notification#global-notification');
|
|
|
+ };
|
|
|
+
|
|
|
+ const getNotificationEvents = (form) => {
|
|
|
let triggerEvents = [];
|
|
|
const triggerEventKeys = Object.keys(form).filter(key => key.match(/^triggerEvent/));
|
|
|
triggerEventKeys.forEach(key => {
|
|
|
@@ -387,14 +386,7 @@ module.exports = function(crowi, app) {
|
|
|
triggerEvents.push(form[key]);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- if (setting) {
|
|
|
- setting.triggerPath = form.triggerPath;
|
|
|
- setting.triggerEvents = triggerEvents;
|
|
|
- setting.save();
|
|
|
- }
|
|
|
-
|
|
|
- return res.redirect('/admin/notification#global-notification');
|
|
|
+ return triggerEvents;
|
|
|
};
|
|
|
|
|
|
actions.search.buildIndex = function(req, res) {
|