Skip to content

Commit

Permalink
Improve UX, add GUI support to "archived as"
Browse files Browse the repository at this point in the history
  • Loading branch information
tomachalek committed Oct 16, 2024
1 parent 16e88c3 commit ba8e876
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 28 deletions.
6 changes: 6 additions & 0 deletions public/files/js/models/searchHistory/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export class Actions {
name: 'QUERY_HISTORY_SET_ARCHIVED_ONLY'
};

static HistorySetArchivedAs:Action<{
value:string;
}> = {
name: 'QUERY_HISTORY_SET_ARCHIVED_AS'
};

static HistorySetEditedItem:Action<{
itemIdx:number;
}> = {
Expand Down
2 changes: 2 additions & 0 deletions public/files/js/models/searchHistory/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface GetHistoryArgs {
fsStructattrValue?:string;
fsCorpus?:string;
fsSubcorpus?:string;
fsArchivedAs?:string;
fsWlpat?:string;
fsWlattr?:string;
fsWlPfilter?:string;
Expand Down Expand Up @@ -197,6 +198,7 @@ export interface SearchHistoryModelState {
fsAnyPropertyValue:string;
fsCorpus:string;
fsSubcorpus:string;
fsArchAs:string;
fsWlAttr:string;
fsWlPat:string;
fsWlPFilter:string;
Expand Down
17 changes: 17 additions & 0 deletions public/files/js/models/searchHistory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
fsQueryCQLProps: true,
fsCorpus: pageModel.getCorpusIdent().id,
fsSubcorpus: '',
fsArchAs: '',
fsWlAttr: '',
fsWlPat: '',
fsWlNFilter: '',
Expand Down Expand Up @@ -136,6 +137,15 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
}
);

this.addActionHandler(
Actions.HistorySetArchivedAs,
action => {
this.changeState(state => {
state.fsArchAs = action.payload.value
});
}
);

this.addActionHandler(
Actions.HistorySetQuerySupertype,
action => {
Expand Down Expand Up @@ -518,17 +528,20 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
args.fsStructureName = this.state.fsStructureName;
args.fsCorpus = this.state.fsCorpus;
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsArchivedAs = this.state.fsArchAs;

} else {
args.fsCorpus = this.state.fsCorpus;
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsArchivedAs = this.state.fsArchAs;
args.fsAnyPropertyValue = this.state.fsAnyPropertyValue;
}
break;
case 'wlist':
if (this.state.fsQueryCQLProps) {
args.fsCorpus = this.state.fsCorpus;
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsArchivedAs = this.state.fsArchAs;
args.fsWlpat = this.state.fsWlPat;
args.fsWlattr = this.state.fsWlAttr;
args.fsWlPfilter = this.state.fsWlPFilter;
Expand All @@ -537,24 +550,28 @@ export class SearchHistoryModel extends StatefulModel<SearchHistoryModelState> {
} else {
args.fsCorpus = this.state.fsCorpus;
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsArchivedAs = this.state.fsArchAs;
args.fsAnyPropertyValue = this.state.fsAnyPropertyValue;
}
break;
case 'kwords':
if (this.state.fsQueryCQLProps) {
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsArchivedAs = this.state.fsArchAs;
args.fsPosattrName = this.state.fsPosattrName;

} else {
args.fsCorpus = this.state.fsCorpus;
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsArchivedAs = this.state.fsArchAs;
args.fsAnyPropertyValue = this.state.fsAnyPropertyValue;
}
break;
default:
args.fsCorpus = this.state.fsCorpus;
args.fsSubcorpus = this.state.fsSubcorpus;
args.fsArchivedAs = this.state.fsArchAs;
args.fsAnyPropertyValue = this.state.fsAnyPropertyValue;
break;
}
Expand Down
1 change: 1 addition & 0 deletions public/files/js/translations/messages.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@
"qhistory__used_pfilter": "Slova pozitivního filtru",
"qhistory__used_nfilter": "Slova negativního filtru",
"qhistory__any_search_note": "Pro podrobnější výběr parametrů zvolte ve filtru konkrétní typ dotazu.",
"qhistory__archived_as_label": "Archivováno jako",
"concview__invalid_page_num_err": "Neplatné číslo stránky",
"concview__click_for_details": "Klikněte pro zobrazení detailů",
"concview__sort_jump_to": "Přejít na",
Expand Down
1 change: 1 addition & 0 deletions public/files/js/translations/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@
"qhistory__used_pfilter": "Positive filter words",
"qhistory__used_nfilter": "Negative filter words",
"qhistory__any_search_note": "For a more detailed selection of parameters, select a specific query type in the filter.",
"qhistory__archived_as_label": "Archived as",
"concview__invalid_page_num_err": "Invalid page number",
"concview__click_for_details": "Click to see details",
"concview__sort_jump_to": "Jump to",
Expand Down
1 change: 1 addition & 0 deletions public/files/js/translations/messages.sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@
"qhistory__remove_from_list": "Odstrani s seznama",
"qhistory__item_removed": "Odstranjeno s seznama",
"qhistory__blank_query": "prazno",
"qhistory__archived_as_label": "Archived as UNTRANSLATED",
"concview__ipm_rel_to_the_whole_corp": "se nanaša na celoten korpus",
"concview__click_to_play_audio": "Kliknite za predvajanje zvočnega posnetka",
"concview__detail_default_mode_menu": "Privzeti prikaz",
Expand Down
1 change: 1 addition & 0 deletions public/files/js/translations/messages.szl.json
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@
"qhistory__used_pfilter": "Positive filter words UNTRANSLATED",
"qhistory__used_nfilter": "Negative filter words UNTRANSLATED",
"qhistory__any_search_note": "For a more detailed selection of parameters, select a specific query type in the filter. UNTRANSLATED",
"qhistory__archived_as_label": "Archived as UNTRANSLATED",
"concview__invalid_page_num_err": "Niynŏleżyn numer strōny",
"concview__click_for_details": "Kliknij, żeby ôbejzdrzeć szczegōły",
"concview__sort_jump_to": "Skocz do",
Expand Down
24 changes: 8 additions & 16 deletions public/files/js/views/searchHistory/full/fulltextForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,17 @@ export function init(
}> = (props) => {

return <>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<QueryCQLProps isAdvancedQuery={props.fsQueryCQLProps} />
{props.fsQueryCQLProps ?
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<UsedPosattrs attr={props.fsPosattrName} value={props.fsPosattrValue} />
<UsedStructattrs attr={props.fsStructattrName} value={props.fsStructattrValue} />
<UsedStructures attr={props.fsStructureName} />
<div />
</> :
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<AnyPropertyValue value={props.fsAnyPropertyValue} />
</>
}
Expand All @@ -319,18 +317,16 @@ export function init(
}> = (props) => {

return <>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<QueryCQLProps isAdvancedQuery={props.fsQueryCQLProps} />
{props.fsQueryCQLProps ?
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<UsedPosattrs attr={props.fsPosattrName} value={props.fsPosattrValue} />
<UsedStructures attr={props.fsStructureName} />
<UsedStructattrs attr={props.fsStructattrName} value={props.fsStructattrValue} />
</> :
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<AnyPropertyValue value={props.fsAnyPropertyValue} />
</>
}
Expand Down Expand Up @@ -387,11 +383,11 @@ export function init(
};

return <>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<QueryCQLProps isAdvancedQuery={props.fsQueryCQLProps} />
{props.fsQueryCQLProps ?
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<label>{he.translate('qhistory__used_wlattr')}</label>
<input type="text" value={props.wlattr} onChange={handleWlattrChange} />
<label>{he.translate('qhistory__used_wlpat')}</label>
Expand All @@ -402,8 +398,6 @@ export function init(
<input type="text" value={props.nfilter} onChange={handleNFilterChange} />
</> :
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<AnyPropertyValue value={props.fsAnyPropertyValue} />
</>
}
Expand All @@ -430,20 +424,18 @@ export function init(
};

return <>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<QueryCQLProps isAdvancedQuery={props.fsQueryCQLProps} />
{props.fsQueryCQLProps ?
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<div className="prop-query">
<label>{he.translate('qhistory__used_posattrs_label')}</label>
{'\u00a0'}
<input type="text" value={props.fsPosattrName} onChange={handleAttrChange} />
</div>
</> :
<>
<UsedCorpus value={props.fsCorpus} />
<UsedSubcorpus value={props.fsSubcorpus} />
<AnyPropertyValue value={props.fsAnyPropertyValue} />
</>
}
Expand Down
4 changes: 2 additions & 2 deletions public/files/js/views/searchHistory/full/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function init(
{he.translate('qhistory__filter_legend')}
</legend>
<div className="grid-inputs">
<srchFields.BasicFields corpusSel={true} />
<srchFields.BasicFields corpusSel={true} archivedAsEnable={false} />
</div>
</fieldset>
</S.FilterForm>
Expand All @@ -124,7 +124,7 @@ export function init(
{he.translate('qhistory__search_legend')}
</legend>
<div className="grid-inputs">
<srchFields.BasicFields corpusSel={false} />
<srchFields.BasicFields corpusSel={false} archivedAsEnable={true} />
<srchFields.ExtendedFields />
</div>
{!props.querySupertype ?
Expand Down
48 changes: 38 additions & 10 deletions public/files/js/views/searchHistory/full/srchFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { init as extendedSearchFormInit } from './fulltextForms';
import * as S from './style';

export interface FieldsViews {
BasicFields:React.ComponentClass<{corpusSel:boolean}>;
BasicFields:React.ComponentClass<{corpusSel:boolean; archivedAsEnable:boolean}>;
ExtendedFields:React.ComponentClass<{}>;
}

Expand Down Expand Up @@ -106,16 +106,42 @@ export function init(
};

return (
<S.ArchivedOnlyCheckbox>
<input type="checkbox" checked={props.value} onChange={handleChange}
<>
<label>{he.translate('qhistory__checkbox_archived_only')}:</label>
<S.ArchivedOnlyCheckbox>
<input type="checkbox" checked={props.value} onChange={handleChange}
style={{verticalAlign: 'middle'}} />
</S.ArchivedOnlyCheckbox>
)
}
</S.ArchivedOnlyCheckbox>
</>
);
};

// -------------- <ArchivedAsInput /> ----------------------------

const ArchivedAsInput:React.FC<{
value:string;
}> = (props) => {

const handleChange = (evt:React.ChangeEvent<HTMLInputElement>) => {
dispatcher.dispatch(
Actions.HistorySetArchivedAs,
{
value: evt.target.value
}
);
};

return (
<>
<label>{he.translate('qhistory__archived_as_label')}:</label>
<input type="text" value={props.value} onChange={handleChange} />
</>
);
};

// -------------------- <BasicFieldset /> -------------------------

const BasicFields:React.FC<SearchHistoryModelState & {corpusSel:boolean}> = (props) => {
const BasicFields:React.FC<SearchHistoryModelState & {corpusSel:boolean; archivedAsEnable:boolean}> = (props) => {
return (
<>
{props.corpusSel ?
Expand All @@ -127,8 +153,10 @@ export function init(
}
<label>{he.translate('qhistory__query_supertype_sel')}:</label>
<SearchKindSelector value={props.querySupertype} />
<label>{he.translate('qhistory__checkbox_archived_only')}:</label>
<ArchivedOnlyCheckbox value={props.archivedOnly} />
{props.archivedAsEnable ?
<ArchivedAsInput value={props.fsArchAs} /> :
<ArchivedOnlyCheckbox value={props.archivedOnly} />
}
</>
);
}
Expand Down Expand Up @@ -190,7 +218,7 @@ export function init(
}

return {
BasicFields: BoundWithProps<{corpusSel:boolean}, SearchHistoryModelState>(
BasicFields: BoundWithProps<{corpusSel:boolean; archivedAsEnable:boolean}, SearchHistoryModelState>(
BasicFields, queryHistoryModel),
ExtendedFields: Bound(AdvancedFields, queryHistoryModel),
}
Expand Down

0 comments on commit ba8e876

Please sign in to comment.