Skip to content

Commit

Permalink
Merge pull request #8543 from RocketChat/hotfix/color-reset
Browse files Browse the repository at this point in the history
[FIX] Color reset when default value editor is different
  • Loading branch information
rodrigok authored Oct 19, 2017
2 parents 93c57b6 + ef00dda commit 6df8254
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/publications/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
16 changes: 10 additions & 6 deletions packages/rocketchat-ui-admin/client/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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');
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 6df8254

Please sign in to comment.