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
import { FormSOP } from '../../libappsop/formsop';
import { ListSOP } from '../../libappsop/listsop';
import { DialogPostponementSpecification, DialogPostponementSpecificationFields } from '../dialogs/dialog.postponementspecification';
 
export class FormPostponementSettings extends FormSOP {
  public listPostponementSpecifications = new ListPostponementSpecifications();
 
  public constructor() {
    super('FormPostponementSettings');
  }
}
 
export class ListPostponementSpecifications extends ListSOP<DialogPostponementSpecification, ListPostponementSpecificationsColumn> {
  public constructor() {
    super('ListPostponementSpecification', new DialogPostponementSpecification());
 
    // Set primary key column name(s), to display in error message when assert fails
    this.rowPrimaryColumnNames = {'Sales segment': ''};
  }
 
  public async create(inputValues: DialogPostponementSpecificationFields): Promise<void> {
    const [dlg] = await this.selectContextMenu(listPostponementSpecificationsContextMenuItem.Create);
    await dlg.updateDialogValues(inputValues);
    await dlg.clickOK();
  }
}
 
export interface ListPostponementSpecificationsColumn {
  'Sales segment'?: string;
  Horizon?: string;
  'Max postponement'?: string;
}
 
const listPostponementSpecificationsContextMenuItem = {
  Create: { ContextMenu: 'listContextMenuPostponementSpecification', Name: 'MenuCreate', Label: 'Create' },
};
 
export { listPostponementSpecificationsContextMenuItem as ListPostponementSpecificationsContextMenuItem };
 
// Step description to re-use in spec file to prevent scriptor re-write each time
const stepPostponementSpecification = {
  create: (fields: any): string => {
    const arr: string[] = [];
    for (const [key, value] of Object.entries(fields)) {
      arr.push(`${key} = "${value}"`);
    }
    return `Create postponement specification with values: ${arr.join(', ')}.`;
  },
};
 
export { stepPostponementSpecification as StepPostponementSpecification };