All files / src/lib/events eventIfCurrentSceneIs.js

0% Statements 0/13
0% Branches 0/2
0% Functions 0/2
0% Lines 0/13

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                                                                                                                                               
const l10n = require("../helpers/l10n").default;
 
const id = "EVENT_IF_CURRENT_SCENE_IS";
const groups = ["EVENT_GROUP_CONTROL_FLOW", "EVENT_GROUP_SCENE"];
const subGroups = {
  EVENT_GROUP_CONTROL_FLOW: "EVENT_GROUP_SCENE",
  EVENT_GROUP_SCENE: "EVENT_GROUP_CONTROL_FLOW",
};
 
const autoLabel = (fetchArg) => {
  return l10n("EVENT_IF_CURRENT_SCENE_IS_LABEL", {
    scene: fetchArg("sceneId"),
  });
};
 
const fields = [
  {
    key: "sceneId",
    label: l10n("SCENE"),
    type: "scene",
    defaultValue: "LAST_SCENE",
  },
  {
    key: "true",
    label: l10n("FIELD_TRUE"),
    type: "events",
  },
  {
    key: "__collapseElse",
    label: l10n("FIELD_ELSE"),
    type: "collapsable",
    defaultValue: true,
    conditions: [
      {
        key: "__disableElse",
        ne: true,
      },
    ],
  },
  {
    key: "false",
    label: l10n("FIELD_FALSE"),
    conditions: [
      {
        key: "__collapseElse",
        ne: true,
      },
      {
        key: "__disableElse",
        ne: true,
      },
    ],
    type: "events",
  },
];
 
const compile = (input, helpers) => {
  const { ifCurrentSceneIs } = helpers;
  const truePath = input.true;
  const falsePath = input.__disableElse ? [] : input.false;
  ifCurrentSceneIs(input.sceneId, truePath, falsePath);
};
 
module.exports = {
  id,
  autoLabel,
  groups,
  subGroups,
  fields,
  compile,
};