Skip to content

Commit

Permalink
[FIX] Color reset when default value editor is different
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Oct 19, 2017
1 parent ae9a9f4 commit 539be00
Showing 1 changed file with 10 additions and 6 deletions.
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 539be00

Please sign in to comment.