aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/routes/package/show/file.js
blob: ead6ee8fd82cf2db238356aec9cb6cf69fc6a660 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import Ember from 'ember';

export default Ember.Route.extend({
  store : Ember.inject.service(),
  model : function (params) {
    const packageInfo = this.modelFor('package');    
    if(packageInfo.modules[params.filePath]) {      
      return this.get('store').loadHaskellModule(packageInfo.id,params.filePath)
        .catch((e) => {console.log(e);this.transitionTo("/not-found");});      
    } else {
      return this.get('store').loadFile(packageInfo.id,params.filePath)
        .then((result) => {          
          document.title = packageInfo.id;
          return result;
        })
        .catch((e) => {console.log(e);this.transitionTo("/not-found");});
    }
  },
  afterModel (model) {    
    document.title = model.id + " - " + this.modelFor('package').id;
  },
  actions : {
    didTransition : function () {            
      this.send("fileOpened",this.currentModel.id);    
    }    
  }
});