Skip to content

Commit

Permalink
Merge pull request #6348 from tomachalek/freq_vs_subc_warning_b
Browse files Browse the repository at this point in the history
Add warning about mixing subcorpus with zero freq. limit ...
  • Loading branch information
tomachalek authored Nov 5, 2024
2 parents 945e925 + 895795a commit f58607d
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 74 deletions.
2 changes: 2 additions & 0 deletions public/files/js/models/freqs/regular/freqForms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export interface TTFreqFormModelState {
fttattr:Array<string>;
flimit:Kontext.FormValue<string>;
freqSort:string;
isSubcorpusSelected:boolean;
}

export class TTFreqFormModel extends StatelessModel<TTFreqFormModelState> {
Expand All @@ -279,6 +280,7 @@ export class TTFreqFormModel extends StatelessModel<TTFreqFormModelState> {
fttattr: props.fttattr,
flimit: {value: props.flimit, isInvalid: false, isRequired: true},
freqSort: props.freq_sort,
isSubcorpusSelected: !!pageModel.getCorpusIdent().usesubcorp
}
);
this.pageModel = pageModel;
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 @@ -751,6 +751,7 @@
"freq__align_type_right": "slova KWIC nejvíce vpravo",
"freq__move_level_up": "Posunout nahoru",
"freq__move_level_down": "Posunout dolů",
"freq__warn_about_zero_freq_vs_subc": "Je-li používán subkorpus, při nulovém limitu se zobrazí všechny dostupné hodnoty z celého korpusu.",
"freq__ml_th_level": "Úroveň",
"freq__ml_th_attribute": "Atribut",
"freq__ml_th_icase": "Nerozlišovat velikost",
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 @@ -751,6 +751,7 @@
"freq__align_type_right": "rightmost KWIC word",
"freq__move_level_up": "Move upwards",
"freq__move_level_down": "Move downwards",
"freq__warn_about_zero_freq_vs_subc": "If a subcorpus is used, all available values from the entire corpus are displayed when the limit is zero.",
"freq__ml_th_level": "Level",
"freq__ml_th_attribute": "Attribute",
"freq__ml_th_icase": "Ignore case",
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 @@ -748,6 +748,7 @@
"freq__align_type_right": "skrajna desna beseda KWIC",
"freq__move_level_up": "Premakni navzgor",
"freq__move_level_down": "Premakni navzdol",
"freq__warn_about_zero_freq_vs_subc": "If a subcorpus is used, all available values from the entire corpus are displayed when the limit is zero. UNTRANSLATED",
"freq__ml_th_level": "Stopnja",
"freq__ml_th_attribute": "Atribut",
"freq__ml_th_icase": "Ne ločuj malih/velikih črk",
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 @@ -750,6 +750,7 @@
"freq__align_type_right": "słowo KWIC nojdalsze w prawo",
"freq__move_level_up": "Przeniyś wyżyj",
"freq__move_level_down": "Przeniyś niżyj",
"freq__warn_about_zero_freq_vs_subc": "If a subcorpus is used, all available values from the entire corpus are displayed when the limit is zero. UNTRANSLATED",
"freq__ml_th_level": "Poziōm",
"freq__ml_th_attribute": "Atrybut",
"freq__ml_th_icase": "Wielkośc liter bez znaczyniŏ",
Expand Down
153 changes: 79 additions & 74 deletions public/files/js/views/freqs/regular/freqForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ export function init(
</div>
</td>
</tr>
{
props.isSubcorpusSelected && props.flimit.value === '0' ?
<tr>
<td colSpan={2}>
<div className="zero-val-note">
<layoutViews.StatusIcon status="warning" />
<p>{he.translate('freq__warn_about_zero_freq_vs_subc')}</p>
</div>
</td>
</tr> :
null
}
</tbody>
</table>
<table className="form">
Expand Down Expand Up @@ -423,87 +435,80 @@ export function init(

// ---------------------- <MLFreqForm /> ---------------------

class MLFreqForm extends React.Component<MLFreqFormModelState> {
const MLFreqForm:React.FC<MLFreqFormModelState> = (props) => {

constructor(props) {
super(props);
this._handleAddLevelClick = this._handleAddLevelClick.bind(this);
}

_handleAddLevelClick() {
const _handleAddLevelClick = () => {
dispatcher.dispatch<typeof Actions.MLAddLevel>({
name: Actions.MLAddLevel.name,
payload: {}
});
}

render() {
const levels = List.map((_, i) => i, this.props.mlxattr);
return (
<S.MLFreqForm>
<tbody>
<tr>
<td>
<label style={{fontWeight: 'bold'}}>
{he.translate('freq__freq_limit_label')}:{'\u00a0'}
<FreqLimitInput flimit={this.props.flimit} actionName={Actions.MLSetFLimit.name} />
</label>
</td>
<td />
</tr>
<tr>
<td colSpan={2}>
<table className="multilevel-freq-params">
<tbody>
<tr>
<th>
{he.translate('freq__ml_th_level')}
</th>
<th>
{he.translate('freq__ml_th_attribute')}
</th>
<th>
{he.translate('freq__ml_th_icase')}
</th>
<th>
{he.translate('freq__ml_th_position')}
</th>
<th>
{he.translate('freq__ml_th_node_start_at')}
</th>
<th />
<th />
</tr>
{levels.map(item => {
return <SingleLevelFieldTR
key={`level_${item}`}
isRemovable={item > 0 || levels.length > 1}
numLevels={levels.length}
levelIdx={item}
attrList={this.props.attrList}
mlxAttrValue={this.props.mlxattr[item]}
mlxicaseValue={this.props.mlxicase[item]}
positionRangeLabels={mlFreqFormModel.getPositionRangeLabels()}
mlxctxIndex={this.props.mlxctxIndices[item]}
alignType={this.props.alignType[item]} />;
})}
{levels.length < this.props.maxNumLevels ?
(<tr>
<td>
<layoutViews.PlusButton mouseOverHint={he.translate('freq__add_level_btn')}
onClick={this._handleAddLevelClick} />
</td>
<td colSpan={6} />
</tr>)
: null}
</tbody>
</table>
</td>
</tr>
</tbody>
</S.MLFreqForm>
);
}
const levels = List.map((_, i) => i, props.mlxattr);
return (
<S.MLFreqForm>
<tbody>
<tr>
<td>
<label style={{fontWeight: 'bold'}}>
{he.translate('freq__freq_limit_label')}:{'\u00a0'}
<FreqLimitInput flimit={props.flimit} actionName={Actions.MLSetFLimit.name} />
</label>
</td>
<td />
</tr>
<tr>
<td colSpan={2}>
<table className="multilevel-freq-params">
<tbody>
<tr>
<th>
{he.translate('freq__ml_th_level')}
</th>
<th>
{he.translate('freq__ml_th_attribute')}
</th>
<th>
{he.translate('freq__ml_th_icase')}
</th>
<th>
{he.translate('freq__ml_th_position')}
</th>
<th>
{he.translate('freq__ml_th_node_start_at')}
</th>
<th />
<th />
</tr>
{levels.map(item => {
return <SingleLevelFieldTR
key={`level_${item}`}
isRemovable={item > 0 || levels.length > 1}
numLevels={levels.length}
levelIdx={item}
attrList={props.attrList}
mlxAttrValue={props.mlxattr[item]}
mlxicaseValue={props.mlxicase[item]}
positionRangeLabels={mlFreqFormModel.getPositionRangeLabels()}
mlxctxIndex={props.mlxctxIndices[item]}
alignType={props.alignType[item]} />;
})}
{levels.length < props.maxNumLevels ?
(<tr>
<td>
<layoutViews.PlusButton mouseOverHint={he.translate('freq__add_level_btn')}
onClick={_handleAddLevelClick} />
</td>
<td colSpan={6} />
</tr>)
: null}
</tbody>
</table>
</td>
</tr>
</tbody>
</S.MLFreqForm>
);
}

return {
Expand Down
11 changes: 11 additions & 0 deletions public/files/js/views/freqs/regular/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ export const TTFreqForm = styled.div`
}
}
.zero-val-note {
display: flex;
align-items: center;
p {
flex-grow: 1;
color: ${theme.colorLightText};
padding-left: 1em;
}
}
}
`;

0 comments on commit f58607d

Please sign in to comment.