mirror of
https://gitlab.silvrtree.co.uk/martind2000/censis-obrand.git
synced 2025-02-12 01:19:16 +00:00
39 lines
887 B
JavaScript
39 lines
887 B
JavaScript
|
import Ember from 'ember';
|
||
|
|
||
|
const { inject: { service }, RSVP } = Ember;
|
||
|
|
||
|
export default Ember.Route.extend({
|
||
|
sessionAccount: service('session-account'),
|
||
|
beforeModel() {
|
||
|
const cid = this.get('sessionAccount.account.memberof');
|
||
|
console.log(this.get('sessionAccount.account'));
|
||
|
console.log('cid:' + cid);
|
||
|
if (typeof cid === 'undefined' || cid === null) {
|
||
|
console.log('Going to new company');
|
||
|
this.transitionTo('newcompany');
|
||
|
}
|
||
|
},
|
||
|
|
||
|
model: function(params) {
|
||
|
'use strict';
|
||
|
const cid = this.get('sessionAccount.account.memberof');
|
||
|
|
||
|
console.log(cid);
|
||
|
|
||
|
if (typeof cid !== 'undefined' && cid !== null) {
|
||
|
return new RSVP.Promise((resolve, reject) => {
|
||
|
return this.get('store').find('company', cid)
|
||
|
.then(resolve, reject);
|
||
|
});
|
||
|
|
||
|
} else {
|
||
|
|
||
|
return {
|
||
|
needNewCompany: true
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
});
|