All files / src/app/extensions/tacton/models/tacton-product-configuration tacton-product-configuration.helper.ts

100% Statements 11/11
95% Branches 19/20
100% Functions 10/10
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 61 62          16x       33x           90x       9x                 9x                   9x       9x       9x       9x       9x       9x      
import {
  TactonProductConfigurationGroup,
  TactonProductConfigurationParameter,
} from './tacton-product-configuration.model';
 
export class TactonProductConfigurationHelper {
  static isGroup(
    el: TactonProductConfigurationGroup | TactonProductConfigurationParameter
  ): el is TactonProductConfigurationGroup {
    return el.isGroup;
  }
 
  static isParameter(
    el: TactonProductConfigurationGroup | TactonProductConfigurationParameter
  ): el is TactonProductConfigurationParameter {
    return el.isParameter;
  }
 
  static isNumberInput(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    return (
      TactonProductConfigurationHelper.isParameter(el) &&
      el.properties.guitype === 'text' &&
      !!el.domain?.max &&
      !!el.domain?.min
    );
  }
 
  static isTextInput(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    return (
      TactonProductConfigurationHelper.isParameter(el) &&
      el.properties.guitype === 'text' &&
      !el.domain?.max &&
      !el.domain?.min
    );
  }
 
  static isImageTextButtons(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    // spell-checker: words imagetext
    return TactonProductConfigurationHelper.isParameter(el) && el.properties.guitype === 'imagetext_buttons';
  }
 
  static isSelectedImage(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    return TactonProductConfigurationHelper.isParameter(el) && el.properties.guitype === 'selected_image';
  }
 
  static isTextButtons(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    return TactonProductConfigurationHelper.isParameter(el) && el.properties.guitype === 'text_buttons';
  }
 
  static isSelectInput(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    return TactonProductConfigurationHelper.isParameter(el) && el.properties.guitype === 'dropdown';
  }
 
  static isReadOnly(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    return TactonProductConfigurationHelper.isParameter(el) && el.properties.guitype === 'readonly';
  }
 
  static isRadioInput(el: TactonProductConfigurationGroup | TactonProductConfigurationParameter): boolean {
    return TactonProductConfigurationHelper.isParameter(el) && el.properties.guitype === 'radio';
  }
}