1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #6353: Add daily option in schedule actions (#2849)

This commit is contained in:
Jorge Miguel Lobo Escalona 2023-11-29 15:38:37 +01:00 committed by GitHub
parent 64fcab6b0d
commit 669aa32dd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 4 deletions

View File

@ -283,13 +283,24 @@ const WEEKLY_FIELD = {
addEmpty: false,
getValue: (_, index) => String(index),
}),
fieldProps: ([_, repeat] = [], form) => {
if (repeat === REPEAT_VALUES.DAILY) {
const allDays = Array.from(
{ length: DAYS_OF_WEEK.length },
(__, index) => `${index}`
)
form?.setValue('WEEKLY', allDays)
}
},
htmlType: (_, context) => {
const values = context?.getValues() || {}
return (
!(
values?.PERIODIC === SCHEDULE_TYPE.PERIODIC &&
values?.REPEAT === REPEAT_VALUES.WEEKLY
(values?.REPEAT === REPEAT_VALUES.WEEKLY ||
values?.REPEAT === REPEAT_VALUES.DAILY)
) && INPUT_TYPES.HIDDEN
)
},
@ -298,9 +309,10 @@ const WEEKLY_FIELD = {
.min(1)
.default(() => context?.[DAYS_FIELD.name]?.split?.(',') ?? [])
.when(REPEAT_FIELD.name, (repeatType, schema) =>
repeatType !== REPEAT_VALUES.WEEKLY
? schema.strip()
: schema.required(T.DaysBetween0_6)
repeatType === REPEAT_VALUES.WEEKLY ||
repeatType === REPEAT_VALUES.DAILY
? schema.required(T.DaysBetween0_6)
: schema.strip()
)
.afterSubmit((value) => value?.join?.(','))
),

View File

@ -100,6 +100,10 @@ const commonTransformBeforeSubmit = (formData) => {
scheduleAction.END_VALUE = END_VALUE
scheduleAction.REPEAT = REPEAT
switch (REPEAT) {
case REPEAT_VALUES.DAILY:
scheduleAction.REPEAT = REPEAT_VALUES.WEEKLY
scheduleAction.DAYS = WEEKLY
break
case REPEAT_VALUES.WEEKLY:
scheduleAction.DAYS = WEEKLY
break

View File

@ -56,6 +56,7 @@ export const END_TYPE_VALUES = {
/** @enum {string} Values to repeat an action */
export const REPEAT_VALUES = {
DAILY: '-1',
WEEKLY: '0',
MONTHLY: '1',
YEARLY: '2',