Skip to content

Commit

Permalink
F #6353: Add daily option in schedule actions (#2849)
Browse files Browse the repository at this point in the history
  • Loading branch information
jloboescalona2 committed Nov 29, 2023
1 parent 64fcab6 commit 669aa32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
},
Expand All @@ -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?.(','))
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/fireedge/src/client/constants/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 669aa32

Please sign in to comment.