diff --git a/client/components/settings/settingBody.jade b/client/components/settings/settingBody.jade index 84d7a1b18..f8cfc3a59 100644 --- a/client/components/settings/settingBody.jade +++ b/client/components/settings/settingBody.jade @@ -122,6 +122,8 @@ template(name='email') template(name='accountSettings') ul#account-setting.setting-detail + li + button.js-all-hide-system-messages.primary {{_ 'hide-system-messages-of-all-users'}} li.accounts-form .title {{_ 'accounts-allowEmailChange'}} .form-group.flex @@ -129,23 +131,18 @@ template(name='accountSettings') span {{_ 'yes'}} input.wekan-form-control#accounts-allowEmailChange(type="radio" name="allowEmailChange" value="false" checked="{{#unless allowEmailChange}}checked{{/unless}}") span {{_ 'no'}} - li - li.accounts-form .title {{_ 'accounts-allowUserNameChange'}} .form-group.flex input.wekan-form-control#accounts-allowUserNameChange(type="radio" name="allowUserNameChange" value="true" checked="{{#if allowUserNameChange}}checked{{/if}}") span {{_ 'yes'}} input.wekan-form-control#accounts-allowUserNameChange(type="radio" name="allowUserNameChange" value="false" checked="{{#unless allowUserNameChange}}checked{{/unless}}") span {{_ 'no'}} - li - li.accounts-form .title {{_ 'accounts-allowUserDelete'}} .form-group.flex input.wekan-form-control#accounts-allowUserDelete(type="radio" name="allowUserDelete" value="true" checked="{{#if allowUserDelete}}checked{{/if}}") span {{_ 'yes'}} input.wekan-form-control#accounts-allowUserDelete(type="radio" name="allowUserDelete" value="false" checked="{{#unless allowUserDelete}}checked{{/unless}}") span {{_ 'no'}} - li button.js-accounts-save.primary {{_ 'save'}} template(name='announcementSettings') diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js index 68126589e..596b40613 100644 --- a/client/components/settings/settingBody.js +++ b/client/components/settings/settingBody.js @@ -274,7 +274,6 @@ BlazeComponent.extendComponent({ $set: { booleanValue: allowUserDelete }, }); }, - allowEmailChange() { return AccountSettings.findOne('accounts-allowEmailChange').booleanValue; }, @@ -284,12 +283,31 @@ BlazeComponent.extendComponent({ allowUserDelete() { return AccountSettings.findOne('accounts-allowUserDelete').booleanValue; }, + allHideSystemMessages() { + Meteor.call('setAllUsersHideSystemMessages', (err, ret) => { + if (!err && ret) { + if (ret === true) { + const message = `${TAPi18n.__( + 'now-system-messages-of-all-users-are-hidden', + )}`; + alert(message); + } + } else { + const reason = err.reason || ''; + const message = `${TAPi18n.__(err.error)}\n${reason}`; + alert(message); + } + }); + }, events() { return [ { 'click button.js-accounts-save': this.saveAccountsChange, }, + { + 'click button.js-all-hide-system-messages': this.allHideSystemMessages, + }, ]; }, }).register('accountSettings'); diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 9694250aa..a76e27324 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -982,5 +982,7 @@ "title-alphabetically": "Title (Alphabetically)", "created-at-newest-first": "Created At (Newest First)", "created-at-oldest-first": "Created At (Oldest First)", - "links-heading": "Links" + "links-heading": "Links", + "hide-system-messages-of-all-users": "Hide system messages of all users", + "now-system-messages-of-all-users-are-hidden": "Now system messages of all users are hidden" } diff --git a/models/users.js b/models/users.js index c88572af0..13e623318 100644 --- a/models/users.js +++ b/models/users.js @@ -797,6 +797,25 @@ Meteor.methods({ if (Meteor.isServer) { Meteor.methods({ + setAllUsersHideSystemMessages() { + if (Meteor.user() && Meteor.user().isAdmin) { + // If setting is missing, add it + Users.update( + { 'profile.hiddenSystemMessages': { $exists: false } }, + { $set: { 'profile.hiddenSystemMessages': true } }, + { multi: true }, + ); + // If setting is false, set it to true + Users.update( + { 'profile.hiddenSystemMessages': false }, + { $set: { 'profile.hiddenSystemMessages': true } }, + { multi: true }, + ); + return true; + } else { + return false; + } + }, setCreateUser( fullname, username,