autoCompleteDefinitions() {
    if (
      this.timeType === TimeTypes.distance ||
      this.definitions.length === 0 ||
      (this.definitions.length === 1 && this.definitions[0].shiftType === ShiftTypes.predefined)
    ) {
      return;
    }

    const shiftsArray = Object.keys(ShiftTypes);
    let smallestDefinedShift = -1;
    for (const [i, element] of shiftsArray.entries()) {
      if (this.constructor.SKIP_FOR_DISTANCE_TO_SCHEDULE_CONVERSION.includes(ShiftTypes[element])) {
        continue;
      }

      for (let j = 0; j < this.definitions.length; j++) {
        if (this.definitions[j].shiftType === ShiftTypes[element]) {
          smallestDefinedShift = i;
          break;
        }
      }
    }

    if (smallestDefinedShift === -1) {
      return;
    }

    const currentTime = new Date();

    for (const [i, element] of shiftsArray.entries()) {
      if (this.constructor.SKIP_FOR_DISTANCE_TO_SCHEDULE_CONVERSION.includes(ShiftTypes[element])) {
        continue;
      }

      let shiftFound = false;
      for (let j = 0; j < this.definitions.length; j++) {
        if (this.definitions[j].shiftType === ShiftTypes[element]) {
          shiftFound = true;
          break;
        }
      }

      if (!shiftFound) {
        if (i > smallestDefinedShift) {
          if (this.timeType === TimeTypes.scheduleRepeat) {
            this.definitions.push({ amount: Number.parseInt(OhUtils.ANY_VALUE, 10), shiftType: ShiftTypes[element] });
          } else {
            this.definitions.push({
              amount: this.constructor.DEFINITION_FUNCTIONS[element].getFunc(currentTime),
              shiftType: ShiftTypes[element]
            });
          }
        } else {
          this.definitions.push({
            amount: RecurrenceShifts[element] === undefined ? 0 : RecurrenceShifts[element].minValue,
            shiftType: ShiftTypes[element]
          });
        }
      }
    }
  }
/**
   * Automatically defines the shift types which were not previously defined. Not applicable for time distances.
   * For schedules - finds the smallest defined shift type (e.g. hours) and sets all smaller
   * shift types to the min value (typically zeroes), so "3 hours" is converted to "3 hours, 0 monutes, 0 seconds".
   * The greater shift types (for example, days, months, years) are set to "any" value for recurrent schedules
   * (e.g. "any year, any month, any day, 3 hours, 0 minutes, 0 seconds")
   * or the the current time for one-shot schedule
   * (for example, "2020 year, May, 30 day, 3 hours, 0 minutes, 0 seconds")
   */
Automatically defines the shift types which were not previously defined. Not applicable for time distances.
For schedules - finds the smallest defined shift type  and sets all smaller
shift types to the min value (typically zeroes), so "3 hours" is converted to "3 hours, 0 monutes, 0 seconds".
The greater shift types (for example, days, months, years) are set to "any" value for recurrent schedules

