diff --git a/html/pfappserver/root/src/globals/pfActions.js b/html/pfappserver/root/src/globals/pfActions.js index 3a2d326564b..7272bf825c9 100644 --- a/html/pfappserver/root/src/globals/pfActions.js +++ b/html/pfappserver/root/src/globals/pfActions.js @@ -186,7 +186,6 @@ const pfActionSchema = yup.object({ value: yup.string() .when('type', type => { switch (true) { - case !type: case type === 'set_role': case pfActions[type].types.includes(fieldType.NONE): case pfActions[type].types.includes(fieldType.HIDDEN): @@ -205,7 +204,7 @@ const pfActionSchema = yup.object({ // break case type === 'set_access_level': case type === 'set_access_level_by_acl_user': - return yup.array().nullable() + return yup.array().ensure() .of(yup.string().nullable()) .required(i18n.t('Level(s) required.')) // break diff --git a/html/pfappserver/root/src/views/Configuration/sources/_components/BaseRuleAction.vue b/html/pfappserver/root/src/views/Configuration/sources/_components/BaseRuleAction.vue index fea8b067c55..3822b4ab85c 100644 --- a/html/pfappserver/root/src/views/Configuration/sources/_components/BaseRuleAction.vue +++ b/html/pfappserver/root/src/views/Configuration/sources/_components/BaseRuleAction.vue @@ -38,6 +38,9 @@ const components = { BaseInputChosenOne } +import i18n from '@/utils/locale' +const sortOptions = ({text: a}, {text: b}) => i18n.t(a).localeCompare(i18n.t(b)) + import { computed, inject, nextTick, ref, unref, watch } from '@vue/composition-api' import { pfComponentType as componentType, @@ -67,6 +70,7 @@ const setup = (props, context) => { watch( // when `type` is mutated () => unref(inputValue) && unref(inputValue).type, () => { + unref(inputValue).value = undefined const { isFocus = false } = typeComponentRef.value if (isFocus) { // and `type` isFocus const { ['default']: _default } = unref(action) @@ -97,7 +101,7 @@ const setup = (props, context) => { const typeOptions = computed(() => unref(actions).map(action => { const { text, value } = action return { text, value } - })) + }).sort(sortOptions)) const valueComponent = computed(() => { if (action.value) {