All files / my/targetDefinition targetDefinition.js

61.11% Statements 11/18
100% Branches 5/5
63.64% Functions 7/11
58.82% Lines 10/17

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 63 64 65 66 67 68 69 70 71 72 73            2x 2002x             286x 286x 286x                                   110x       132x       88x                                 1430x             418x            
/*
 * Copyright (c) 2021, salesforce.com, inc.
 * All rights reserved.
 * Licensed under the BSD 3-Clause license.
 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
 */
import { api, LightningElement } from 'lwc';
export default class TargetDefinition extends LightningElement {
  @api
  target;
 
  enabled;
 
  connectedCallback() {
    this.enableSmall = this.isSmallFormFactorSupported;
    this.enableLarge = this.isFormFactorSupported;
    this.enabled = false;
  }
 
  onChangeLargeCheckbox = (e) => {
    this.enableLarge = e.target.checked;
    this.onChange();
  };
  onChangeSmallCheckbox = (e) => {
    this.enableSmall = e.target.checked;
    this.onChange();
  };
 
  onChangeTargetCheckbox = (e) => {
    this.enabled = e.target.checked;
    this.onChange();
  };
 
  get disableDeviceCheck() {
    return !this.enabled;
  }
 
  get largeFormId() {
    return `${this.target.value}-form-large`;
  }
 
  get smallFormId() {
    return `${this.target.value}-form-small`;
  }
 
  onChange = () => {
    this.dispatchEvent(
      new CustomEvent('changetarget', {
        detail: {
          target: this.target,
          enabled: this.enabled,
          small: this.enableSmall,
          large: this.enableLarge
        }
      })
    );
  };
 
  get isFormFactorSupported() {
    return (
      this.target.value === 'lightning__AppPage' ||
      this.target.value === 'lightning__RecordPage' ||
      this.target.value === 'lightning__HomePage'
    );
  }
  get isSmallFormFactorSupported() {
    return (
      this.target.value === 'lightning__AppPage' ||
      this.target.value === 'lightning__RecordPage'
    );
  }
}