/** 
 | 
 * @file          Panel for weekly recurrence 
 | 
 * @author        Pethaperumal Natarajan (Pethaperumal.NATARAJAN.intern@3ds.com) 
 | 
 */ 
 | 
  
 | 
import { ButtonSOP } from '../../../libappsop/buttonsop'; 
 | 
import { CheckboxSOP } from '../../../libappsop/checkboxsop'; 
 | 
import { DateTimeSelectorSOP } from '../../../libappsop/datetimeselectorsop'; 
 | 
import { EditFieldSOP } from '../../../libappsop/editfieldsop'; 
 | 
import { PanelSOP } from '../../../libappsop/panelsop'; 
 | 
import { UtilSOP } from '../../../libappsop/utilsop'; 
 | 
  
 | 
export class PanelRecurrenceWeekly extends PanelSOP { 
 | 
  // Buttons 
 | 
  public readonly btnMonday = new ButtonSOP('btnMonday'); 
 | 
  public readonly btnTuesday = new ButtonSOP('btnTuesday'); 
 | 
  public readonly btnWednesday = new ButtonSOP('btnWednesday'); 
 | 
  public readonly btnThursday = new ButtonSOP('btnThursday'); 
 | 
  public readonly btnFriday = new ButtonSOP('btnFriday'); 
 | 
  public readonly btnSaturday = new ButtonSOP('btnSaturday'); 
 | 
  public readonly btnSunday = new ButtonSOP('btnSunday'); 
 | 
  
 | 
  // Edit Fields 
 | 
  public readonly efRepeatFrequency = new EditFieldSOP('edtEveryNrOfWeeks'); 
 | 
  public readonly efNrOfOccurrencesToEnd = new EditFieldSOP('edtNrOfOccurrences'); 
 | 
  
 | 
  // Checkboxes 
 | 
  public readonly cbNoEndDate = new CheckboxSOP('ckbNoEndDate'); 
 | 
  public readonly cbEndAfter = new CheckboxSOP('ckbEndAfter'); 
 | 
  public readonly cbEndBy = new CheckboxSOP('ckbEndBy'); 
 | 
  
 | 
  // Date Time Selector 
 | 
  public readonly dtsRecurrenceEndDate = new DateTimeSelectorSOP('dsEndOfPeriod'); 
 | 
  
 | 
  public constructor() { 
 | 
    super('pnlRecurrenceDetails'); 
 | 
  } 
 | 
  
 | 
  /** 
 | 
   * Click day buttons to indicate repeat on days. Pass empty array to toggle off all day buttons. 
 | 
   * 
 | 
   * @param toggleOnDays One or more day number to toggle on. 
 | 
   */ 
 | 
  public async setRepeatWeeklyOnDays(toggleOnDays: number[]): Promise<void> { 
 | 
    await this.toggleRepeatOnDayButton(this.btnMonday, toggleOnDays.includes(1)); // Checks if day index part of passed in "days", the method will correctly click button to toggle on/off 
 | 
    await this.toggleRepeatOnDayButton(this.btnTuesday, toggleOnDays.includes(2)); 
 | 
    await this.toggleRepeatOnDayButton(this.btnWednesday, toggleOnDays.includes(3)); 
 | 
    await this.toggleRepeatOnDayButton(this.btnThursday, toggleOnDays.includes(4)); 
 | 
    await this.toggleRepeatOnDayButton(this.btnFriday, toggleOnDays.includes(5)); 
 | 
    await this.toggleRepeatOnDayButton(this.btnSaturday, toggleOnDays.includes(6)); 
 | 
    await this.toggleRepeatOnDayButton(this.btnSunday, toggleOnDays.includes(0)); 
 | 
  } 
 | 
  
 | 
  private async toggleRepeatOnDayButton(btnDay: ButtonSOP, toggleOn: boolean): Promise<void> { 
 | 
    if ((await btnDay.isToggled()) !== toggleOn) { 
 | 
      await btnDay.click(); 
 | 
    } 
 | 
  } 
 | 
} 
 | 
  
 | 
const stepPanelRecurrenceWeekly = { 
 | 
  setRepeatWeeklyOnDays: (toggleOnDays: number[]): string => { 
 | 
    const action = toggleOnDays.length === 0 ? 'ensure no Repeat on days button pressed' : `ensure only Repeat on days button pressed for ${UtilSOP.getDaysString(toggleOnDays)}`; 
 | 
    return `In panel Repetition details, ${action}.`; 
 | 
  }, 
 | 
}; 
 | 
  
 | 
export { stepPanelRecurrenceWeekly as StepPanelRecurrenceWeekly }; 
 |