2019-01-24 22:34:32 +03:00
|
|
|
import Controller from '@ember/controller';
|
2019-10-02 14:35:50 +03:00
|
|
|
import moment from 'moment';
|
2019-01-24 22:34:32 +03:00
|
|
|
import {alias} from '@ember/object/computed';
|
2019-04-16 18:02:43 +03:00
|
|
|
import {computed} from '@ember/object';
|
2019-02-22 14:31:45 +03:00
|
|
|
import {inject as controller} from '@ember/controller';
|
|
|
|
import {inject as service} from '@ember/service';
|
2019-04-16 18:02:43 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2019-01-24 22:34:32 +03:00
|
|
|
|
|
|
|
export default Controller.extend({
|
2019-02-22 14:31:45 +03:00
|
|
|
members: controller(),
|
2019-04-16 18:02:43 +03:00
|
|
|
store: service(),
|
|
|
|
|
2019-02-22 14:31:45 +03:00
|
|
|
router: service(),
|
|
|
|
|
|
|
|
member: alias('model'),
|
|
|
|
|
2019-10-02 14:35:50 +03:00
|
|
|
subscribedAt: computed('member.createdAt', function () {
|
2019-10-03 14:46:36 +03:00
|
|
|
let memberSince = moment(this.member.createdAt).from(moment());
|
2019-10-02 14:35:50 +03:00
|
|
|
let createdDate = moment(this.member.createdAt).format('MMM DD, YYYY');
|
2019-10-03 14:46:36 +03:00
|
|
|
return `${createdDate} (${memberSince})`;
|
2019-10-02 14:35:50 +03:00
|
|
|
}),
|
|
|
|
|
2019-02-22 14:31:45 +03:00
|
|
|
actions: {
|
2019-10-02 14:35:50 +03:00
|
|
|
setProperty() {
|
|
|
|
return;
|
2019-10-02 07:00:03 +03:00
|
|
|
},
|
|
|
|
toggleDeleteTagModal() {
|
|
|
|
this.toggleProperty('showDeleteMemberModal');
|
|
|
|
},
|
2019-02-22 14:31:45 +03:00
|
|
|
finaliseDeletion() {
|
|
|
|
// decrememnt the total member count manually so there's no flash
|
|
|
|
// when transitioning back to the members list
|
|
|
|
if (this.members.meta) {
|
|
|
|
this.members.decrementProperty('meta.pagination.total');
|
|
|
|
}
|
|
|
|
this.router.transitionTo('members');
|
|
|
|
}
|
2019-04-16 18:02:43 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
fetchMember: task(function* (memberId) {
|
2019-10-07 15:26:32 +03:00
|
|
|
this.set('isLoading', true);
|
2019-04-16 18:02:43 +03:00
|
|
|
yield this.store.findRecord('member', memberId, {
|
|
|
|
reload: true
|
|
|
|
}).then((data) => {
|
|
|
|
this.set('member', data);
|
2019-10-07 15:26:32 +03:00
|
|
|
this.set('isLoading', false);
|
2019-04-16 18:02:43 +03:00
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2019-01-24 22:34:32 +03:00
|
|
|
});
|