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

Commit 5ef7ede

Browse files
committed
Merge pull request #1396 from OpenBazaar/moderatorFixes
fix moderators in settings
2 parents 79c23d4 + cd56a25 commit 5ef7ede

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

css/obBase.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5623,15 +5623,19 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
56235623
-webkit-filter: blur(20px) grayscale(1) contrast(0.5);
56245624
}
56255625

5626+
56265627
#ov1 .fadeOut {
56275628
opacity: 0;
56285629
pointer-events: none;
5630+
transition: opacity .3s cubic-bezier(0, 0, 0.2, 1);
56295631
}
56305632

56315633
#ov1 .foldIn {
56325634
height: 0;
5635+
padding: 0;
56335636
overflow: hidden;
5634-
transition: height 1s;
5637+
transition: height 1s, padding 1s;
5638+
pointer-events: none;
56355639
}
56365640

56375641
#ov1 .underline {
@@ -5801,8 +5805,11 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
58015805
border-bottom: 1px solid #444;
58025806
}
58035807

5808+
#ov1.notFancy .fadeOut,
58045809
#ov1.notFancy .statusBar.fadeOut,
58055810
#ov1.notFancy #pageNav .statusBar.fadeOut,
5811+
#ov1.notFancy #userPage .fadeOut,
5812+
#ov1.notFancy #userPage #pageNav .fadeOut,
58065813
#ov1.notFancy #userPage #pageNav .statusBar.fadeOut,
58075814
#ov1.notFancy #userPage #obContainer #content .statusBar.fadeOut {
58085815
opacity: 0 !important;

js/templates/settings.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,9 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Basic') %></h3>
728728

729729
<div class="flexCol-9 borderRight0 custCol-border">
730730
<div class="hideTopAndBottomBorder js-settingsCurrentMods">
731-
<!--TODO: moderators input here-->
731+
</div>
732+
<div class="padding10 width100 alignCenter fadeable js-loadingMsg">
733+
<i class="ion-android-sync spinner textSize24px textOpacity50"></i>
732734
</div>
733735
</div>
734736
</div>
@@ -748,6 +750,9 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Basic') %></h3>
748750
<div class="flexCol-9 borderRight0 custCol-border">
749751
<div class="hideTopAndBottomBorder js-settingsNewMods">
750752
</div>
753+
<div class="padding10 width100 alignCenter fadeable js-loadingMsg">
754+
<i class="ion-android-sync spinner textSize24px textOpacity50"></i>
755+
</div>
751756
</div>
752757
</div>
753758

js/views/settingsVw.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ module.exports = Backbone.View.extend({
7474
this.serverUrl = options.userModel.get('serverUrl');
7575
this.userModel = this.options.userModel;
7676
this.model = new Backbone.Model();
77-
this.subViews = [];
77+
this.subViews = []; //TODO: get rid of subviews, submodels, use proper remove method
7878
this.subModels = [];
7979
this.subModels.push(this.userProfile);
8080

81+
this.shownMods = []; //array of mods that have been shown, used to prevent duplicates
82+
8183
this.moderatorFeeInput;
8284
this.moderatorFeeHolder;
8385
this.oldFeeValue = options.userProfile.get('profile').moderation_fee || 0;
@@ -479,6 +481,13 @@ module.exports = Backbone.View.extend({
479481
existingMods = this.userModel.get('moderator_guids'),
480482
isExistingMod = existingMods.indexOf(moderator.guid) > -1;
481483

484+
//make sure this moderator is not a duplicate
485+
if(this.shownMods.indexOf(moderator.guid) > -1){
486+
return;
487+
} else {
488+
this.shownMods.push(moderator.guid);
489+
}
490+
482491
if(moderator.guid != this.model.get('page').profile.guid && this.userModel.get('blocked_guids').indexOf(moderator.guid) == -1){
483492
moderator.serverUrl = self.serverUrl;
484493
moderator.userID = moderator.guid;
@@ -547,6 +556,10 @@ module.exports = Backbone.View.extend({
547556
}
548557
});
549558
}
559+
//hide spinners after a while
560+
setTimeout(()=> {
561+
this.$('.js-loadingMsg').addClass('foldIn');
562+
},3000);
550563
this.firstLoadModerators = false;
551564
} else if (state === 'blocked') {
552565
// Since the Blocked Users View kicks off many server calls (one
@@ -796,18 +809,27 @@ module.exports = Backbone.View.extend({
796809
var self = this,
797810
form = this.$el.find("#storeForm"),
798811
settingsData = {},
799-
moderatorsChecked = this.$el.find('.js-userShortView input:checked'),
800-
modList = [],
812+
moderatorsNew = this.$el.find('#storeForm .js-settingsNewMods .js-userShortView input:checked'),
813+
moderatorList = this.userModel.get('moderators').map(function(moderatorObject){
814+
return moderatorObject.guid;
815+
}),
816+
moderatorsUnChecked = this.$('#storeForm .js-settingsCurrentMods .js-userShortView input:not(:checked)'),
801817
onFail,
802818
$saveBtn = this.$('.js-saveStore');
803819

804820
$saveBtn.addClass('loading');
805821

806-
moderatorsChecked.each(function() {
807-
modList.push($(this).data('guid'));
822+
//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
823+
moderatorsUnChecked.each(function() {
824+
moderatorList = __.without(moderatorList, ($(this).data('guid')));
825+
});
826+
827+
//add any new moderators that have been checked
828+
moderatorsNew.each(function() {
829+
moderatorList.push($(this).data('guid'));
808830
});
809831

810-
settingsData.moderators = modList.length > 0 ? modList : "";
832+
settingsData.moderators = moderatorList.length > 0 ? moderatorList : "";
811833

812834
onFail = (data) => {
813835
$saveBtn.removeClass('loading');

0 commit comments

Comments
 (0)