Skip to content

Commit

Permalink
Merge pull request #6321 from mzimandl/fullsearch
Browse files Browse the repository at this point in the history
Fix loading actions and split searches into tabs
  • Loading branch information
tomachalek authored Oct 15, 2024
2 parents d2ff7ea + 6d0fecd commit 420ac36
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 321 deletions.
5 changes: 3 additions & 2 deletions public/files/js/models/searchHistory/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ export class Actions {
name: 'QUERY_HISTORY_REMOVE_ITEM_FROM_LIST_DONE'
};

static ToggleAdvancedSearch:Action<{
static ChangeSearchForm:Action<{
value:string;
}> = {
name: 'QUERY_HISTORY_TOGGLE_ADVANCED_SEARCH'
name: 'QUERY_HISTORY_CHANGE_SEARCH_FORM'
};

static SetFsPosattrName:Action<{
Expand Down
3 changes: 1 addition & 2 deletions public/files/js/models/searchHistory/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export interface GetHistoryArgs {
query_supertype:Kontext.QuerySupertype;
corpname:string;
archived_only:boolean;
extended_search:boolean;
fsPosattrName?:string;
fsPosattrValue?:string;
fsStructureName?:string;
Expand Down Expand Up @@ -185,14 +184,14 @@ export interface SearchHistoryModelState {
archivedOnly:boolean;
currentItem:number;
supportsFulltext:boolean;
searchFormView:string;
fsQueryCQLProps:boolean;
fsPosattrName:string;
fsPosattrValue:string;
fsStructureName:string;
fsStructattrName:string;
fsStructattrValue:string;
fsAnyPropertyValue:string;
extendedSearchVisible:boolean;
fsSubcorpus:string;
fsWlAttr:string;
fsWlPat:string;
Expand Down
80 changes: 36 additions & 44 deletions public/files/js/models/searchHistory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
archivedOnly: false,
currentItem: 0,
supportsFulltext,
searchFormView: 'quick',
fsPosattrName: 'word',
fsPosattrValue: '',
fsStructureName: '',
fsStructattrName: '',
fsStructattrValue: '',
fsAnyPropertyValue: '',
fsQueryCQLProps: true,
extendedSearchVisible: false,
fsSubcorpus: '',
fsWlAttr: '',
fsWlPat: '',
Expand All @@ -112,31 +112,38 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
Actions.HistorySetCurrentCorpusOnly,
action => {
this.changeState(state => {
state.isBusy = true;
state.isBusy = !this.isAdvancedSearch();
state.currentCorpusOnly = action.payload.value;
});
this.performLoadAction();
if (!this.isAdvancedSearch()) {
this.performLoadAction();
}
}
);

this.addActionHandler(
Actions.HistorySetArchivedOnly,
action => {
this.changeState(state => {
state.isBusy = true;
state.isBusy = !this.isAdvancedSearch();
state.archivedOnly = action.payload.value;
});
this.performLoadAction();
if (!this.isAdvancedSearch()) {
this.performLoadAction();
}
}
);

this.addActionHandler(
Actions.HistorySetQuerySupertype,
action => {
this.changeState(state => {
state.isBusy = !this.isAdvancedSearch();
state.querySupertype = action.payload.value;
});
this.performLoadAction();
if (!this.isAdvancedSearch()) {
this.performLoadAction();
}
}
);

Expand Down Expand Up @@ -280,11 +287,11 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
);

this.addActionHandler(
Actions.ToggleAdvancedSearch,
Actions.ChangeSearchForm,
action => {
this.changeState(
state => {
state.extendedSearchVisible = !state.extendedSearchVisible;
state.searchFormView = action.payload.value;
}
)
}
Expand Down Expand Up @@ -425,19 +432,10 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
this.addActionHandler(
Actions.SubmitExtendedSearch,
action => {
this.loadData().subscribe({
next: () => {
this.changeState(state => {
state.isBusy = false
});
},
error: (err) => {
this.changeState(state => {
state.isBusy = false
});
this.pageModel.showMessage('error', err);
},
this.changeState(state => {
state.isBusy = true;
});
this.performLoadAction();
}
)
}
Expand All @@ -461,28 +459,19 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
}

private performLoadAction(widgetMode: boolean = false): void {
if (!this.state.extendedSearchVisible) {
this.loadData(widgetMode).subscribe({
next: () => {
this.changeState(state => {
state.isBusy = false
});
},
error: (err) => {
this.changeState(state => {
state.isBusy = false
});
this.pageModel.showMessage('error', err);
},
});

} else {
this.changeState(
state => {
state.isBusy = false;
}
);
}
this.loadData(widgetMode).subscribe({
next: () => {
this.changeState(state => {
state.isBusy = false
});
},
error: (err) => {
this.changeState(state => {
state.isBusy = false
});
this.pageModel.showMessage('error', err);
},
});
}

private loadData(widgetMode:boolean=false): Observable<GetHistoryResponse> {
Expand All @@ -494,9 +483,8 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
corpname: !widgetMode && this.state.currentCorpusOnly ?
this.pageModel.getCorpusIdent().id : undefined,
archived_only: !widgetMode && this.state.archivedOnly,
extended_search: this.state.extendedSearchVisible,
};
if (this.state.extendedSearchVisible) {
if (!widgetMode && this.isAdvancedSearch()) {
switch (this.state.querySupertype) {
case 'conc':
case 'pquery':
Expand Down Expand Up @@ -641,4 +629,8 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
)
);
}

private isAdvancedSearch():boolean {
return this.state.searchFormView === 'advanced';
}
}
4 changes: 3 additions & 1 deletion public/files/js/translations/messages.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@
"qhistory__th_datetime": "datum a čas",
"qhistory__open_in_form": "Použít",
"qhistory__filter_legend": "Filtr",
"qhistory__search_legend": "Hledání",
"qhistory__load_more_link": "Nahrát další",
"qhistory__archived_as": "Archivováno jako",
"qhistory__checkbox_archived_only": "Pouze archivované",
Expand All @@ -485,7 +486,8 @@
"qhistory__remove_from_list": "Odstranit ze seznamu",
"qhistory__item_removed": "Odstraněno ze seznamu",
"qhistory__blank_query": "nevyplněno",
"qhistory__advanced_search": "Rozšířené hledání",
"qhistory__quick_search": "Rychlé hledání",
"qhistory__extended_search": "Rozšířené hledání",
"qhistory__used_posattrs_label": "Poziční atribut",
"qhistory__used_property_value": "obsahuje",
"qhistory__used_structattrs_label": "Strukturní atribut",
Expand Down
4 changes: 3 additions & 1 deletion public/files/js/translations/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@
"qhistory__th_datetime": "date and time",
"qhistory__open_in_form": "Use",
"qhistory__filter_legend": "Filter",
"qhistory__search_legend": "Search",
"qhistory__load_more_link": "Load more",
"qhistory__archived_as": "Archived as",
"qhistory__checkbox_archived_only": "Only archived items",
Expand All @@ -485,7 +486,8 @@
"qhistory__remove_from_list": "Remove from the list",
"qhistory__item_removed": "Removed from the list",
"qhistory__blank_query": "blank",
"qhistory__advanced_search": "Extended search",
"qhistory__quick_search": "Quick search",
"qhistory__extended_search": "Extended search",
"qhistory__used_posattrs_label": "Positional attribute",
"qhistory__used_property_value": "contains",
"qhistory__used_structattrs_label": "Structural attribute",
Expand Down
4 changes: 3 additions & 1 deletion public/files/js/translations/messages.sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@
"qhistory__th_datetime": "datum in čas",
"qhistory__open_in_form": "Uporabi",
"qhistory__filter_legend": "Filter",
"qhistory__search_legend": "Search UNTRANSLATED",
"qhistory__load_more_link": "Naloži več",
"qhistory__archived_as": "Arhivirano kot",
"qhistory__checkbox_archived_only": "Samo arhivirani elementi",
Expand Down Expand Up @@ -935,7 +936,8 @@
"pquery__parameters_form": "Parametri paradigmatične poizvedbe",
"pquery__align_type_whole_kwic": "celoten KWIC kot ena beseda",
"qhistory__curr_corp_only_label_{corpus}": "{corpus} only UNTRANSLATED",
"qhistory__advanced_search": "Extended search UNTRANSLATED",
"qhistory__quick_search": "Quick search UNTRANSLATED",
"qhistory__extended_search": "Extended search UNTRANSLATED",
"qhistory__used_posattrs_label": "Positional attribute UNTRANSLATED",
"qhistory__used_property_value": "contains UNTRANSLATED",
"qhistory__used_structattrs_label": "Structural attribute UNTRANSLATED",
Expand Down
4 changes: 3 additions & 1 deletion public/files/js/translations/messages.szl.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@
"qhistory__th_datetime": "data i czas",
"qhistory__open_in_form": "Use UNTRANSLATED",
"qhistory__filter_legend": "Filter",
"qhistory__search_legend": "Search UNTRANSLATED",
"qhistory__load_more_link": "Laduj wiyncyj",
"qhistory__archived_as": "Zarchiwizowane za",
"qhistory__checkbox_archived_only": "Ino zarchiwizowane elymynta",
Expand All @@ -484,7 +485,8 @@
"qhistory__remove_from_list": "Remove from the list UNTRANSLATED",
"qhistory__item_removed": "Removed from the list UNTRANSLATED",
"qhistory__blank_query": "blank UNTRANSLATED",
"qhistory__advanced_search": "Extended search UNTRANSLATED",
"qhistory__quick_search": "Quick search UNTRANSLATED",
"qhistory__extended_search": "Extended search UNTRANSLATED",
"qhistory__used_posattrs_label": "Positional attribute UNTRANSLATED",
"qhistory__used_property_value": "contains UNTRANSLATED",
"qhistory__used_structattrs_label": "Structural attribute UNTRANSLATED",
Expand Down
Loading

0 comments on commit 420ac36

Please sign in to comment.