renhao
2023-09-21 1aa9f2bb83dd9e4b7517f1cbf06b0db53979bb31
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
import { PanelBase } from '../../libappbase/panelbase';
import { ButtonSOP } from '../../libappsop/buttonsop';
import { CheckboxSOP } from '../../libappsop/checkboxsop';
import { DialogSOP } from '../../libappsop/dialogsop';
import { DropDownListSOP } from '../../libappsop/dropdownlistsop';
import { RadioButtonSOP } from '../../libappsop/radiobuttonsop';
 
export interface DialogSmartPlanFields {
  BtnSavePreferencesEnabled?: string;
  BtnRestoreDefaultEnabled?: string;
  Strategy?: string;
  OverrideLockedPlan?: string;
  LimitUnits?: string;
  OnlyPlanOneStepUpstream?: string;
  SmartPlanDirection?: string;
}
 
export class DialogSmartPlan extends DialogSOP<DialogSmartPlanFields> {
  public static readonly title = 'Smart Plan';
  public static readonly btnSavePreferences = 'Save my preferences';
  public static readonly btnRestoreDafault = 'Restore default';
  public pnlAdvanced = new PanelBase('PanelAdvaned');
  public btnSavePreferences = new ButtonSOP('btnSavePreferences');
  public btnRestoreDefault = new ButtonSOP('btnRestoreDefault');
  public ddlStrategy = new DropDownListSOP('DropDownListStrategy');
  public cbOverrideLockedPlan = new CheckboxSOP('CheckboxOverrideManual');
  public cbLimitUnits = new CheckboxSOP('CheckboxIsSelectedUnits');
  public cbOnlyPlanOneStepUpstream = new CheckboxSOP('CheckboxOnlyPlanOneStepUpstream');
  public rbSmartPlanDirection = new RadioButtonSOP('RadioButtonGroupSmartPlanDirection');
 
  public constructor() {
    super('DialogSmartPlan', 'btnOK', 'btnCancel');
 
    // 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('BtnSavePreferencesEnabled', this.btnSavePreferences);
    this._uiMap.set('BtnRestoreDefaultEnabled', this.btnRestoreDefault);
    this._uiMap.set('Strategy', this.ddlStrategy);
    this._uiMap.set('OverrideLockedPlan', this.cbOverrideLockedPlan);
    this._uiMap.set('LimitUnits', this.cbLimitUnits);
    this._uiMap.set('SmartPlanDirection', this.rbSmartPlanDirection);
    this._uiMap.set('OnlyPlanOneStepUpstream', this.cbOnlyPlanOneStepUpstream);
  }
 
  /**
   * Open Advanced panel, select Smart Plan direction and click Ok button
   *
   * @param smartPlanDirection Smart Plan direction value to be selected
   */
  public async selectSmartPlanDirection(smartPlanDirection: string): Promise<void> {
    await this.pnlAdvanced.switchTo();
    await this.rbSmartPlanDirection.checkOnRadioButton(smartPlanDirection);
    await this.clickOK();
  }
}
 
export enum DialogSmartPlanDirectionRadioButton {
  Upstream = 'Upstream',
  Downstream = 'Downstream',
  MiddleOut = 'Middle-out',
}