mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
38a3962368
refs https://github.com/TryGhost/Team/issues/969 A lot of power of filtering members comes from ability to perform actions on the filtered member list. This change adds bulk operation actions on the the UI to apply on filtered members, but has not wired them up to the API yet. - adds unsubscribe bulk operation UI - adds label addition bulk operation UI - adds label removal bulk operation UI - adds new single label selection UI for add/remove label to members UI
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class GhMemberLabelInput extends Component {
|
|
@service store;
|
|
|
|
@tracked selectedLabel;
|
|
|
|
get availableLabels() {
|
|
return this._availableLabels.toArray().sort((labelA, labelB) => {
|
|
return labelA.name.localeCompare(labelB.name, undefined, {ignorePunctuation: true});
|
|
});
|
|
}
|
|
|
|
get availableLabelNames() {
|
|
return this.availableLabels.map(label => label.name.toLowerCase());
|
|
}
|
|
|
|
constructor(...args) {
|
|
super(...args);
|
|
// perform a background query to fetch all users and set `availableLabels`
|
|
// to a live-query that will be immediately populated with what's in the
|
|
// store and be updated when the above query returns
|
|
this.store.query('label', {limit: 'all'});
|
|
this._availableLabels = this.store.peekAll('label');
|
|
this.selectedLabel = this.args.label || null;
|
|
}
|
|
|
|
@action
|
|
updateLabel(newLabel) {
|
|
// update labels
|
|
this.selectedLabel = newLabel;
|
|
this.args.onChange(newLabel);
|
|
}
|
|
}
|