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
import { PanelBase } from '../../libappbase/panelbase';
import { DialogSOP } from '../../libappsop/dialogsop';
import { DropDownListSOP } from '../../libappsop/dropdownlistsop';
import { EditFieldSOP } from '../../libappsop/editfieldsop';
import { DateTimeSelectorSOP } from '../../libappsop/datetimeselectorsop';
import { CheckboxSOP } from '../../libappsop/checkboxsop';
import { RadioButtonSOP } from '../../libappsop/radiobuttonsop';
 
export interface DialogUnitFields {
  Name?: string;
  Parent?: string;
  CapacityType?: string;
  StartEnabled?: string;
  Start?: string;
  EndEnabled?: string;
  End?: string;
  // Advanced tab fields
  BatchEditShiftPatternOpt?: string;
  ShiftPatternOpt?: string;
}
 
export class DialogUnit extends DialogSOP<DialogUnitFields> {
  public static readonly title = 'Unit';
 
  public ddlParent = new DropDownListSOP('selParentUnit');
  public efName = new EditFieldSOP('EditFieldName');
  public rbgCapacityType = new RadioButtonSOP('RadioButtonGroupCapacityType');
  public pnlGeneral = new PanelBase('PanelGeneral');
  public pnlAdvanced = new PanelBase('PanelAdvanced');
  public cbHasStart = new CheckboxSOP('CheckboxHasStart');
  public cbHasEnd = new CheckboxSOP('CheckboxHasEnd');
  public dtsStart = new DateTimeSelectorSOP('dsStart');
  public dtsEnd = new DateTimeSelectorSOP('dsEnd');
  // Advanced tab fields
  public cbBatchEditShiftPatternOpt = new CheckboxSOP('CheckBoxBatchEditUseShiftPatternOptimization');
  public cbShiftPatternOpt = new CheckboxSOP('CheckboxUseShiftPatternOptimization');
 
  public constructor() {
    super('DialogCreateEditUnit');
 
    // 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.efName);
    this._uiMap.set('Parent', this.ddlParent);
    this._uiMap.set('CapacityType', this.rbgCapacityType);
    this._uiMap.set('StartEnabled', this.cbHasStart);
    this._uiMap.set('Start', this.dtsStart);
    this._uiMap.set('EndEnabled', this.cbHasEnd);
    this._uiMap.set('End', this.dtsEnd);
    // Advanced tab fields
    this._uiMap.set('BatchEditShiftPatternOpt', this.cbBatchEditShiftPatternOpt);
    this._uiMap.set('ShiftPatternOpt', this.cbShiftPatternOpt);
  }
}
 
/**
 * Expected tooltip for OK button when disabled.
 */
export const okButtonDisabledTooltip = {
  // Partial prefix indicates precondition defined partially thus use partial match when verifying.
  partialEndLaterThanStart: (startDate: string, endDate: string): string => `End (${endDate}) must be later than start (${startDate}).`,
};