Merge pull request #8543 from RocketChat/hotfix/color-reset

[FIX] Color reset when default value editor is different
pull/8641/head
Rodrigo Nascimento 8 years ago
parent c61036bbde
commit 1a29fd0797
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
  1. 2
      packages/rocketchat-lib/server/publications/settings.js
  2. 16
      packages/rocketchat-ui-admin/client/admin.js

@ -58,7 +58,7 @@ Meteor.methods({
RocketChat.models.Settings.cache.on('changed', function(type, setting) {
if (setting['public'] === true) {
RocketChat.Notifications.notifyAllInThisInstance('public-settings-changed', type, _.pick(setting, '_id', 'value', 'properties'));
RocketChat.Notifications.notifyAllInThisInstance('public-settings-changed', type, _.pick(setting, '_id', 'value', 'editor', 'properties'));
}
return RocketChat.Notifications.notifyLoggedInThisInstance('private-settings-changed', type, setting);
});

@ -20,11 +20,9 @@ const setFieldValue = function(settingId, value, type, editor) {
input.next()[0].CodeMirror.setValue(value);
break;
case 'color':
editor = value && value[0] === '#' ? 'color' : 'expression';
input.parents('.horizontal').find('select[name="color-editor"]').val(editor).change();
input.val(value).change();
if (editor === 'color') {
new jscolor(input); //eslint-disable-line
}
break;
case 'roomPick':
const selectedRooms = Template.instance().selectedRooms.get();
@ -341,6 +339,9 @@ Template.admin.events({
break;
case 'boolean':
value = value === '1';
break;
case 'color':
$(e.target).siblings('.colorpicker-swatch').css('background-color', value);
}
TempSettings.update({
_id: this._id
@ -354,6 +355,7 @@ Template.admin.events({
'change select[name=color-editor]'(e) {
const value = _.trim($(e.target).val());
TempSettings.update({ _id: this._id }, { $set: { editor: value }});
RocketChat.settings.collectionPrivate.update({ _id: this._id }, { $set: { editor: value }});
},
'click .submit .discard'() {
const group = FlowRouter.getParam('group');
@ -566,14 +568,16 @@ Template.admin.onRendered(function() {
SideNav.openFlex();
});
Tracker.autorun(function() {
const hasColor = TempSettings.findOne({
const hasColor = TempSettings.find({
group: FlowRouter.getParam('group'),
type: 'color'
}, { fields: { _id: 1 }});
}, { fields: { _id: 1, editor: 1 }}).fetch().length;
if (hasColor) {
Meteor.setTimeout(function() {
$('.colorpicker-input').each(function(index, el) {
new jscolor(el); //eslint-disable-line
if (!el._jscLinkedInstance) {
new jscolor(el); //eslint-disable-line
}
});
}, 400);
}

Loading…
Cancel
Save