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
import { ListSOP } from '../../libappsop/listsop';
import { FormSOP } from '../../libappsop/formsop';
import { DialogUnitOfMeasure } from '../dialogs/dialog.unitofmeasure';
 
/**
 * Units of Measure form.
 */
export class FormUnitsOfMeasure extends FormSOP {
  public listUnitsOfMeasure = new ListUnitsOfMeasure();
 
  public constructor() {
    super('FormUOM');
  }
}
 
/**
 * UoM list in Units of Measure form.
 */
class ListUnitsOfMeasure extends ListSOP<DialogUnitOfMeasure, ListUnitsOfMeasureColumn> {
  public constructor() {
    super('ListUOM', new DialogUnitOfMeasure());
 
    // Set primary key column name(s), to display in error message when assert fails
    this.rowPrimaryColumnNames = {Name: ''};
  }
 
  /**
   * Verify first row is default UoM (bold text for Name column) while the other rows are non-bold.
   *
   * @param defaultUoMName Default UoM name to verify the first row.
   */
  public async verifyFirstRowDefaultUoM(defaultUoMName: string): Promise<void> {
    const totalRows = await this.getRowCount();
    for (let x = 0; x < totalRows; x++) {
      const row = await this.getRowByIndex(x);
      // Verify 1st row is the default UoM and bold
      if (x === 0) {
        await this.verifyRowValues(row, {Name: defaultUoMName});
        await this.verifyRowCellBold(row, {Name: 'true'});
      } else {
        // Non-default UoM is NOT bold
        await this.verifyRowCellBold(row, {Name: 'false'});
      }
    }
  }
}
 
export interface ListUnitsOfMeasureColumn {
  Name?: string;
  ImgIsDefault?: string;
}
 
const listUnitsOfMeasureContextMenuItem = {
  Create: { ContextMenu: 'listContextMenuUOM', Name: 'MenuCreate', Label: 'Create' },
  Edit: { ContextMenu: 'listContextMenuUOM', Name: 'MenuEdit', Label: 'Edit' },
  SetAsDefault: { ContextMenu: 'listContextMenuUOM', Name: 'MenuSetAsDefault', Label: 'Set as default' },
};
 
export { listUnitsOfMeasureContextMenuItem as ListUnitsOfMeasureContextMenuItem };