Skip to content

Commit

Permalink
Move route announcement from SearchResultsListView to -Panel
Browse files Browse the repository at this point in the history
This was misfactored in 9f791cd. #163 #449 #501
  • Loading branch information
jgonggrijp committed Nov 10, 2021
1 parent e314696 commit 9e069d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
12 changes: 12 additions & 0 deletions frontend/src/panel-search-results/search-result-list-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ import { extend, get } from 'lodash';
import { CompositeView, ViewOptions as BaseOpt } from '../core/view';
import FlatItem from '../common-adapters/flat-item-model';
import explorerChannel from '../explorer/explorer-radio';
import { announceRoute } from '../explorer/utilities';
import SemanticQuery from '../semantic-search/model';
import LoadingSpinner from '../loading-spinner/loading-spinner-view';

import searchResultListTemplate from './search-result-list-template';
import SearchResultListView from './search-result-list-view';

const announceAnno = announceRoute('item:annotations', ['model', 'id']);
const announceQuery = announceRoute('search:results:semantic', ['model', 'id']);

function announce(): void {
if (this.model instanceof SemanticQuery) {
this.model.when('id', announceQuery, this);
} else announceAnno.call(this);
}

export interface ViewOptions extends BaseOpt {
selectable: boolean;
/**
Expand Down Expand Up @@ -36,6 +47,7 @@ export default class SearchResultListPanel extends CompositeView {
promise.then(this.removeSpinner.bind(this));
}
this.render();
this.on('announceRoute', announce);
return this;
}

Expand Down
13 changes: 0 additions & 13 deletions frontend/src/panel-search-results/search-result-list-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,8 @@ import { extend, invokeMap } from 'lodash';
import { CollectionView, ViewOptions as BaseOpt } from '../core/view';
import FlatItem from '../common-adapters/flat-item-model';

import { announceRoute } from '../explorer/utilities';
import SemanticQuery from '../semantic-search/model';

import SearchResultView from './search-result-base-view';

const announceAnno = announceRoute('item:annotations', ['model', 'id']);
const announceQuery = announceRoute('search:results:semantic', ['model', 'id']);

function announce(): void {
if (this.model instanceof SemanticQuery) {
this.model.when('id', announceQuery, this);
} else announceAnno.call(this);
}

export interface ViewOptions extends BaseOpt {
selectable: boolean;
}
Expand All @@ -38,7 +26,6 @@ class SearchResultListView extends CollectionView<FlatItem, SearchResultView> {
blur: this.onBlur,
});
this.listenToOnce(this.collection, 'add', this.render);
this.on('announceRoute', announce);
return this;
}

Expand Down

0 comments on commit 9e069d9

Please sign in to comment.