server/bo_client/app/routes/doc.js
author ymh <ymh.work@gmail.com>
Fri, 17 Nov 2017 18:02:04 +0100
changeset 567 271e2afbf830
parent 28 b0b56e0f8c7f
permissions -rw-r--r--
Correct share button url
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
import Ember from 'ember';
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
export default Ember.Route.extend({
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
     4
  options: Ember.inject.service(),
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
  model(params) {
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
    return this.store.findRecord('document', params.doc_id);
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
  },
28
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
     8
  actions: {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
     9
    saveDocument: function(doc) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    10
      doc.save();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    11
      if(this.get('options').backurl) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    12
        window.location.replace(this.get('options').backurl);
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    13
      }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    14
      else {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    15
        this.transitionTo('index');
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    16
      }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    17
    },
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    18
    cancelDocument: function(doc) {
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    19
      doc.rollbackAttributes();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    20
      doc.reload();
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    21
    }
b0b56e0f8c7f Add contributor edition
ymh <ymh.work@gmail.com>
parents: 4
diff changeset
    22
  }
4
f55970e41793 first skeleton of bo client in ember
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
});