client/unified-form/cover-tab/action.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.UPDATE_ISBN_VALUE = exports.UPDATE_ISBN_TYPE = exports.CLEAR_PUBLISHERS = exports.CLEAR_PUBLISHER = exports.CLEAR_AUTHOR = exports.AUTO_ISBN = exports.ADD_PUBLISHER = exports.ADD_AUTHOR = void 0;
exports.addAuthor = addAuthor;
exports.addPublisher = addPublisher;
exports.clearAuthor = clearAuthor;
exports.clearPublisher = clearPublisher;
exports.clearPublishers = clearPublishers;
exports.debouncedUpdateISBNValue = debouncedUpdateISBNValue;
exports.updateAutoISBN = updateAutoISBN;
exports.updateISBNType = updateISBNType;
var UPDATE_ISBN_VALUE = 'UPDATE_ISBN_VALUE';
exports.UPDATE_ISBN_VALUE = UPDATE_ISBN_VALUE;
var ADD_AUTHOR = 'ADD_AUTHOR';
exports.ADD_AUTHOR = ADD_AUTHOR;
var UPDATE_ISBN_TYPE = 'UPDATE_ISBN_TYPE';
exports.UPDATE_ISBN_TYPE = UPDATE_ISBN_TYPE;
var ADD_PUBLISHER = 'ADD_PUBLISHER';
exports.ADD_PUBLISHER = ADD_PUBLISHER;
var CLEAR_PUBLISHER = 'CLEAR_PUBLISHER';
exports.CLEAR_PUBLISHER = CLEAR_PUBLISHER;
var CLEAR_PUBLISHERS = 'CLEAR_PUBLISHERS';
exports.CLEAR_PUBLISHERS = CLEAR_PUBLISHERS;
var CLEAR_AUTHOR = 'CLEAR_AUTHOR';
exports.CLEAR_AUTHOR = CLEAR_AUTHOR;
var AUTO_ISBN = 'AUTO_ISBN';
exports.AUTO_ISBN = AUTO_ISBN;
var nextPublisherId = 0;
var nextAuthorId = 0;

/**
 * Produces an action indicating that new Publisher should be added in `Publishers`.
 *
 * @param {Object} value - New publisher state.
 * @returns {Action} The resulting ADD_PUBLISHER action.
 */
function addPublisher() {
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  return {
    payload: {
      id: "p".concat(nextPublisherId++),
      value: value
    },
    type: ADD_PUBLISHER
  };
}

/**
 * Produces an action indicating that newly created
 * Publisher should be removed from `Publishers`.
 *
 * @param {string} pid - Publisher id to be removed.
 * @returns {Action} The resulting CLEAR_PUBLISHER action.
 */
function clearPublisher(pid) {
  return {
    payload: pid,
    type: CLEAR_PUBLISHER
  };
}

/**
 * Produces an action indicating that all Publishers should be removed from `Publishers`.
 *
 * @returns {Action} The resulting CLEAR_PUBLISHERS action.
 */
function clearPublishers() {
  return {
    type: CLEAR_PUBLISHERS
  };
}

/**
 * Produces an action indicating that newly created
 * Author should be removed from `Authors`.
 *
 * @param {string}aid - Author id to be removed.
 * @returns {Action} The resulting CLEAR_AUTHOR action.
 */
function clearAuthor(aid) {
  return {
    payload: aid,
    type: CLEAR_AUTHOR
  };
}

/**
 * Produces an action indicating that new Author should be added in `Authors`
 * as well as in AC of Edition.
 *
 * @param {object} value - New author credit state.
 * @param {string} rowId - Row id of author credit editor.
 * @returns {Action} The resulting ADD_AUTHOR action.
 */
function addAuthor() {
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  var rowId = arguments.length > 1 ? arguments[1] : undefined;
  return {
    payload: {
      id: "a".concat(nextAuthorId++),
      rowId: rowId,
      value: value
    },
    type: ADD_AUTHOR
  };
}

/**
 * Produces an action indicating that `ISBN` value should be updated.
 *
 * @param {string} newValue - New value of ISBN Field.
 * @returns {Action} The resulting UPDATE_ISBN_VALUE action.
 */
function debouncedUpdateISBNValue(newValue) {
  return {
    meta: {
      debounce: 'keystroke'
    },
    payload: newValue,
    type: UPDATE_ISBN_VALUE
  };
}

/**
 * Produces an action indicating that `ISBN` type should be updated.
 *
 * @param {number} typeId - Type of corresponding ISBN value.
 * @returns {Action} The resulting UPDATE_ISBN_TYPE action.
 */
function updateISBNType(typeId) {
  return {
    payload: typeId,
    type: UPDATE_ISBN_TYPE
  };
}

/**
 * Produces an action indicating that `autoISBN` value should be updated.
 *
 * @param {boolean} value - New value for autoISBN.
 * @returns {Action} The resulting AUTO_ISBN action.
 */
function updateAutoISBN(value) {
  return {
    payload: value,
    type: AUTO_ISBN
  };
}
//# sourceMappingURL=action.js.map