Skip to content

Commit

Permalink
keywords filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mzimandl committed Sep 26, 2023
1 parent 3e14b2c commit 0519f0b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 11 deletions.
18 changes: 13 additions & 5 deletions public/files/js/models/keywords/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ export interface KeywordsResultState {
data:Array<Keyword>;
isBusy:boolean;
refCorpname:string;
refSubcorpname:string|undefined;
refSubcorpId:string|undefined;
focusCorpname:string;
focusSubcorpname:string|undefined;
focusSubcorpId:string|undefined;
total:number;
kwpage:number;
kwpagesize:number;
Expand All @@ -45,15 +46,18 @@ export interface KeywordsResultState {
queryId:string;
isLoading:boolean;
manateeIsCustomCNC:boolean;
attr:string;
}

export interface KeywordsResultModelArgs {
dispatcher:IActionDispatcher;
layoutModel:PageModel;
refCorpname:string;
refSubcorpname:string|undefined;
refSubcorpId:string|undefined;
focusCorpname:string;
focusSubcorpname:string|undefined;
focusSubcorpId:string|undefined;
attr:string;
}

export interface DataAjaxResponse extends Kontext.AjaxResponse {
Expand All @@ -76,19 +80,22 @@ export class KeywordsResultModel extends StatelessModel<KeywordsResultState> {
dispatcher,
layoutModel,
refCorpname,
refSubcorpname,
refSubcorpId,
focusCorpname,
focusSubcorpname
focusSubcorpname,
focusSubcorpId,
attr,
}:KeywordsResultModelArgs) {
super(
dispatcher,
{
data: layoutModel.getConf<Array<Keyword>>('Keywords'),
isBusy: false,
refCorpname,
refSubcorpname,
refSubcorpId,
focusCorpname,
focusSubcorpname,
focusSubcorpId,
kwpage: layoutModel.getConf<number>('Page'),
kwpagesize: layoutModel.getConf<number>('PageSize'),
kwsort: layoutModel.getConf<string>('Sort'),
Expand All @@ -97,6 +104,7 @@ export class KeywordsResultModel extends StatelessModel<KeywordsResultState> {
queryId: layoutModel.getConf<string>('QueryId'),
isLoading: false,
manateeIsCustomCNC: layoutModel.getConf<boolean>('manateeIsCustomCNC'),
attr,
}
);
this.layoutModel = layoutModel;
Expand Down
4 changes: 3 additions & 1 deletion public/files/js/pages/keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ export class KeywordsResultPage {
dispatcher: this.layoutModel.dispatcher,
layoutModel: this.layoutModel,
refCorpname: this.layoutModel.getConf<KeywordsSubmitArgs>('KeywordsForm').ref_corpname,
refSubcorpname: this.layoutModel.getConf<KeywordsSubmitArgs>('KeywordsForm').ref_usesubcorp,
refSubcorpId: this.layoutModel.getConf<KeywordsSubmitArgs>('KeywordsForm').ref_usesubcorp,
focusCorpname: this.layoutModel.getCorpusIdent().id,
focusSubcorpname: this.layoutModel.getCorpusIdent().subcName,
focusSubcorpId: this.layoutModel.getCorpusIdent().usesubcorp,
attr: this.layoutModel.getConf<KeywordsSubmitArgs>('KeywordsForm').wlattr,
});
const view = viewInit({
dispatcher: this.layoutModel.dispatcher,
Expand Down
3 changes: 2 additions & 1 deletion public/files/js/translations/messages.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@
"kwords__rel_freq_in_corp2_hd": "Rel. frekv. (referenční korpus)",
"kwords__result_word_hd": "Slovo",
"kwords__min_freq": "Min. frekvence",
"kwords__max_freq": "Max. frekvence"
"kwords__max_freq": "Max. frekvence",
"kwords__filter_th": "Filtr"
}
}
3 changes: 2 additions & 1 deletion public/files/js/translations/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@
"kwords__rel_freq_in_corp2_hd": "Rel. freq. (ref. corpus)",
"kwords__result_word_hd": "Word",
"kwords__min_freq": "Min. frequency",
"kwords__max_freq": "Max. frequency"
"kwords__max_freq": "Max. frequency",
"kwords__filter_th": "Filter"
}
}
3 changes: 2 additions & 1 deletion public/files/js/translations/messages.sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,7 @@
"kwords__rel_freq_in_corp2_hd": "Rel. freq. (ref. corpus) UNTRANSLATED",
"kwords__result_word_hd": "Word UNTRANSLATED",
"kwords__min_freq": "Min. frequency UNTRANSLATED",
"kwords__max_freq": "Max. frequency UNTRANSLATED"
"kwords__max_freq": "Max. frequency UNTRANSLATED",
"kwords__filter_th": "Filter"
}
}
3 changes: 2 additions & 1 deletion public/files/js/translations/messages.szl.json
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@
"kwords__rel_freq_in_corp2_hd": "Rel. freq. (ref. corpus) UNTRANSLATED",
"kwords__result_word_hd": "Word UNTRANSLATED",
"kwords__min_freq": "Min. frequency UNTRANSLATED",
"kwords__max_freq": "Max. frequency UNTRANSLATED"
"kwords__max_freq": "Max. frequency UNTRANSLATED",
"kwords__filter_th": "Filter"
}
}
20 changes: 19 additions & 1 deletion public/files/js/views/keywords/result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ export function init({
);
};

