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
import { DropDownListSOP } from '../../../libappsop/dropdownlistsop';
import { LabelSOP } from '../../../libappsop/labelsop';
import { NumberPickerSOP } from '../../../libappsop/numberpickersop';
import { PanelSOP } from '../../../libappsop/panelsop';
 
/**
 * Panel period in left navigation panel.
 * Set the period specification to filter forms data as well as set number of past and future periods to display.
 */
export class PanelPeriod extends PanelSOP {
  public lblStartOfPlanning = new LabelSOP('LabelStartOfPlanning');
  public ddlPeriodGranularity = new DropDownListSOP('DropDownListNavPeriodSpecification');
  public nmpNumFuturePeriods = new NumberPickerSOP('NumberPickerShowFuture');
  public nmpNumHistoricalPeriods = new NumberPickerSOP('NumberPickerShowPast');
 
  public constructor() {
    super('PanelNavPeriod');
  }
 
  /**
   * Set number of future periods to be shown in the app (direct edit the number picker text field).
   *
   * @param numPeriods Number of periods to show.
   */
  public async setNumFuturePeriods(numPeriods: string): Promise<void> {
    await this.nmpNumFuturePeriods.setValue(numPeriods);
  }
 
  /**
   * Set number of historical periods to be shown in the app (direct edit the number picker text field).
   *
   * @param numPeriods Number of periods to show.
   */
  public async setNumHistoricalPeriods(numPeriods: string): Promise<void> {
    await this.nmpNumHistoricalPeriods.setValue(numPeriods);
  }
 
  /**
   * Set the period specification to be used to filter the app.
   * Use the enum provided in data.period.ts which includes the system period specification named 'Planning periods'.
   *
   * @param periodSpecification Period specification to select.
   */
  public async setPeriodGranularity(periodSpecification: string): Promise<void> {
    await this.ddlPeriodGranularity.selectItemSOP(periodSpecification);
  }
}
 
// Step description to re-use in spec file to prevent scriptor re-write each time
const stepNavigationPanelPeriod = {
  setNumFuturePeriods: (numFuturePeriods: number): string => `In left Navigation panel (Period panel), set number future periods = ${numFuturePeriods}.`,
  setNumHistoricalPeriods: (numHistoricalPeriods: number): string => `In left Navigation panel (Period panel), set number historical periods = ${numHistoricalPeriods}.`,
  setPeriodGranularity: (periodSpecName: string): string => `In left Navigation panel (Period panel), select period granularity = '${periodSpecName}'.`,
};
 
export { stepNavigationPanelPeriod as StepNavigationPanelPeriod };