project/app/controllers/pages.js
Martin Donnelly e06e53e5bd whats wrong?
2016-04-06 16:53:06 +01:00

42 lines
1.0 KiB
JavaScript

import Ember from 'ember';
const { service , store } = Ember.inject;
export default Ember.Controller.extend({
session: service('session'),
sessionAccount: service('session-account'),
actions: {
savePage: function() {
var model = this.get('model');
model.save()
.catch(function(err) {
console.error(err);
});
},
createNew: function() {
'use strict';
const cid = this.get('sessionAccount.account.memberof');
var store = this.get('store');
var newPage = store.createRecord('page',{cid: cid,
vid: 'JPnbDnRzwDSNLTCcS4miFq', content: 0, imageUrl: 'http://lorempixel.com/300/300'});
this.set('content',newPage);
this.set('isEditing', true);
}, cancelEdit: function() {
var model = this.get('model');
model.rollbackAttributes();
model = this.store.findAll('page');
this.set('isEditing', false);
this.set('model', model);
}
}
});