yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
 * @file          Event Dialog
 * @author        Wong Jia Hui (jiahui.wong@3ds.com)
 */
import { ButtonSOP } from '../../../libappsop/buttonsop';
import { DialogSOP } from '../../../libappsop/dialogsop';
import { PanelCalendarEventFields, PanelCalendarEvent } from './panel.calendarevent';
import { PanelRecurrenceWeekly } from './panel.recurrenceweekly';
 
export class DialogCalendarEvent extends DialogSOP<PanelCalendarEventFields> {
  public static readonly title = 'Calendar event';
  public pnlCalendarEvent = new PanelCalendarEvent();
  public pnlRecurrenceWeekly = new PanelRecurrenceWeekly();
  public readonly btnCustomizeRepetition = new ButtonSOP('btnCustomize');
 
  public constructor() {
    super('LibCal_dlgEvent', 'btnOK');
 
    // Set UI element mapping to pair the UI name to the UI element for use in DialogSOP to find the UI object to set value or verify value
    // This prevents each new Dialog to duplicate code just to set/verify UI element value
    this._uiMap.set('Name', this.pnlCalendarEvent.efName);
    this._uiMap.set('Description', this.pnlCalendarEvent.efDescription);
    this._uiMap.set('ApplyToNewResources', this.pnlCalendarEvent.cbApplyToNewResources);
    this._uiMap.set('IsAllDay', this.pnlCalendarEvent.cbIsAllDay);
    this._uiMap.set('Type', this.pnlCalendarEvent.ddslType);
    this._uiMap.set('Category', this.pnlCalendarEvent.ddlCategory);
    this._uiMap.set('StartDate', this.pnlCalendarEvent.dsStartDate);
    this._uiMap.set('EndDate', this.pnlCalendarEvent.dsEndDate);
    this._uiMap.set('StartTime', this.pnlCalendarEvent.durationSelectorStart);
    this._uiMap.set('EndTime', this.pnlCalendarEvent.durationSelectorEnd);
 
    // Repetition weekly
    this._uiMap.set('RecurWeeklyRepeatEvery', this.pnlRecurrenceWeekly.efRepeatFrequency);
    this._uiMap.set('RecurWeeklyNoEndDate', this.pnlRecurrenceWeekly.cbNoEndDate);
    this._uiMap.set('RecurWeeklyEndAfter', this.pnlRecurrenceWeekly.cbEndAfter);
    this._uiMap.set('RecurWeeklyEndBy', this.pnlRecurrenceWeekly.cbEndBy);
    this._uiMap.set('RecurWeeklyOccurrencesToEnd', this.pnlRecurrenceWeekly.efNrOfOccurrencesToEnd);
    this._uiMap.set('RecurWeeklyEndByDate', this.pnlRecurrenceWeekly.dtsRecurrenceEndDate);
  }
 
  /**
   * Click on Customize repetition button to expand/collapse. A panel is shown to customize repetition in more details.
   */
  public async clickCustomizeRepetition(): Promise<void> {
    await this.btnCustomizeRepetition.click();
  }
 
  /**
   * Click on the correct Repeat button for this event. As each Repeat type is a button thus we cannot utilize the usual method on dialogSOP.updateDialogvalues.
   *
   * @param repeat The repeat type for this event.
   */
  public async setEventRepeat(repeat: CalendarEventRepeat): Promise<void> {
    await this.pnlCalendarEvent.getRepeatButton(repeat).click();
  }
}
 
export enum CalendarEventRepeat {
  Once = 'Once',
  Daily = 'Daily',
  Weekly = 'Weekly',
  Monthly = 'Monthly',
  Yearly = 'Yearly',
}
 
const stepDialogCalendarEvent = {
  clickCustomizeRepetition: (): string => `In dialog ${DialogCalendarEvent.title}, click on Customize repetition button to expand the detail panel.`,
  setEventRepeat: (repeat: CalendarEventRepeat): string => `In dialog ${DialogCalendarEvent.title}, click button Repeat = ${repeat}.`,
};
 
export { stepDialogCalendarEvent as StepDialogCalendarEvent };