mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
fix broken session after move to ember data objects
This commit is contained in:
parent
19f77855fd
commit
9483c44561
11 changed files with 50 additions and 46 deletions
|
@ -12,17 +12,22 @@
|
|||
import Ember from 'ember';
|
||||
import netUtil from '../../utils/net';
|
||||
|
||||
const {
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend({
|
||||
folderService: Ember.inject.service('folder'),
|
||||
folder: null,
|
||||
appMeta: Ember.inject.service(),
|
||||
session: service(),
|
||||
|
||||
didInitAttrs() {
|
||||
if (this.get("session.authenticated")) {
|
||||
this.get("session.user.accounts").forEach((account) => {
|
||||
// TODO: do not mutate account.active here
|
||||
account.active = account.orgId === this.get("appMeta.orgId");
|
||||
});
|
||||
// this.get("session.session.content.authenticated.user.accounts").forEach((account) => {
|
||||
// // TODO: do not mutate account.active here
|
||||
// account.active = account.orgId === this.get("appMeta.orgId");
|
||||
// });
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -30,5 +30,7 @@ export default Model.extend({
|
|||
selected: attr('boolean', { defaultValue: false }),
|
||||
slug: Ember.computed('name', function () {
|
||||
return stringUtil.makeSlug(this.get('name'));
|
||||
})
|
||||
}),
|
||||
created: attr(),
|
||||
revised: attr()
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
import models from '../../../utils/model';
|
||||
import NotifierMixin from '../../../mixins/notifier';
|
||||
|
||||
export default Ember.Controller.extend(NotifierMixin, {
|
||||
|
@ -11,11 +10,6 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
},
|
||||
|
||||
onAddSection(section) {
|
||||
let self = this;
|
||||
debugger;
|
||||
|
||||
console.log(section.get('contentType'));
|
||||
|
||||
this.audit.record("added-section");
|
||||
this.audit.record("added-section-" + section.get('contentType'));
|
||||
|
||||
|
@ -29,7 +23,7 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
};
|
||||
|
||||
let data = this.get('store').normalize('page', page);
|
||||
let pageData = this.get('store').push({ data: data });
|
||||
let pageData = this.get('store').push(data);
|
||||
|
||||
let meta = {
|
||||
documentId: this.get('model.document.id'),
|
||||
|
@ -37,8 +31,8 @@ export default Ember.Controller.extend(NotifierMixin, {
|
|||
config: ""
|
||||
};
|
||||
|
||||
let metaData = this.get('store').normalize('page-meta', meta);
|
||||
let pageMetaData = this.get('store').push({ data: metaData });
|
||||
let pageMeta = this.get('store').normalize('page-meta', meta);
|
||||
let pageMetaData = this.get('store').push(pageMeta);
|
||||
|
||||
let model = {
|
||||
page: pageData,
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
// https://documize.com
|
||||
|
||||
import Ember from 'ember';
|
||||
import models from '../../../utils/model';
|
||||
import NotifierMixin from '../../../mixins/notifier';
|
||||
|
||||
const {
|
||||
|
@ -34,7 +33,6 @@ export default Ember.Route.extend(NotifierMixin, {
|
|||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
var self = this;
|
||||
this.folder = model;
|
||||
controller.set('model', model);
|
||||
|
||||
|
@ -96,7 +94,7 @@ export default Ember.Route.extend(NotifierMixin, {
|
|||
|
||||
folderPermissions.map((permission) => {
|
||||
let data = this.get('store').normalize('folder-permission', permission);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
controller.set('permissions', folderPermissions.sortBy('fullname'));
|
||||
|
|
|
@ -26,7 +26,7 @@ export default Ember.Service.extend({
|
|||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = this.get('store').normalize('document', response);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default Ember.Service.extend({
|
|||
|
||||
documents = response.map((doc) => {
|
||||
let data = this.get('store').normalize('document', doc);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return documents;
|
||||
|
@ -63,7 +63,7 @@ export default Ember.Service.extend({
|
|||
|
||||
documents = response.map((doc) => {
|
||||
let data = this.get('store').normalize('document', doc);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return documents;
|
||||
|
@ -203,7 +203,7 @@ export default Ember.Service.extend({
|
|||
let data = [];
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('page', obj);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
|
@ -220,7 +220,7 @@ export default Ember.Service.extend({
|
|||
|
||||
pages = response.map((page) => {
|
||||
let data = this.get('store').normalize('page', page);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return pages;
|
||||
|
@ -234,7 +234,7 @@ export default Ember.Service.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = this.get('store').normalize('page', response);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -245,7 +245,7 @@ export default Ember.Service.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = this.get('store').normalize('page-meta', response);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -263,7 +263,7 @@ export default Ember.Service.extend({
|
|||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('attachment', obj);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
|
|
|
@ -35,7 +35,7 @@ export default BaseService.extend({
|
|||
data: JSON.stringify(folder)
|
||||
}).then((folder) => {
|
||||
let data = this.get('store').normalize('folder', folder);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -45,7 +45,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((folder) => {
|
||||
let data = this.get('store').normalize('folder', folder);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -115,7 +115,7 @@ export default BaseService.extend({
|
|||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('folder', obj);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
|
@ -132,7 +132,7 @@ export default BaseService.extend({
|
|||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('folder-permission', obj);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
|
|
|
@ -27,7 +27,7 @@ export default Ember.Service.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = this.get('store').normalize('organization', response);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export default BaseService.extend({
|
|||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('section', obj);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
|
@ -62,7 +62,7 @@ export default BaseService.extend({
|
|||
if (is.not.null(response) && is.array(response) && response.length > 0) {
|
||||
pages = response.map((page) => {
|
||||
let data = this.get('store').normalize('page', page);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,10 @@
|
|||
// https://documize.com
|
||||
|
||||
import Ember from 'ember';
|
||||
import models from '../utils/model';
|
||||
import SimpleAuthSession from 'ember-simple-auth/services/session';
|
||||
|
||||
const {
|
||||
inject: { service },
|
||||
computed: { oneWay, or, notEmpty },
|
||||
computed
|
||||
} = Ember;
|
||||
|
||||
|
@ -26,9 +24,17 @@ export default SimpleAuthSession.extend({
|
|||
|
||||
isMac: false,
|
||||
isMobile: false,
|
||||
authenticated: notEmpty('user.id'),
|
||||
isAdmin: oneWay('user.admin'),
|
||||
isEditor: or('user.admin', 'user.editor'),
|
||||
authenticated: computed('user.id', function () {
|
||||
return this.get('user.id') !== '0';
|
||||
}),
|
||||
isAdmin: computed('user', function () {
|
||||
let data = this.get('user');
|
||||
return data.get('admin');
|
||||
}),
|
||||
isEditor: computed('user', function () {
|
||||
let data = this.get('user');
|
||||
return data.get('editor');
|
||||
}),
|
||||
|
||||
init: function () {
|
||||
this.set('isMac', is.mac());
|
||||
|
@ -38,9 +44,8 @@ export default SimpleAuthSession.extend({
|
|||
user: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
||||
if (this.get('isAuthenticated')) {
|
||||
let user = this.get('session.content.authenticated.user') || { id: '' };
|
||||
// let data = this.get('store').normalize('user', user);
|
||||
// return this.get('store').push({ data: data });
|
||||
return models.UserModel.create(user);
|
||||
let data = this.get('store').normalize('user', user);
|
||||
return this.get('store').push(data);
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ export default Ember.Service.extend({
|
|||
|
||||
return this.get('ajax').post(url).then((doc) => {
|
||||
let data = this.get('store').normalize('document', doc);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -50,7 +50,7 @@ export default Ember.Service.extend({
|
|||
|
||||
templates = response.map((template) => {
|
||||
let data = this.get('store').normalize('template', template);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return templates;
|
||||
|
|
|
@ -30,7 +30,7 @@ export default Ember.Service.extend({
|
|||
contentType: 'json'
|
||||
}).then((response) => {
|
||||
let data = this.get('store').normalize('user', response);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -42,7 +42,7 @@ export default Ember.Service.extend({
|
|||
type: 'GET'
|
||||
}).then((response) => {
|
||||
let data = this.get('store').normalize('user', response);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -51,7 +51,7 @@ export default Ember.Service.extend({
|
|||
return this.get('ajax').request(`users`).then((response) => {
|
||||
return response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -67,7 +67,7 @@ export default Ember.Service.extend({
|
|||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
return this.get('store').push({ data: data });
|
||||
return this.get('store').push(data);
|
||||
});
|
||||
|
||||
return data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue