client/unified-form/action.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.OPEN_ENTITY_MODAL = exports.LOAD_EDITION = exports.DUMP_EDITION = exports.CLOSE_ENTITY_MODAL = void 0;
exports.closeEntityModal = closeEntityModal;
exports.dumpEdition = dumpEdition;
exports.loadEdition = loadEdition;
exports.openEntityModal = openEntityModal;
var DUMP_EDITION = 'DUMP_EDITION';
exports.DUMP_EDITION = DUMP_EDITION;
var LOAD_EDITION = 'LOAD_EDITION';
exports.LOAD_EDITION = LOAD_EDITION;
var OPEN_ENTITY_MODAL = 'OPEN_ENTITY_MODAL';
exports.OPEN_ENTITY_MODAL = OPEN_ENTITY_MODAL;
var CLOSE_ENTITY_MODAL = 'CLOSE_ENTITY_MODAL';
exports.CLOSE_ENTITY_MODAL = CLOSE_ENTITY_MODAL;
var nextEditionId = 0;

/**
 * Produces an action indicating that current edition state should be saved in `Editions`.
 *
 * @param {string} type - type of new entity which caused dump
 * @returns {Action} The resulting DUMP_EDITION action.
 */
function dumpEdition(type) {
  return {
    payload: {
      id: "e".concat(nextEditionId),
      type: type,
      value: null
    },
    type: DUMP_EDITION
  };
}

/**
 * Produces an action indicating that particular edition state having that id
 * should be loaded from `Editions`.
 *
 * @param {string} editionId - id of edition to load
 * @returns {Action} The resulting LOAD_EDITION action.
 */
function loadEdition() {
  var editionId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'e0';
  return {
    payload: {
      id: editionId
    },
    type: LOAD_EDITION
  };
}

/**
 * Set entity modal state to open
 *
 * @returns {Action} The resulting OPEN_ENTITY_MODAL action.
 */
function openEntityModal() {
  return {
    type: OPEN_ENTITY_MODAL
  };
}

/**
 * Set entity modal state to close
 *
 * @returns {Action} The resulting CLOSE_ENTITY_MODAL action.
 */
function closeEntityModal() {
  return {
    type: CLOSE_ENTITY_MODAL
  };
}
//# sourceMappingURL=action.js.map