mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
d7375aab1a
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
37 lines
976 B
JavaScript
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'
|
|
});
|
|
}
|
|
});
|