Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Remove room from roomPick setting #6912

Merged
merged 12 commits into from
May 17, 2017

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