const buildQ = (value:string) => `aword,[${props.attr}="${value}"]`;

return (
<S.KeywordsResult>

<dl className="corpora">
<dt>{he.translate('kwords__focus_corpus')}:</dt>
<dd>{props.focusCorpname} {props.focusSubcorpname ? ` / ${props.focusSubcorpname}` : ''}</dd>
<dt>{he.translate('kwords__reference_corpus')}:</dt>
<dd>{props.refCorpname} {props.refSubcorpname ? ` / ${props.refSubcorpname}` : ''}</dd>
<dd>{props.refCorpname} {props.refSubcorpId ? ` / ${props.refSubcorpId}` : ''}</dd>
</dl>

<div className="ktx-pagination">
Expand All @@ -109,7 +111,9 @@ export function init({
<th>{he.translate('kwords__score_col_hd')}</th>
}
<th>{he.translate('kwords__freq_in_corp1_hd')}</th>
<th>{he.translate('kwords__filter_th')}</th>
<th>{he.translate('kwords__freq_in_corp2_hd')}</th>
<th>{he.translate('kwords__filter_th')}</th>
<th>{he.translate('kwords__rel_freq_in_corp1_hd')}</th>
<th>{he.translate('kwords__rel_freq_in_corp2_hd')}</th>
</tr>
Expand All @@ -130,7 +134,21 @@ export function init({
<td className="num">{he.formatNumber(kw.score, 2)}</td>
}
<td className="num">{he.formatNumber(kw.frq1, 0)}</td>
<td>
<a href={he.createActionLink('create_view',
props.focusSubcorpId ?
{corpname: props.focusCorpname, usesubcorp: props.focusSubcorpId, q: buildQ(kw.item)} :
{corpname: props.focusCorpname, q: buildQ(kw.item)}
)}> p </a>
</td>
<td className="num">{he.formatNumber(kw.frq2, 0)}</td>
<td>
<a href={he.createActionLink('create_view',
props.refSubcorpId ?
{corpname: props.refCorpname, usesubcorp: props.refSubcorpId, q: buildQ(kw.item)} :
{corpname: props.refCorpname, q: buildQ(kw.item)}
)}> p </a>
</td>
<td className="num">{he.formatNumber(kw.rel_frq1, 2)}</td>
<td className="num">{he.formatNumber(kw.rel_frq2, 2)}</td>
</tr>
Expand Down

0 comments on commit 0519f0b

Please sign in to comment.