diff --git a/packages/rocketchat-ui-admin/admin/admin.coffee b/packages/rocketchat-ui-admin/admin/admin.coffee index 16158a92224..4c907eac343 100644 --- a/packages/rocketchat-ui-admin/admin/admin.coffee +++ b/packages/rocketchat-ui-admin/admin/admin.coffee @@ -3,7 +3,7 @@ TempSettings = new Meteor.Collection null RocketChat.TempSettings = TempSettings getDefaultSetting = (settingId) -> - return RocketChat.settings.cachedCollectionPrivate.collection.findOne({_id: settingId}) + return RocketChat.settings.collectionPrivate.findOne({_id: settingId}) setFieldValue = (settingId, value, type, editor) -> input = $('.page-settings').find('[name="' + settingId + '"]') @@ -69,16 +69,16 @@ Template.admin.helpers return result; appLanguage: (key) -> - if !key - return !RocketChat.settings.get('Language') - selected = (RocketChat.settings.get('Language'))?.split('-').shift().toLowerCase() is key - return selected + return (RocketChat.settings.get('Language'))?.split('-').shift().toLowerCase() is key group: -> - return TempSettings.findOne { _id: FlowRouter.getParam('group'), type: 'group' } + groupId = FlowRouter.getParam('group') + group = RocketChat.settings.collectionPrivate.findOne { _id: groupId, type: 'group' } - sections: -> - settings = TempSettings.find({ group: FlowRouter.getParam('group') }, {sort: {section: 1, sorter: 1, i18nLabel: 1}}).fetch() + if not group + return + + settings = RocketChat.settings.collectionPrivate.find({ group: groupId }, {sort: {section: 1, sorter: 1, i18nLabel: 1}}).fetch() sections = {} for setting in settings @@ -93,19 +93,19 @@ Template.admin.helpers found = 0 for item in i18nDefaultQuery - if TempSettings.findOne(item)? + if RocketChat.settings.collectionPrivate.findOne(item)? setting.value = TAPi18n.__(setting._id + '_Default') sections[setting.section or ''] ?= [] sections[setting.section or ''].push setting - sectionsArray = [] + group.sections = [] for key, value of sections - sectionsArray.push + group.sections.push section: key settings: value - return sectionsArray + return group i18nDefaultValue: -> return TAPi18n.__(@_id + '_Default') @@ -154,6 +154,9 @@ Template.admin.helpers return TempSettings.find(query).count() > 0 + isSettingChanged: (id) -> + return RocketChat.TempSettings.findOne({_id: id}, {fields: {changed: 1}}).changed + translateSection: (section) -> if section.indexOf(':') > -1 return section @@ -259,7 +262,7 @@ Template.admin.helpers return setting.value is setting.packageValue Template.admin.events - "change .input-monitor, keyup .input-monitor": (e, t) -> + "change .input-monitor, keyup .input-monitor": _.throttle((e, t) -> value = _.trim $(e.target).val() switch @type @@ -272,6 +275,7 @@ Template.admin.events $set: value: value changed: RocketChat.settings.collectionPrivate.findOne(@_id).value isnt value + , 500) "change select[name=color-editor]": (e, t) -> value = _.trim $(e.target).val() @@ -287,10 +291,9 @@ Template.admin.events changed: true settings = TempSettings.find(query, {fields: {_id: 1, value: 1, packageValue: 1}}).fetch() - console.log(settings) settings.forEach (setting) -> - oldSetting = RocketChat.settings.cachedCollectionPrivate.collection.findOne({_id: setting._id}, {fields: {value: 1, type:1, editor: 1}}) + oldSetting = RocketChat.settings.collectionPrivate.findOne({_id: setting._id}, {fields: {value: 1, type:1, editor: 1}}) setFieldValue(setting._id, oldSetting.value, oldSetting.type, oldSetting.editor) diff --git a/packages/rocketchat-ui-admin/admin/admin.html b/packages/rocketchat-ui-admin/admin/admin.html index d2e8e05d655..d0e8e452e0d 100644 --- a/packages/rocketchat-ui-admin/admin/admin.html +++ b/packages/rocketchat-ui-admin/admin/admin.html @@ -1,241 +1,241 @@