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
import { Form } from '../../e2elib/lib/src/pageobjects/form.component';
import { MatrixEditorSOP } from '../../libappsop/matrixeditorsop';
import { QUtils } from '../../e2elib/lib/src/main/qutils.class';
import { DialogSmartPlan } from '../dialogs/dialog.smartplan';
import { DataMatrixProductPlanningAttributeName } from '../data/data.supplyplanning';
 
export class FormProductPlanning extends Form {
  public meProductPlanning = new MatrixEditorProductPlanning();
 
  public constructor() {
    super('FormPlanning');
  }
 
  /**
   * Get background color of demand cell for the product in the period
   *
   * @param productID Product name or index of row
   * @param date Date in string format: dd-Mon-yyyy eg: 1-Jan-2020
   */
  public async getDemandBackgroundColor(productID: string | number, date: string): Promise<string> {
    const cell = await this.meProductPlanning.getCell(productID, DataMatrixProductPlanningAttributeName.TotalDemand, date);
    return QUtils.getCssStyle(cell.element, 'background-color');
  }
}
 
export class MatrixEditorProductPlanning extends MatrixEditorSOP<DialogSmartPlan> {
  public static readonly title = 'Product plannings';
 
  public constructor() {
    super('MatrixEditorProductPlanning', 'matrixeditorContextMenuProductPlanning', new DialogSmartPlan());
  }
 
  /**
   * Set total supply value on the specific cell
   *
   * @param rowID Product name or index of row
   * @param date Date in string format: dd-Mon-yyyy eg: 1-Jan-2020 - Column
   * @param value Value to be set
   */
  public async setTotalSupply(rowID: string | number, date: string, value: number): Promise<void> {
    const cell = await this.getCell(rowID, DataMatrixProductPlanningAttributeName.TotalSupply, date);
    await cell.sendInput(value.toString());
  }
 
  /**
   * Open and return Smart Plan dialog by rightclick on desired cell and choosing Smart Plan context menu item
   *
   * @param rowID Product name or index of row
   * @param date Date in string format: dd-Mon-yyyy eg: 1-Jan-2020
   * @returns Dialog Smart Plan
   */
  public async startSettingSmartPlanDirection(rowID: string | number, date: string): Promise<DialogSmartPlan> {
    const [dlg] = await this.rightClickCellSelectContextmenu(MatrixEditorProductPlanningContextMenuItem.SmartPlan, rowID, DataMatrixProductPlanningAttributeName.TotalSupply, date);
    return dlg;
  }
}
 
export enum MatrixEditorProductPlanningContextMenuItem {
  SmartPlan = 'MenuSmartPlan',
}