diff options
author | alexwl <alexey.a.kiryushin@gmail.com> | 2019-02-13 23:44:05 +0300 |
---|---|---|
committer | alexwl <alexey.a.kiryushin@gmail.com> | 2019-02-13 23:44:05 +0300 |
commit | e8ded03ec40e0ba3d17b9e3e57805ce9afd43534 (patch) | |
tree | b669e381faed51dff9445fe6d869513c46cb5589 /javascript/app | |
parent | 0b17136d965ddc602a5a0176b538bdb0a47f4d12 (diff) |
Add a switch between 'search in the current package' and 'search in all packages' on the package page
Diffstat (limited to 'javascript/app')
-rw-r--r-- | javascript/app/components/input-with-autocomplete.js | 11 | ||||
-rw-r--r-- | javascript/app/controllers/package.js | 23 | ||||
-rw-r--r-- | javascript/app/routes/package.js | 5 | ||||
-rw-r--r-- | javascript/app/styles/app.scss | 1 | ||||
-rw-r--r-- | javascript/app/templates/package.hbs | 13 |
5 files changed, 44 insertions, 9 deletions
diff --git a/javascript/app/components/input-with-autocomplete.js b/javascript/app/components/input-with-autocomplete.js index 2b09ea4..34abe7a 100644 --- a/javascript/app/components/input-with-autocomplete.js +++ b/javascript/app/components/input-with-autocomplete.js @@ -97,10 +97,15 @@ export default Ember.Component.extend({ }); }, showAutocompleteList() { - this.$autocompleteContainer.css({ - "display":"block" - }); + if(this.get('query') !== "") { + this.$autocompleteContainer.css({ + "display":"block" + }); + } }, + searchUrlObserver : Ember.observer('createSearchUrlFunction',function() { + this.notifyPropertyChange('query'); + }), queryObserver : Ember.observer("query",function() { if(this.get('query')) { const perPage = this.get('maxItems') ? this.get('maxItems') : 10; 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) { diff --git a/javascript/app/routes/package.js b/javascript/app/routes/package.js index 1076779..037ed97 100644 --- a/javascript/app/routes/package.js +++ b/javascript/app/routes/package.js @@ -3,7 +3,7 @@ import {urls} from '../utils/api-urls'; export default Ember.Route.extend({ store : Ember.inject.service('store'), - model (params) { + model (params) { return this.get('store').loadPackage(params.packageId) .catch((e) => {console.log(e);this.transitionTo("/package-not-found");}); }, @@ -11,9 +11,6 @@ export default Ember.Route.extend({ this._super(controller, model); const packageId = this.modelFor('package').id; controller.set('bottomPanelVisible',false); - controller.set('createSearchUrlFunction',(query) => { - return urls.identifierSearchUrl(packageId,query); - }); }, actions : { openFile (filePath) { diff --git a/javascript/app/styles/app.scss b/javascript/app/styles/app.scss index a6e322e..c847bfa 100644 --- a/javascript/app/styles/app.scss +++ b/javascript/app/styles/app.scss @@ -142,6 +142,7 @@ li { .package-header-filename { white-space: nowrap; + margin-left: 35px; } .package-header-package-name { diff --git a/javascript/app/templates/package.hbs b/javascript/app/templates/package.hbs index 5f9fa68..f58d10a 100644 --- a/javascript/app/templates/package.hbs +++ b/javascript/app/templates/package.hbs @@ -11,6 +11,7 @@ placeholder="Identifier" as |identifier|}} <span class="source-code-font">{{identifier.demangledOccName}} :: {{type-signature-text components=identifier.idType.components}}</span> <div class="module-name"> + <b>{{identifier.locationInfo.packageId.name}}-{{identifier.locationInfo.packageId.version}}</b> {{#if identifier.locationInfo.modulePath}} {{identifier.locationInfo.modulePath}} {{else}} @@ -19,6 +20,18 @@ </div> {{/input-with-autocomplete}} </span> + {{#radio-button + value="currentPackage" + groupValue=searchMode + changed="searchModeChanged"}} + <span>in {{model.id}}</span> + {{/radio-button}} + {{#radio-button + value="allPackages" + groupValue=searchMode + changed="searchModeChanged"}} + <span>in all packages</span> + {{/radio-button}} {{#if currentFile}} <span class="package-header-filename"> {{currentFile}} |