client/entity-editor/author-credit-editor/actions.js

"use strict";

require("core-js/modules/es.object.keys.js");
require("core-js/modules/es.symbol.js");
require("core-js/modules/es.array.filter.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.object.get-own-property-descriptor.js");
require("core-js/modules/web.dom-collections.for-each.js");
require("core-js/modules/es.object.get-own-property-descriptors.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.UPDATE_CREDIT_JOIN_PHRASE_VALUE = exports.UPDATE_CREDIT_DISPLAY_VALUE = exports.UPDATE_CREDIT_AUTHOR_VALUE = exports.UPDATE_AUTHOR_CREDIT = exports.TOGGLE_AUTHOR_CREDIT = exports.SHOW_AUTHOR_CREDIT_EDITOR = exports.RESET_AUTHOR_CREDIT = exports.REMOVE_EMPTY_CREDIT_ROWS = exports.REMOVE_AUTHOR_CREDIT_ROW = exports.HIDE_AUTHOR_CREDIT_EDITOR = exports.CLEAR_AUTHOR_CREDIT = exports.ADD_AUTHOR_CREDIT_ROW = void 0;
exports.addAuthorCreditRow = addAuthorCreditRow;
exports.clearAuthorCredit = clearAuthorCredit;
exports.hideAuthorCreditEditor = hideAuthorCreditEditor;
exports.removeAuthorCreditRow = removeAuthorCreditRow;
exports.removeEmptyCreditRows = removeEmptyCreditRows;
exports.resetAuthorCredit = resetAuthorCredit;
exports.showAuthorCreditEditor = showAuthorCreditEditor;
exports.toggleAuthorCredit = toggleAuthorCredit;
exports.updateAuthorCredit = updateAuthorCredit;
exports.updateCreditAuthorValue = updateCreditAuthorValue;
exports.updateCreditDisplayValue = updateCreditDisplayValue;
exports.updateCreditJoinPhraseValue = updateCreditJoinPhraseValue;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
/*
 * Copyright (C) 2020  Sean Burke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
/* eslint-disable no-console */

var ADD_AUTHOR_CREDIT_ROW = 'ADD_AUTHOR_CREDIT_ROW';
exports.ADD_AUTHOR_CREDIT_ROW = ADD_AUTHOR_CREDIT_ROW;
var REMOVE_AUTHOR_CREDIT_ROW = 'REMOVE_AUTHOR_CREDIT_ROW';
exports.REMOVE_AUTHOR_CREDIT_ROW = REMOVE_AUTHOR_CREDIT_ROW;
var UPDATE_CREDIT_AUTHOR_VALUE = 'UPDATE_CREDIT_AUTHOR_VALUE';
exports.UPDATE_CREDIT_AUTHOR_VALUE = UPDATE_CREDIT_AUTHOR_VALUE;
var UPDATE_CREDIT_DISPLAY_VALUE = 'UPDATE_CREDIT_DISPLAY_VALUE';
exports.UPDATE_CREDIT_DISPLAY_VALUE = UPDATE_CREDIT_DISPLAY_VALUE;
var UPDATE_CREDIT_JOIN_PHRASE_VALUE = 'UPDATE_CREDIT_JOIN_PHRASE_VALUE';
exports.UPDATE_CREDIT_JOIN_PHRASE_VALUE = UPDATE_CREDIT_JOIN_PHRASE_VALUE;
var SHOW_AUTHOR_CREDIT_EDITOR = 'SHOW_AUTHOR_CREDIT_EDITOR';
exports.SHOW_AUTHOR_CREDIT_EDITOR = SHOW_AUTHOR_CREDIT_EDITOR;
var HIDE_AUTHOR_CREDIT_EDITOR = 'HIDE_AUTHOR_CREDIT_EDITOR';
exports.HIDE_AUTHOR_CREDIT_EDITOR = HIDE_AUTHOR_CREDIT_EDITOR;
var REMOVE_EMPTY_CREDIT_ROWS = 'REMOVE_EMPTY_CREDIT_ROWS';
exports.REMOVE_EMPTY_CREDIT_ROWS = REMOVE_EMPTY_CREDIT_ROWS;
var UPDATE_AUTHOR_CREDIT = 'UPDATE_AUTHOR_CREDIT';
exports.UPDATE_AUTHOR_CREDIT = UPDATE_AUTHOR_CREDIT;
var CLEAR_AUTHOR_CREDIT = 'CLEAR_AUTHOR_CREDIT';
exports.CLEAR_AUTHOR_CREDIT = CLEAR_AUTHOR_CREDIT;
var RESET_AUTHOR_CREDIT = 'RESET_AUTHOR_CREDIT';
exports.RESET_AUTHOR_CREDIT = RESET_AUTHOR_CREDIT;
var TOGGLE_AUTHOR_CREDIT = 'TOGGLE_AUTHOR_CREDIT';
exports.TOGGLE_AUTHOR_CREDIT = TOGGLE_AUTHOR_CREDIT;
var nextAuthorCreditRowId = 1;

/**
 * Produces an action indicating that a row for an additional name should be
 * added to the author credit editor. The row is assigned an ID based on an
 * incrementing variable existing on the client.
 *
 * @returns {Action} The resulting ADD_AUTHOR_CREDIT_ROW action.
 */
function addAuthorCreditRow() {
  /*
   * Prepend 'n' here to indicate a new row, and avoid conflicts with IDs of
   * existing author credit rows.
   */
  return {
    payload: "n".concat(nextAuthorCreditRowId++),
    type: ADD_AUTHOR_CREDIT_ROW
  };
}

/**
 * Produces an action indicating that the row with the provided ID should be
 * removed from the author credit editor.
 *
 * @param {number} rowId - The ID for the row to be deleted.
 * @returns {Action} The resulting REMOVE_AUTHOR_CREDIT_ROW action.
 */
function removeAuthorCreditRow(rowId) {
  return {
    payload: rowId,
    type: REMOVE_AUTHOR_CREDIT_ROW
  };
}

/**
 * Produces an action indicating that the author value for a particular name
 * within the editor should be updated with the provided value.
 *
 * @param {number} rowId - The ID of the row in the author credit editor to update.
 * @param {Author} newAuthor - The new value to be used for the author value.
 * @returns {Action} The resulting UPDATE_CREDIT_AUTHOR_VALUE action.
 */
function updateCreditAuthorValue(rowId, newAuthor) {
  return {
    payload: _objectSpread({
      rowId: rowId
    }, newAuthor),
    type: UPDATE_CREDIT_AUTHOR_VALUE
  };
}

/**
 * Produces an action indicating that the display value for a particular name
 * within the editor should be updated with the provided value.
 *
 * @param {number} rowId - The ID of the row in the author credit editor to update.
 * @param {string} value - The new value to be used for the author display.
 * @returns {Action} The resulting UPDATE_CREDIT_DISPLAY_VALUE action.
 */
function updateCreditDisplayValue(rowId, value) {
  return {
    payload: {
      rowId: rowId,
      value: value
    },
    type: UPDATE_CREDIT_DISPLAY_VALUE
  };
}

/**
 * Produces an action indicating that the join phrase value for a particular
 * name within the editor should be updated with the provided value.
 *
 * @param {number} rowId - The ID of the row in the author credit editor to update.
 * @param {string} value - The new value to be used for the join phrase.
 * @returns {Action} The resulting UPDATE_CREDIT_JOIN_PHRASE_VALUE action.
 */
function updateCreditJoinPhraseValue(rowId, value) {
  return {
    payload: {
      rowId: rowId,
      value: value
    },
    type: UPDATE_CREDIT_JOIN_PHRASE_VALUE
  };
}

/**
 * Produces an action indicating that the Author Credit editor popup should be shown
 *
 * @returns {Action} The resulting SHOW_AUTHOR_CREDIT_EDITOR action.
 */
function showAuthorCreditEditor() {
  return {
    type: SHOW_AUTHOR_CREDIT_EDITOR
  };
}

/**
 * Produces an action indicating that the Author Credit editor popup should be hidden
 *
 * @returns {Action} The resulting HIDE_AUTHOR_CREDIT_EDITOR action.
 */
function hideAuthorCreditEditor() {
  return {
    type: HIDE_AUTHOR_CREDIT_EDITOR
  };
}

/**
 * Produces an action indicating that triggers the removal of empty items in the Author Credit
 *
 * @returns {Action} The resulting REMOVE_EMPTY_CREDIT_ROWS action.
 */
function removeEmptyCreditRows() {
  return {
    type: REMOVE_EMPTY_CREDIT_ROWS
  };
}

/**
 * Produces an action indicating an existing Author Credit has been selected.
 * Used only on the Edition merge page
 *
 * @param {number} authorCredit - The selected existing Author Credit
 * @returns {Action} The resulting UPDATE_AUTHOR_CREDIT action.
 */
function updateAuthorCredit(authorCredit) {
  return {
    payload: authorCredit,
    type: UPDATE_AUTHOR_CREDIT
  };
}

/**
 * @returns {Action} The resulting CLEAR_AUTHOR_CREDIT action.
 */
function clearAuthorCredit() {
  return {
    type: CLEAR_AUTHOR_CREDIT
  };
}

/**
 * @returns {Action} The resulting RESET_AUTHOR_CREDIT action.
 */
function resetAuthorCredit() {
  return {
    type: RESET_AUTHOR_CREDIT
  };
}

/**
 *  Produces an action indicating that the AC checkbox should be toggled.
 *
 * @returns {Action} The resulting TOGGLE_AUTHOR_CREDIT action.
 */
function toggleAuthorCredit() {
  return {
    type: TOGGLE_AUTHOR_CREDIT
  };
}
//# sourceMappingURL=actions.js.map