From e8ded03ec40e0ba3d17b9e3e57805ce9afd43534 Mon Sep 17 00:00:00 2001 From: alexwl Date: Wed, 13 Feb 2019 23:44:05 +0300 Subject: Add a switch between 'search in the current package' and 'search in all packages' on the package page --- javascript/app/controllers/package.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'javascript/app/controllers') diff --git a/javascript/app/controllers/package.js b/javascript/app/controllers/package.js index 45a8bab..278899f 100644 --- a/javascript/app/controllers/package.js +++ b/javascript/app/controllers/package.js @@ -1,16 +1,35 @@ 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",function() { + const packageId = this.get('model.id'); + const query = this.get('query'); + if(this.get('searchMode') === "currentPackage") { + return (query) => urls.identifierSearchUrl(packageId,query); + } else { + return (query) => urls.globalIdentifiersUrl(query); + } + }), actions : { + searchModeChanged () { + + }, searchIdentifier (query) { if(query) { this.set('currentFile',null); - document.title = this.get('model.id'); - this.transitionToRoute('package.search',query); + document.title = this.get('model.id'); + if(this.get('searchMode') === "currentPackage") { + this.transitionToRoute('package.search',query); + } else { + this.transitionToRoute('search',query); + } } }, showIdentifier (identifierInfo) { -- cgit v1.2.3