or the the current time for one-shot schedule
(for example, "2020 year, May, 30 day, 3 hours, 0 minutes, 0 seconds")
Automatically defines the shift types which were not previously defined . Not applicable for time distances . For schedules - finds the smallest defined shift type and sets all smaller shift types to the min value ( typically zeroes ) so " 3 hours " is converted to " 3 hours 0 monutes 0 seconds " . The greater shift types ( for example days months years ) are set to " any " value for recurrent schedules or the the current time for one - shot schedule ( for example " 2020 year May 30 day 3 hours 0 minutes 0 seconds " )
autoCompleteDefinitions() {
    if (
      this.timeType === TimeTypes.distance ||
      this.definitions.length === 0 ||
      (this.definitions.length === 1 && this.definitions[0].shiftType === ShiftTypes.predefined)
    ) {
      return;
    }
    const shiftsArray = Object.keys(ShiftTypes);
    let smallestDefinedShift = -1;
    for (const [i, element] of shiftsArray.entries()) {
      if (this.constructor.SKIP_FOR_DISTANCE_TO_SCHEDULE_CONVERSION.includes(ShiftTypes[element])) {
        continue;
      }
      for (let j = 0; j < this.definitions.length; j++) {
        if (this.definitions[j].shiftType === ShiftTypes[element]) {
          smallestDefinedShift = i;
          break;
        }
      }
    }
    if (smallestDefinedShift === -1) {
      return;
    }
    const currentTime = new Date();
    for (const [i, element] of shiftsArray.entries()) {
      if (this.constructor.SKIP_FOR_DISTANCE_TO_SCHEDULE_CONVERSION.includes(ShiftTypes[element])) {
        continue;
      }
      let shiftFound = false;
      for (let j = 0; j < this.definitions.length; j++) {
        if (this.definitions[j].shiftType === ShiftTypes[element]) {
          shiftFound = true;
          break;
        }
      }
      if (!shiftFound) {
        if (i > smallestDefinedShift) {
          if (this.timeType === TimeTypes.scheduleRepeat) {
            this.definitions.push({ amount: Number.parseInt(OhUtils.ANY_VALUE, 10), shiftType: ShiftTypes[element] });
          } else {
            this.definitions.push({
              amount: this.constructor.DEFINITION_FUNCTIONS[element].getFunc(currentTime),
              shiftType: ShiftTypes[element]
            });
          }
        } else {
          this.definitions.push({
            amount: RecurrenceShifts[element] === undefined ? 0 : RecurrenceShifts[element].minValue,
            shiftType: ShiftTypes[element]
          });
        }
      }
    }
  }
autoCompleteDefinitions ( ) { if ( this . timeType === TimeTypes . distance || this . definitions . length === 0 || ( this . definitions . length === 1 && this . definitions [ 0 ] . shiftType === ShiftTypes . predefined ) ) { return ; } const shiftsArray = Object . keys ( ShiftTypes ) ; let smallestDefinedShift = - 1 ; for ( const [ i , element ] of shiftsArray . entries ( ) ) { if ( this . constructor . SKIP_FOR_DISTANCE_TO_SCHEDULE_CONVERSION . includes ( ShiftTypes [ element ] ) ) { continue ; } for ( let j = 0 ; j < this . definitions . length ; j ++ ) { if ( this . definitions [ j ] . shiftType === ShiftTypes [ element ] ) { smallestDefinedShift = i ; break ; } } } if ( smallestDefinedShift === - 1 ) { return ; } const currentTime = new Date ( ) ; for ( const [ i , element ] of shiftsArray . entries ( ) ) { if ( this . constructor . SKIP_FOR_DISTANCE_TO_SCHEDULE_CONVERSION . includes ( ShiftTypes [ element ] ) ) { continue ; } let shiftFound = false ; for ( let j = 0 ; j < this . definitions . length ; j ++ ) { if ( this . definitions [ j ] . shiftType === ShiftTypes [ element ] ) { shiftFound = true ; break ; } } if ( ! shiftFound ) { if ( i > smallestDefinedShift ) { if ( this . timeType === TimeTypes . scheduleRepeat ) { this . definitions . push ( { amount : Number . parseInt ( OhUtils . ANY_VALUE , 10 ) , shiftType : ShiftTypes [ element ] } ) ; } else { this . definitions . push ( { amount : this . constructor . DEFINITION_FUNCTIONS [ element ] . getFunc ( currentTime ) , shiftType : ShiftTypes [ element ] } ) ; } } else { this . definitions . push ( { amount : RecurrenceShifts [ element ] === undefined ? 0 : RecurrenceShifts [ element ] . minValue , shiftType : ShiftTypes [ element ] } ) ; } } } }
Automatically defines the shift types which were not previously defined.
Automatically defines the shift types which were not previously defined .