aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/controllers/package.js
blob: 666cacfafec9b756145363761f2785ec61c24149 (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
28
29
30
31
32
33
34
35
36
37
38
39
import Ember from 'ember';
import {goToDefinition} from '../utils/go-to-definition';
import {urls} from '../utils/api-urls';

export default Ember.Controller.extend({
  store : Ember.inject.service('store'),
  currentFile : null,
  loadItemsFunction : null,
  query : null,
  searchMode : "currentPackage",
  createSearchUrlFunction : Ember.computed("searchMode","model",function() {    
    const packageId = this.get('model.id');    
    if(this.get('searchMode') === "currentPackage") {
      return (query) => urls.identifierSearchUrl(packageId,query);
    } else {
      return (query) => urls.globalIdentifiersUrl(query);
    }
  }),
  actions : {
    searchIdentifier (query) {
      if(query) {
        this.set('currentFile',null);
        document.title = this.get('model.id');
        if(this.get('searchMode') === "currentPackage") {
          this.transitionToRoute('package.search',query);
        } else {
          this.transitionToRoute('search',query);
        }
      }
    },
    showIdentifier (identifierInfo) {
      goToDefinition(this.get('store'),
                     identifierInfo.locationInfo,
                     1,//left mouse button
                     null);
      return false;
    }
  }
});