Skip to content

Commit

Permalink
[github-#4][fix]: provides bookmarks into search results view (close #4
Browse files Browse the repository at this point in the history
…).
  • Loading branch information
dmitry.astafyev committed Jan 5, 2018
1 parent 705c75d commit f1c3b55
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 12 deletions.
2 changes: 2 additions & 0 deletions app/client/src/app/config/events.system.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"VIEW_RESIZE_FINISHED" : "VIEW_RESIZE_FINISHED",
"VIEW_FORCE_UPDATE_CONTENT" : "VIEW_FORCE_UPDATE_CONTENT",
"VIEW_SWITCH_POSITION_BETWEEN" : "VIEW_SWITCH_POSITION_BETWEEN",
"BOOKMARK_IS_CREATED" : "BOOKMARK_IS_CREATED",
"BOOKMARK_IS_REMOVED" : "BOOKMARK_IS_REMOVED",

"HOLDER_VIEWS_RESIZE" : "HOLDER_VIEWS_RESIZE",
"ADD_VIEW" : "ADD_VIEW",
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/app/views/list/component.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/client/src/app/views/list/component.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app/client/src/app/views/list/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,10 @@ export class ViewControllerList extends ViewControllerPattern implements ViewInt
toggleBookmark(index : number){
if(~this.bookmarks.indexOf(index)){
this.bookmarks.splice(this.bookmarks.indexOf(index),1);
Events.trigger(Configuration.sets.SYSTEM_EVENTS.BOOKMARK_IS_REMOVED, index);
} else {
this.bookmarks.push(index);
Events.trigger(Configuration.sets.SYSTEM_EVENTS.BOOKMARK_IS_CREATED, index);
}
if (this.bookmarks.length > 0){
Events.trigger(Configuration.sets.EVENTS_VIEWS.VIEW_BAR_ENABLE_BUTTON, this.viewParams.GUID, 'LIST_VIEW_ONLY_BOOKMARKS_TRIGGER');
Expand Down
29 changes: 24 additions & 5 deletions app/client/src/app/views/search.results/tab.results/component.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

30 changes: 25 additions & 5 deletions app/client/src/app/views/search.results/tab.results/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class TabControllerSearchResults extends TabController implements ViewInt
private regsCache : Object = {};
private requests : Array<Request> = [];
private _requests : Array<Request> = [];
private bookmarks : Array<number> = [];
private requestsListClosed : boolean = true;
private filterMode : string = FILTER_MODES.ACTIVE_AND_PASSIVE;
private conditions : Array<SimpleListItem> = [
Expand Down Expand Up @@ -150,7 +151,9 @@ export class TabControllerSearchResults extends TabController implements ViewInt
Configuration.sets.EVENTS_SHORTCUTS.SHORTCUT_TO_BEGIN,
Configuration.sets.EVENTS_SHORTCUTS.SHORTCUT_TO_END,
Configuration.sets.SYSTEM_EVENTS.REQUESTS_HISTORY_UPDATED,
Configuration.sets.SYSTEM_EVENTS.REQUESTS_APPLIED].forEach((handle: string)=>{
Configuration.sets.SYSTEM_EVENTS.REQUESTS_APPLIED,
Configuration.sets.SYSTEM_EVENTS.BOOKMARK_IS_CREATED,
Configuration.sets.SYSTEM_EVENTS.BOOKMARK_IS_REMOVED].forEach((handle: string)=>{
this['on' + handle] = this['on' + handle].bind(this);
Events.bind(handle, this['on' + handle]);
});
Expand Down Expand Up @@ -182,7 +185,9 @@ export class TabControllerSearchResults extends TabController implements ViewInt
Configuration.sets.EVENTS_SHORTCUTS.SHORTCUT_TO_BEGIN,
Configuration.sets.EVENTS_SHORTCUTS.SHORTCUT_TO_END,
Configuration.sets.SYSTEM_EVENTS.REQUESTS_HISTORY_UPDATED,
Configuration.sets.SYSTEM_EVENTS.REQUESTS_APPLIED].forEach((handle: string)=>{
Configuration.sets.SYSTEM_EVENTS.REQUESTS_APPLIED,
Configuration.sets.SYSTEM_EVENTS.BOOKMARK_IS_CREATED,
Configuration.sets.SYSTEM_EVENTS.BOOKMARK_IS_REMOVED].forEach((handle: string)=>{
Events.unbind(handle, this['on' + handle]);
});
this.onScrollSubscription. unsubscribe();
Expand All @@ -207,6 +212,20 @@ export class TabControllerSearchResults extends TabController implements ViewInt
Events.trigger(Configuration.sets.SYSTEM_EVENTS.REQUESTS_HISTORY_GET_ALL, this.onREQUESTS_HISTORY_UPDATED.bind(this));
}

onBOOKMARK_IS_CREATED(index: number) {
this.bookmarks.indexOf(index) === -1 && this.bookmarks.push(index);
this.filterRows();
this.updateRows();
this.forceUpdate();
}

onBOOKMARK_IS_REMOVED(index: number) {
this.bookmarks.indexOf(index) !== -1 && this.bookmarks.splice(this.bookmarks.indexOf(index),1);
this.filterRows();
this.updateRows();
this.forceUpdate();
}

onREQUESTS_HISTORY_UPDATED(requests: Array<Request>, _requests: Array<Request>){
this.requests = requests;
this._requests = _requests.map((request)=>{
Expand Down Expand Up @@ -296,7 +315,7 @@ export class TabControllerSearchResults extends TabController implements ViewInt
original : row.str,
index : _index,
selection : this.selection.index === _index ? true : false,
bookmarked : false,
bookmarked : this.bookmarks.indexOf(index) !== -1,
visibility : this.numbers,
total_rows : this._rows.length === 0 ? rows.length : this._rows.length,
markers : this.markers,
Expand Down Expand Up @@ -346,7 +365,7 @@ export class TabControllerSearchResults extends TabController implements ViewInt
if (requests.length > 0){
result = rows.filter((row, index)=>{
if (exp[index] === void 0){
let filtered = false,
let filtered = this.bookmarks.indexOf(index) !== -1,
highlight = {
foregroundColor: '',
backgroundColor: ''
Expand Down Expand Up @@ -459,14 +478,15 @@ export class TabControllerSearchResults extends TabController implements ViewInt

updateRows(){
let markersHash = this.getMarkersHash();
this.rows instanceof Array && (this.rows = this.rows.map((row)=>{
this.rows instanceof Array && (this.rows = this.rows.map((row, index)=>{
let selection = this.selection.index === row.params.index ? true : false,
update = row.params.selection !== selection ? (row.update !== null) : false;
update = row.params.GUID !== null ? (row.update !== null) : update;
row.params.selection = selection;
row.params.visibility = this.numbers;
row.params.total_rows = this._rows.length;
row.params.GUID = this.viewParams !== null ? this.viewParams.GUID : null;
row.params.bookmarked = this.bookmarks.indexOf(row.index) !== -1;
row.params.markers = this.markers;
row.params.markersHash = markersHash;
update && row.update(row.params);
Expand Down

0 comments on commit f1c3b55

Please sign in to comment.