Skip to content

Commit

Permalink
MT bulk op to change to group not working
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Jul 21, 2018
1 parent d901721 commit dfe7ad2
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 2 deletions.
94 changes: 92 additions & 2 deletions http/js/iznik/views/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,18 @@ define([
break;
}

case 'ToGroup': {
self.collection.add(new Iznik.Models.Plugin.Work({
id: bulkop.id,
subview: new Iznik.Views.Plugin.Yahoo.ToGroup({
model: mod,
bulkop: bulkop
}),
bulk: true
}));
break;
}

default: {
console.log("Ignore bulkop");
}
Expand Down Expand Up @@ -1680,14 +1692,92 @@ define([
this.startBusy();

if (self.options.bulkop.criterion != 'WebOnly') {
console.error("To Special Notices bulk op only supports WebOnly filter");
console.error("To Special Notices bulk op only supports WebOnly filter", self.options.bulkop.criterion);
self.options.bulkop.criterion = 'WebOnly';
}

this.getChunk();
}
});


Iznik.Views.Plugin.Yahoo.ToGroup = Iznik.Views.Plugin.SubView.extend({
// Setting offset to 0 omits start from first one
offset: 0,
context: null,
members: [],

crumbLocation: "/members/all",

template: 'plugin_togroup',

changeOne: function() {
var self = this;

if (self.offset < self.members.length) {
var percent = Math.round((self.offset / self.members.length) * 100);
self.$('.progress-bar:last').css('width', percent + '%').attr('aria-valuenow', percent);

var member = self.members[self.offset++];
console.log(member);
var group = Iznik.Session.getGroup(self.options.bulkop.groupid);
var mod = new Iznik.Models.Yahoo.User({
group: group.get('nameshort'),
email: member.email,
userId: member.yahooUserId
});
self.listenToOnce(mod, 'completed', function() {
self.changeOne();
});
mod.changeAttr('postingStatus', 'DEFAULT');
} else {
// Finished
console.log("Finished");
self.succeed();
}
},

getChunk: function() {
var self = this;
$.ajax({
type: 'GET',
url: API + 'memberships/' + self.options.bulkop.groupid,
context: self,
data: {
limit: 1000,
context: self.context ? self.context : null,
yahooDeliveryType: 'NONE'
},
success: function(ret) {
var self = this;
self.context = ret.context;
self.$('.js-count').html(ret.members.length);

if (ret.members.length > 0) {
// We returned some - add them to the list.
_.each(ret.members, function(member) {
if (member.hasOwnProperty('email') && member.email.toLowerCase().indexOf('fbuser') == -1) {
// FBUser members are members on Yahoo which are allowed to be on Web Only.
self.members.push(member);
}
});
self.getChunk.call(self);
} else {
// We got them all.
self.$('.js-download').hide();
self.$('.js-progress').show();
self.changeOne();
}
}
})
},

start: function() {
var self = this;
this.startBusy();
this.getChunk();
}
});

Iznik.Views.Plugin.Yahoo.ApprovePendingMessage = Iznik.Views.Plugin.SubView.extend({
template: 'plugin_pending_approve',
crumbLocation: "/management/pendingmessages",
Expand Down
15 changes: 15 additions & 0 deletions http/template/plugin/togroup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="panel panel-default">
<div class="panel-body forcebreak">
<h4>
<div class="glyphicon glyphicon-time" ></div>
Change to Group Settings
</h4>
<p>Group: {{nameshort}}</p>
<div class="js-download">
Finding possible members to change (<span class="js-count">0</span>)...
</div>
<div class="progress js-progress" style="display: none">
<div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;" />
</div>
</div>
</div>

0 comments on commit dfe7ad2

Please sign in to comment.