Skip to content

Commit

Permalink
add composition mode to pquery inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mzimandl committed Oct 31, 2022
1 parent 0f7a449 commit 18a281e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions public/files/js/models/pquery/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export interface PqueryFormModelState {
structAttrs:Array<Kontext.AttrItem>;
paramsVisible:boolean;
posRangeNotSupported:boolean; // for structural attributes pos range makes no sense
compositionModeOn:boolean;
}

/**
Expand Down Expand Up @@ -192,7 +193,7 @@ export function newModelState(
type: 'specification',
maxNonMatchingRatio: Kontext.newFormValue('0', true)
},
type: 'partial-query'
type: 'partial-query',
}
),
2
Expand Down Expand Up @@ -222,7 +223,8 @@ export function newModelState(
attrs,
structAttrs,
paramsVisible: true,
posRangeNotSupported: defaultAttr.includes('.')
posRangeNotSupported: defaultAttr.includes('.'),
compositionModeOn: false,
};
}

Expand Down Expand Up @@ -465,7 +467,8 @@ export function storedQueryToModel(
attrs,
structAttrs,
paramsVisible: true,
posRangeNotSupported: sq.attr.includes('.')
posRangeNotSupported: sq.attr.includes('.'),
compositionModeOn: false,
}
}

Expand Down
11 changes: 11 additions & 0 deletions public/files/js/models/pquery/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ export class PqueryFormModel extends StatefulModel<PqueryFormModelState> impleme
}
);

this.addActionHandler(
QueryActions.SetCompositionMode,
action => {
this.changeState(
state => {
state.compositionModeOn = action.payload.status;
}
)
}
);

this.addActionHandler<typeof QueryActions.QueryInputMoveCursor>(
QueryActions.QueryInputMoveCursor.name,
action => {
Expand Down
1 change: 0 additions & 1 deletion public/files/js/models/query/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { Actions } from './actions';
import { Actions as ConcActions } from '../concordance/actions';
import { Actions as MainMenuActions } from '../mainMenu/actions';
import * as PluginInterfaces from '../../types/plugins';
import { TextTypesModel } from '../textTypes/main';
import { AjaxConcResponse } from '../concordance/common';
import { QueryType, AnyQuery, AdvancedQuery, SimpleQuery, parseSimpleQuery } from './query';
import { highlightSyntaxStatic } from '../cqleditor/parser';
Expand Down

0 comments on commit 18a281e

Please sign in to comment.