Ghost/ghost/admin/app/models/invite.js
Kevin Ansfield d7375aab1a Fixed missing invite role name on team screen
no issue
- removed the rename of `role_id` to `role` in the invite serialiser to let Ember Data do it's thing with the `invite.role` relationship
- added a guard to the team screen background reloading to ensure that role data is present in the store before loading invites so that Ember Data doesn't trigger unnecessary requests to find missing relationship data
2019-01-14 17:01:30 +00:00

37 lines
976 B
JavaScript

import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import {belongsTo} from 'ember-data/relationships';
import {inject as service} from '@ember/service';
export default Model.extend({
token: attr('string'),
email: attr('string'),
expires: attr('number'),
createdAtUTC: attr('moment-utc'),
createdBy: attr('number'),
updatedAtUTC: attr('moment-utc'),
updatedBy: attr('number'),
status: attr('string'),
role: belongsTo('role', {async: false}),
ajax: service(),
ghostPaths: service(),
resend() {
let fullInviteData = this.toJSON();
let inviteData = {
email: fullInviteData.email,
role_id: fullInviteData.role
};
let inviteUrl = this.get('ghostPaths.url').api('invites');
return this.get('ajax').post(inviteUrl, {
data: JSON.stringify({invites: [inviteData]}),
contentType: 'application/json'
});
}
});