chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
import { Form } from '../../e2elib/lib/src/pageobjects/form.component';
import { ListRow } from '../../e2elib/lib/src/pageobjects/list/listrow.component';
import { ListBase } from '../../libappbase/listbase';
import { DialogOperationCost } from '../dialogs/dialog.operationcost';
import { CheckboxBase } from '../../libappbase/checkboxbase';
import { QContextMenu } from '../../e2elib/lib/api/pageobjects/qcontextmenu.component';
 
export class FormOperationCost extends Form {
  public cbFilterByAccounts = new CheckboxBase('cbFilterByAccounts');
  public listOperationCost = new ListOperationCost();
 
  public constructor() {
    super('FormOperationCosts');
  }
 
  /**
   * To pass-in boolean to toggle on FilterByAccount checbox
   *
   * @param toBeToggleOn boolean to toggle on or off check box (false | true)
   */
  public async toggleFilterByAccount(toBeToggleOn: boolean): Promise<void> {
    const cbStatus = await this.cbFilterByAccounts.isChecked();
    if (cbStatus !== toBeToggleOn) {
      await this.cbFilterByAccounts.click();
    }
  }
}
 
export class ListOperationCost extends ListBase {
  private readonly _cmMenu = new QContextMenu('lsContextMenuAccCosts');
  public dlgOperationCost = new DialogOperationCost();
 
  public constructor() {
    super('lsAccountCosts');
  }
 
  public async getOperationCostRowCount(): Promise<number> {
    return this.getRowCount();
  }
 
  public async getAllOperationCostRows(): Promise<ListRow[]> {
    return this.getAllRows();
  }
 
  /**
   * To verify is all pass-in operation cost rows is matched with expected values
   *
   * @param rowsToMatchValues OperationCost rows that need to satisfy expected values
   * @param expectedValues A string array that store a list of string values that need to be matched
   * @param errMsg Error message if there is any row does not match expected values
   */
  public async verifyAllRowsSatisfyColumnValuesByUnit(rowsToMatchValues: ListRow[], expectedValues: string[]): Promise<boolean> {
    return this.rowHasValidValue(
      rowsToMatchValues,
      'Unit',
      expectedValues,
    );
  }
 
  /**
   * Open create edit operation cost dialog in the list
   *
   * @param row Row of operation cost to edit, create dialog will be triggered if this is undefined
   * @param isCopy Indicate to open the dialog for copy or edit, defaulted to false (edit)
   */
  public async openCreateEditUnitCostDialog(row?: ListRow, isCopy: boolean = false): Promise<void> {
    if (row !== undefined) {
      if (isCopy) {
        await row.rightClick(undefined, this._cmMenu, 'MenuCopy');
      } else {
        await row.rightClick(undefined, this._cmMenu, 'MenuEdit');
      }
    } else {
      await this.rightClick(undefined, this._cmMenu, 'MenuCreate');
    }
    await this.dlgOperationCost.waitUntilPresent();
  }
}
 
export enum ListColumnOperationCost {
  Unit = 'Unit',
  Operation = 'Operation',
  Account = 'Account',
  CostDriver = 'Cost driver',
  Cost = 'Cost',
  UoM = 'UoM',
  Start = 'Start',
  End = 'End',
}