Skip to content

Commit

Permalink
Merge pull request #6912 from RocketChat/remove-room-from-setting
Browse files Browse the repository at this point in the history
[FIX] Remove room from roomPick setting
  • Loading branch information
rodrigok authored May 17, 2017
2 parents 4f5b96e + 378d469 commit 03d9cfe
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/rocketchat-lib/server/methods/saveSetting.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint new-cap: 0 */

Meteor.methods({
saveSetting(_id, value, editor) {
if (Meteor.userId() === null) {
Expand All @@ -20,7 +22,7 @@ Meteor.methods({
//Verify the value is what it should be
switch (setting.type) {
case 'roomPick':
check(value, [Object]);
check(value, Match.OneOf([Object], ''));
break;
case 'boolean':
check(value, Boolean);
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui-admin/client/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ <h2>
{{> inputAutocomplete settings=autocompleteRoom id=_id name=_id class="search autocomplete" autocomplete="off" disabled=isDisabled.disabled}}
<ul class="selected-rooms">
{{#each selectedRooms}}
<li class="remove-room" data-setting={{_id}}>{{name}} <i class="icon-cancel secondary-font-color"></i></li>
<li class="remove-room" data-setting={{../_id}}>{{name}} <i class="icon-cancel secondary-font-color"></i></li>
{{/each}}
</ul>
</div>
Expand Down
11 changes: 8 additions & 3 deletions packages/rocketchat-ui-admin/client/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const setFieldValue = function(settingId, value, type, editor) {
new jscolor(input); //eslint-disable-line
}
break;
case 'roomPick':
const selectedRooms = Template.instance().selectedRooms.get();
selectedRooms[settingId] = value;
Template.instance().selectedRooms.set(selectedRooms);
TempSettings.update({ _id: settingId }, { $set: { value, changed: JSON.stringify(RocketChat.settings.collectionPrivate.findOne(settingId).value) !== JSON.stringify(value) } });
break;
default:
input.val(value).change();
}
Expand Down Expand Up @@ -533,7 +539,7 @@ Template.admin.events({
selectedRooms[this.id] = (selectedRooms[this.id] || []).concat(doc);
instance.selectedRooms.set(selectedRooms);
const value = selectedRooms[this.id];
TempSettings.update({ _id: this.id }, { $set: { value, changed: RocketChat.settings.collectionPrivate.findOne(this.id).value !== value }});
TempSettings.update({ _id: this.id }, { $set: { value }});
event.currentTarget.value = '';
event.currentTarget.focus();
},
Expand All @@ -548,8 +554,7 @@ Template.admin.events({
const value = selectedRooms[settingId];
TempSettings.update({ _id: settingId }, {
$set: {
value,
changed: RocketChat.settings.collectionPrivate.findOne(settingId).value !== value
value
}
});
}
Expand Down

0 comments on commit 03d9cfe

Please sign in to comment.