B: Fix form messages priority
This commit is contained in:
parent
974d63550b
commit
6a2712c499
|
|
@ -79,12 +79,12 @@ export function DlgCreateBlock() {
|
||||||
const children_operations = useWatch({ control: methods.control, name: 'children_operations' });
|
const children_operations = useWatch({ control: methods.control, name: 'children_operations' });
|
||||||
const [activeTab, setActiveTab] = useState<TabID>(TabID.CARD);
|
const [activeTab, setActiveTab] = useState<TabID>(TabID.CARD);
|
||||||
const { canSubmit, hint } = (() => {
|
const { canSubmit, hint } = (() => {
|
||||||
if (!methods.formState.isValid) {
|
if (!title) {
|
||||||
return { canSubmit: false, hint: hintMsg.formInvalid };
|
|
||||||
} else if (!title) {
|
|
||||||
return { canSubmit: false, hint: hintMsg.titleEmpty };
|
return { canSubmit: false, hint: hintMsg.titleEmpty };
|
||||||
} else if (manager.oss.blocks.some(block => block.title === title)) {
|
} else if (manager.oss.blocks.some(block => block.title === title)) {
|
||||||
return { canSubmit: false, hint: hintMsg.blockTitleTaken };
|
return { canSubmit: false, hint: hintMsg.blockTitleTaken };
|
||||||
|
} else if (!methods.formState.isValid) {
|
||||||
|
return { canSubmit: false, hint: hintMsg.formInvalid };
|
||||||
} else {
|
} else {
|
||||||
return { canSubmit: true, hint: '' };
|
return { canSubmit: true, hint: '' };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,12 +66,12 @@ export function DlgCreateSchema() {
|
||||||
});
|
});
|
||||||
const alias = useWatch({ control: control, name: 'item_data.alias' });
|
const alias = useWatch({ control: control, name: 'item_data.alias' });
|
||||||
const { canSubmit, hint } = (() => {
|
const { canSubmit, hint } = (() => {
|
||||||
if (!isValid) {
|
if (!alias) {
|
||||||
return { canSubmit: false, hint: hintMsg.formInvalid };
|
|
||||||
} else if (!alias) {
|
|
||||||
return { canSubmit: false, hint: hintMsg.aliasEmpty };
|
return { canSubmit: false, hint: hintMsg.aliasEmpty };
|
||||||
} else if (manager.oss.operations.some(operation => operation.alias === alias)) {
|
} else if (manager.oss.operations.some(operation => operation.alias === alias)) {
|
||||||
return { canSubmit: false, hint: hintMsg.schemaAliasTaken };
|
return { canSubmit: false, hint: hintMsg.schemaAliasTaken };
|
||||||
|
} else if (!isValid) {
|
||||||
|
return { canSubmit: false, hint: hintMsg.formInvalid };
|
||||||
} else {
|
} else {
|
||||||
return { canSubmit: true, hint: '' };
|
return { canSubmit: true, hint: '' };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ export function DlgCreateSynthesis() {
|
||||||
const alias = useWatch({ control: methods.control, name: 'item_data.alias' });
|
const alias = useWatch({ control: methods.control, name: 'item_data.alias' });
|
||||||
const [activeTab, setActiveTab] = useState<TabID>(TabID.ARGUMENTS);
|
const [activeTab, setActiveTab] = useState<TabID>(TabID.ARGUMENTS);
|
||||||
const { canSubmit, hint } = (() => {
|
const { canSubmit, hint } = (() => {
|
||||||
if (!methods.formState.isValid) {
|
if (!alias) {
|
||||||
return { canSubmit: false, hint: hintMsg.formInvalid };
|
|
||||||
} else if (!alias) {
|
|
||||||
return { canSubmit: false, hint: hintMsg.aliasEmpty };
|
return { canSubmit: false, hint: hintMsg.aliasEmpty };
|
||||||
} else if (manager.oss.operations.some(operation => operation.alias === alias)) {
|
} else if (manager.oss.operations.some(operation => operation.alias === alias)) {
|
||||||
return { canSubmit: false, hint: hintMsg.schemaAliasTaken };
|
return { canSubmit: false, hint: hintMsg.schemaAliasTaken };
|
||||||
|
} else if (!methods.formState.isValid) {
|
||||||
|
return { canSubmit: false, hint: hintMsg.formInvalid };
|
||||||
} else {
|
} else {
|
||||||
return { canSubmit: true, hint: '' };
|
return { canSubmit: true, hint: '' };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ export function DlgEditOperation() {
|
||||||
header='Редактирование операции'
|
header='Редактирование операции'
|
||||||
submitText='Сохранить'
|
submitText='Сохранить'
|
||||||
canSubmit={canSubmit}
|
canSubmit={canSubmit}
|
||||||
validationHint={hintMsg.formInvalid}
|
validationHint={canSubmit ? '' : hintMsg.formInvalid}
|
||||||
onSubmit={event => void methods.handleSubmit(onSubmit)(event)}
|
onSubmit={event => void methods.handleSubmit(onSubmit)(event)}
|
||||||
className='w-160 px-6 h-128'
|
className='w-160 px-6 h-128'
|
||||||
helpTopic={HelpTopic.UI_SUBSTITUTIONS}
|
helpTopic={HelpTopic.UI_SUBSTITUTIONS}
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ export function DlgImportSchema() {
|
||||||
const alias = useWatch({ control: control, name: 'item_data.alias' });
|
const alias = useWatch({ control: control, name: 'item_data.alias' });
|
||||||
const clone_source = useWatch({ control: control, name: 'clone_source' });
|
const clone_source = useWatch({ control: control, name: 'clone_source' });
|
||||||
const { canSubmit, hint } = (() => {
|
const { canSubmit, hint } = (() => {
|
||||||
if (!isValid) {
|
if (!alias) {
|
||||||
return { canSubmit: false, hint: hintMsg.formInvalid };
|
|
||||||
} else if (!alias) {
|
|
||||||
return { canSubmit: false, hint: hintMsg.aliasEmpty };
|
return { canSubmit: false, hint: hintMsg.aliasEmpty };
|
||||||
} else if (manager.oss.operations.some(operation => operation.alias === alias)) {
|
} else if (manager.oss.operations.some(operation => operation.alias === alias)) {
|
||||||
return { canSubmit: false, hint: hintMsg.schemaAliasTaken };
|
return { canSubmit: false, hint: hintMsg.schemaAliasTaken };
|
||||||
|
} else if (!isValid) {
|
||||||
|
return { canSubmit: false, hint: hintMsg.formInvalid };
|
||||||
} else {
|
} else {
|
||||||
return { canSubmit: true, hint: '' };
|
return { canSubmit: true, hint: '' };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,12 @@ export function PickSubstitutions({
|
||||||
const [ignores, setIgnores] = useState<ISubstituteConstituents[]>([]);
|
const [ignores, setIgnores] = useState<ISubstituteConstituents[]>([]);
|
||||||
const filteredSuggestions =
|
const filteredSuggestions =
|
||||||
suggestions?.filter(
|
suggestions?.filter(
|
||||||
item => !ignores.find(ignore => ignore.original === item.original && ignore.substitution === item.substitution)
|
item =>
|
||||||
|
!ignores.find(
|
||||||
|
ignore =>
|
||||||
|
(ignore.original === item.original && ignore.substitution === item.substitution) ||
|
||||||
|
(ignore.original === item.substitution && ignore.substitution === item.original)
|
||||||
|
)
|
||||||
) ?? [];
|
) ?? [];
|
||||||
|
|
||||||
const substitutionData: IMultiSubstitution[] = [
|
const substitutionData: IMultiSubstitution[] = [
|
||||||
|
|
@ -201,7 +206,7 @@ export function PickSubstitutions({
|
||||||
size: 0,
|
size: 0,
|
||||||
cell: props =>
|
cell: props =>
|
||||||
props.row.original.is_suggestion ? (
|
props.row.original.is_suggestion ? (
|
||||||
<div className='max-w-fit'>
|
<div className='flex max-w-fit'>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
title='Принять предложение'
|
title='Принять предложение'
|
||||||
icon={<IconAccept size='1rem' className='icon-green' />}
|
icon={<IconAccept size='1rem' className='icon-green' />}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ export function DlgCreateCst() {
|
||||||
const alias = useWatch({ control: methods.control, name: 'alias' });
|
const alias = useWatch({ control: methods.control, name: 'alias' });
|
||||||
const cst_type = useWatch({ control: methods.control, name: 'cst_type' });
|
const cst_type = useWatch({ control: methods.control, name: 'cst_type' });
|
||||||
const { canSubmit, hint } = (() => {
|
const { canSubmit, hint } = (() => {
|
||||||
if (!methods.formState.isValid) {
|
if (!validateNewAlias(alias, cst_type, schema)) {
|
||||||
return { canSubmit: false, hint: hintMsg.formInvalid };
|
|
||||||
} else if (!validateNewAlias(alias, cst_type, schema)) {
|
|
||||||
return { canSubmit: false, hint: hintMsg.aliasInvalid };
|
return { canSubmit: false, hint: hintMsg.aliasInvalid };
|
||||||
|
} else if (!methods.formState.isValid) {
|
||||||
|
return { canSubmit: false, hint: hintMsg.formInvalid };
|
||||||
} else {
|
} else {
|
||||||
return { canSubmit: true, hint: '' };
|
return { canSubmit: true, hint: '' };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,10 @@ export function DlgCstTemplate() {
|
||||||
const { canSubmit, hint } = (() => {
|
const { canSubmit, hint } = (() => {
|
||||||
if (!cst_type) {
|
if (!cst_type) {
|
||||||
return { canSubmit: false, hint: hintMsg.templateInvalid };
|
return { canSubmit: false, hint: hintMsg.templateInvalid };
|
||||||
} else if (!methods.formState.isValid) {
|
|
||||||
return { canSubmit: false, hint: hintMsg.formInvalid };
|
|
||||||
} else if (!validateNewAlias(alias, cst_type, schema)) {
|
} else if (!validateNewAlias(alias, cst_type, schema)) {
|
||||||
return { canSubmit: false, hint: hintMsg.aliasInvalid };
|
return { canSubmit: false, hint: hintMsg.aliasInvalid };
|
||||||
|
} else if (!methods.formState.isValid) {
|
||||||
|
return { canSubmit: false, hint: hintMsg.formInvalid };
|
||||||
} else {
|
} else {
|
||||||
return { canSubmit: true, hint: '' };
|
return { canSubmit: true, hint: '' };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user