Skip to content

Commit

Permalink
mostly fix uiState on admin blockables page
Browse files Browse the repository at this point in the history
  • Loading branch information
thehesiod committed Oct 22, 2018
1 parent 5e44fea commit 3490ba3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ goog.require('upvote.admin.lib.controllers.ModelController');
goog.require('upvote.app.constants');
goog.require('upvote.errornotifier.ErrorService');
goog.require('upvote.shared.Page');
goog.require('upvote.statechip.ToUiState');

goog.scope(() => {
const ModelController = upvote.admin.lib.controllers.ModelController;
Expand Down Expand Up @@ -79,6 +80,31 @@ upvote.admin.blockablepage.BlockableController = class extends ModelController {
this.init();
}

/** @override */
loadData(opt_more) {
let dataPromise = super.loadData(opt_more);
let resource = this.resource;

return (!dataPromise) ? dataPromise : dataPromise.then((results) => {
if(!results) {
return null;
}

results.forEach(function(item) {
if (!!item['certId']) {
resource
.get({'id': item['certId']})['$promise']
.then((cert) => {
item.cert = cert;
})
.catch((response) => {
this.errorService_.createToastFromError(response);
});
}
});
});
}

/** @protected @override */
init() {
super.init();
Expand Down Expand Up @@ -110,6 +136,17 @@ upvote.admin.blockablepage.BlockableController = class extends ModelController {
let cardPromise = super.loadCard();
return (!cardPromise) ? cardPromise : cardPromise.then(() => {
this.card['rootScope'] = this.rootScope;

if (!!this.card['certId']) {
this.resource
.get({'id': this.card['certId']})['$promise']
.then((cert) => {
this.card.cert = cert;
})
.catch((response) => {
this.errorService_.createToastFromError(response);
});
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
Flagged: {{ card.flagged }}
</div>
<div>
State: {{ card.state | prettifyState }}
State: {{ card.state | toUiState: card.vote:card.cert | stateToDisplay }}
</div>
<div>
Last Changed State: {{ card.stateChangeDt }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<uv-listing-cell>{{ item.occurredDt | date:'mediumDate' }}</uv-listing-cell>
<uv-listing-cell>{{item.score}}</uv-listing-cell>
<uv-listing-cell ng-if="type != 'TRENDING_ALLOWED'">
<uv-state-chip state="item.state"></uv-state-chip>
<uv-state-chip state="item.state" vote="item.vote" cert="item.cert" is-pending="item.isPending"></uv-state-chip>
</uv-listing-cell>
<uv-listing-cell ng-if="type == 'TRENDING_ALLOWED'">{{item.count}}</uv-listing-cell>
<md-tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ goog.require('upvote.admin.blockables.prettifyType');
goog.require('upvote.admin.blockables.prettifyVotingProhibitedReason');
goog.require('upvote.admin.blockables.uvBlockableCard');
goog.require('upvote.admin.blockables.uvBlockableListing');
goog.require('upvote.statechip.StateToDisplay');
goog.require('upvote.statechip.ToUiState');
goog.require('upvote.statechip.module');


Expand All @@ -40,6 +42,8 @@ upvote.admin.blockables.module =
.directive(
'uvBlockableHeader', upvote.admin.blockables.uvBlockableHeader)
.filter('prettifyState', () => upvote.admin.blockables.prettifyState)
.filter('toUiState', () => upvote.statechip.ToUiState)
.filter('stateToDisplay', () => upvote.statechip.StateToDisplay)
.filter(
'prettifyVotingProhibitedReason',
() => upvote.admin.blockables.prettifyVotingProhibitedReason)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,25 @@ upvote.admin.lib.controllers.ModelController = class {
/**
* Load search query data.
* @param {boolean=} opt_more Whether to load more items from the last query.
* @return {?angular.$q.Promise} A promise that will resolve once the data is loaded.
* @protected
*/
loadData(opt_more) {
if (!opt_more) {
this.requestData['cursor'] = null;
}

let data = this.queryData['search'] ?
Object.assign({}, this.requestData, this.queryData) :
this.requestData;
this.queryResource['search'](data)['$promise'].then((results) => {

return this.queryResource['search'](data)['$promise'].then((results) => {
this.content = opt_more ? this.content.concat(results['content']) :
results['content'];
this.requestData['cursor'] = results['cursor'];
this.requestData['more'] = results['more'];
this.requestData['perPage'] = results['perPage'];
return results['content'];
});
}

Expand Down

0 comments on commit 3490ba3

Please sign in to comment.