Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit db7e90e

Browse files
committed
Add add mod with guid
- added a field to add a mod manually, mostly for testing.
1 parent 0303040 commit db7e90e

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

js/languages/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@
231231
"SearchForCategory": "Search for category",
232232
"Moderators": "Moderators",
233233
"CurrentModerators": "Current Moderators",
234-
"AddModerators": "Add New Moderators",
234+
"AddModerators": "Add Moderators",
235+
"ManualAddModerator": "Add Moderators by GUID",
236+
"ManualAddModeratorHelp": "Enter the GUIDs of one or more moderators, separated by commas, here. The GUID is on the right side of their About tab on their page. Adding the GUID of a user that is not a moderator will have no effect, that GUID will be ignored.",
235237
"DeselectToRemoveModerator": "Deselect the moderators you want to remove",
236238
"SelectToAddModerator": "Select the moderators you want to add",
237239
"Categories": "Categories",

js/templates/settings.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,26 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Basic') %></h3>
756756
</div>
757757
</div>
758758

759+
<div class="flexRow">
760+
<div class="flexCol-3 borderRight custCol-border zIndex1"><!-- add z-index so help box overlaps next column-->
761+
<div class="fieldItem">
762+
<label for="addManualMods" class="tooltip tooltip-box" data-tooltip="<%= polyglot.t('ManualAddModeratorHelp') %>">
763+
<%= polyglot.t('ManualAddModerator') %> <i class="ion-help-circled"></i>
764+
</label>
765+
766+
</div>
767+
</div>
768+
769+
<div class="flexCol-9 borderRight0 custCol-border">
770+
<div class="fieldItem padding0">
771+
<input name="manualMods"
772+
type="text"
773+
id="addManualMods"
774+
class="fieldItem">
775+
</div>
776+
</div>
777+
</div>
778+
759779
<div class="flexRow TODO">
760780
<div class="flexCol-3 borderRight custCol-border">
761781
<div class="fieldItem">
@@ -768,6 +788,7 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Basic') %></h3>
768788
<div class="flexCol-9 borderRight0 custCol-border">
769789
<div class="fieldItem padding0">
770790
<!--TODO: keywords input here -->
791+
<input id="store-keywords">
771792
</div>
772793
</div>
773794
</div>

js/views/settingsVw.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,24 +811,36 @@ module.exports = Backbone.View.extend({
811811
form = this.$el.find("#storeForm"),
812812
settingsData = {},
813813
moderatorsNew = this.$el.find('#storeForm .js-settingsNewMods .js-userShortView input:checked'),
814-
moderatorList = this.userModel.get('moderators').map(function(moderatorObject){
815-
return moderatorObject.guid;
816-
}),
814+
moderatorList = this.userModel.get('moderator_guids'),
815+
manualModList,
817816
moderatorsUnChecked = this.$('#storeForm .js-settingsCurrentMods .js-userShortView input:not(:checked)'),
818817
onFail,
819818
$saveBtn = this.$('.js-saveStore');
820819

821820
$saveBtn.addClass('loading');
822821

822+
console.log(moderatorList)
823+
823824
//first, remove any existing moderators that have been unchecked. This prevents removing saved moderators that don't show up in the UI for some reason
824825
moderatorsUnChecked.each(function() {
825826
moderatorList = __.without(moderatorList, ($(this).data('guid')));
826827
});
827828

829+
console.log(moderatorList)
830+
828831
//add any new moderators that have been checked
829832
moderatorsNew.each(function() {
830833
moderatorList.push($(this).data('guid'));
831834
});
835+
836+
//add any manually entered mods
837+
manualModList = this.$('#addManualMods').val().split(',');
838+
console.log(manualModList);
839+
__.each(manualModList, function(mod){
840+
if(mod.length === 40){
841+
moderatorList.push(mod);
842+
}
843+
});
832844

833845
settingsData.moderators = moderatorList.length > 0 ? moderatorList : "";
834846

@@ -838,6 +850,8 @@ module.exports = Backbone.View.extend({
838850
messageModal.show(window.polyglot.t('errorMessages.saveError'), data.reason);
839851
};
840852

853+
return;
854+
841855
saveToAPI(form, "", self.serverUrl + "profile", function() {
842856
saveToAPI(form, self.userModel.toJSON(), self.serverUrl + "settings",
843857
function () {

0 commit comments

Comments
 (0)