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
import { EditField } from '../../e2elib/lib/src/pageobjects/editfield.component';
import { DialogBase } from '../../libappbase/dialogbase';
import { DateTimeSelectorSOP } from '../../libappsop/datetimeselectorsop';
import { DropDownListSOP } from '../../libappsop/dropdownlistsop';
import { DropDownStringListSOP } from '../../libappsop/dropdownstringlistsop';
 
export class DialogInventoryCost extends DialogBase {
  public ddlAccount = new DropDownListSOP('DropDownListAccount');
  public ddlCostDriver = new DropDownStringListSOP('DropDownStringListCostDriver');
  public ddlProduct = new DropDownListSOP('DropDownListProduct');
  public ddlStockingPoint = new DropDownListSOP('DropDownListStockingPoint');
  public dtsStart = new DateTimeSelectorSOP('DateSelectorCostStart');
  public efCost = new EditField('EditFieldCost');
 
  public constructor() {
    super('DialogCreateEditInventoryCost', 'btnOk', 'btnCancel');
  }
 
  /**
   * Update field value in the dialog.
   *
   * @param account Account field value
   * @param costDriver Cost driver field value
   * @param product Product field value
   * @param stockingPoint Stocking point field value
   * @param startDate Start field value
   * @param cost Cost field value
   */
  public async updateDialog(account?: string, costDriver?: string, product?: string, stockingPoint?: string, startDate?: Date, cost?: number): Promise<void> {
    if (account !== undefined) {
      await this.ddlAccount.selectItemSOP(account);
    }
    if (costDriver !== undefined) {
      await this.ddlCostDriver.selectItem(costDriver);
    }
    if (product !== undefined) {
      await this.ddlProduct.selectItemSOP(product);
    }
    if (stockingPoint !== undefined) {
      await this.ddlStockingPoint.selectItemSOP(stockingPoint);
    }
    if (startDate !== undefined) {
      await this.dtsStart.setDate(startDate);
    }
    if (cost !== undefined) {
      await this.efCost.sendInput(cost.toString());
    }
  }
 
  /**
   * OK button is enabled, click on it to close dialog.
   *
   * @returns True = button is enabled; False = button is disabled.
   */
  public async closeDialog(): Promise<boolean> {
    const canClickOK = await this.clickOK();
    return canClickOK;
  }
}