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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
 * @file          Event panel in Event dialog
 * @author        Wong Jia Hui (jiahui.wong@3ds.com)
 */
import { DataEventCategoryName } from '../../data/data.calendar';
import { EditFieldSOP } from '../../../libappsop/editfieldsop';
import { ButtonSOP } from '../../../libappsop/buttonsop';
import { CheckboxSOP } from '../../../libappsop/checkboxsop';
import { DropDownStringListSOP } from '../../../libappsop/dropdownstringlistsop';
import { DropDownListSOP } from '../../../libappsop/dropdownlistsop';
import { DateTimeSelectorSOP } from '../../../libappsop/datetimeselectorsop';
import { PanelSOP } from '../../../libappsop/panelsop';
import { DurationSelectorSOP } from '../../../libappsop/durationselectorsop';
import { CalendarEventRepeat } from './dialog.calendarevent';
 
export interface PanelCalendarEventFields {
  Name?: string;
  Description?: string;
  Type?: string;
  Category?: DataEventCategoryName;
  ApplyToNewResources?: string;
  IsAllDay?: string;
  StartDate?: string;
  EndDate?: string;
  StartTime?: string;
  EndTime?: string;
  RecurWeeklyRepeatEvery?: string; // Recurrence weekly fields start here
  RecurWeeklyNoEndDate?: string;
  RecurWeeklyEndAfter?: string;
  RecurWeeklyEndBy?: string;
  RecurWeeklyOccurrencesToEnd?: string;
  RecurWeeklyEndByDate?: string;
}
 
export class PanelCalendarEvent extends PanelSOP {
  // Edit fields
  public readonly efName = new EditFieldSOP('edtName');
  public readonly efDescription = new EditFieldSOP('edtDescription');
 
  // Buttons
  public readonly btnOnce = new ButtonSOP('btnOnce');
  public readonly btnDaily = new ButtonSOP('btnDaily');
  public readonly btnWeekly = new ButtonSOP('btnWeekly');
  public readonly btnMonthly = new ButtonSOP('btnMonthly');
  public readonly btnYearly = new ButtonSOP('btnYearly');
 
  // Checkboxes
  public readonly cbApplyToNewResources = new CheckboxSOP('ckbApplyToNewResources');
  public readonly cbIsAllDay = new CheckboxSOP('ckbIsAllDay');
 
  // Drop down string list
  public readonly ddslType = new DropDownStringListSOP('ddslType');
 
  // Drop down list
  public readonly ddlCategory = new DropDownListSOP('ddlCategory');
 
  // Date time selector
  public readonly dsStartDate = new DateTimeSelectorSOP('dsStartDate');
  public readonly dsEndDate = new DateTimeSelectorSOP('dsEndDate');
 
  // Duration Selector
  public readonly durationSelectorStart = new DurationSelectorSOP('durStartTimeOfDay', { Hours: 0, Minutes: 0 });
  public readonly durationSelectorEnd = new DurationSelectorSOP('durEndTimeOfDay', { Hours: 0, Minutes: 0 });
 
  public constructor() {
    super('tabEvent');
  }
 
  /**
   * @override
   */
  public async switchTo(): Promise<void> {
    await super.switchTo();
    await this.efName.waitUntilPresent();
    await this.efDescription.waitUntilPresent();
    await this.btnOnce.waitUntilPresent();
    await this.btnDaily.waitUntilPresent();
    await this.btnWeekly.waitUntilPresent();
    await this.btnMonthly.waitUntilPresent();
    await this.btnYearly.waitUntilPresent();
    await this.cbApplyToNewResources.waitUntilPresent();
    await this.cbIsAllDay.waitUntilPresent();
    await this.ddslType.waitUntilPresent();
    await this.ddlCategory.waitUntilPresent();
    await this.dsStartDate.waitUntilPresent();
    await this.dsEndDate.waitUntilPresent();
    await this.durationSelectorStart.waitUntilPresent();
    await this.durationSelectorEnd.waitUntilPresent();
  }
 
  public getRepeatButton(repeat: CalendarEventRepeat): ButtonSOP {
    switch (repeat) {
      case CalendarEventRepeat.Once: {
        return this.btnOnce;
      }
      case CalendarEventRepeat.Daily: {
        return this.btnDaily;
      }
      case CalendarEventRepeat.Weekly: {
        return this.btnWeekly;
      }
      case CalendarEventRepeat.Monthly: {
        return this.btnMonthly;
      }
      case CalendarEventRepeat.Yearly: {
        return this.btnYearly;
      }
      default:
        throw Error(`Invalid Repeat button enum "${repeat}".`);
    }
  }
}