server/bo_client/app/routes/doc.js
author ymh <ymh.work@gmail.com>
Thu, 02 Jun 2016 18:24:19 +0200
changeset 168 17f10b56c079
parent 28 b0b56e0f8c7f
permissions -rw-r--r--
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning

import Ember from 'ember';

export default Ember.Route.extend({
  options: Ember.inject.service(),
  model(params) {
    return this.store.findRecord('document', params.doc_id);
  },
  actions: {
    saveDocument: function(doc) {
      doc.save();
      if(this.get('options').backurl) {
        window.location.replace(this.get('options').backurl);
      }
      else {
        this.transitionTo('index');
      }
    },
    cancelDocument: function(doc) {
      doc.rollbackAttributes();
      doc.reload();
    }
  }
});