client/entity-editor/edition-section/actions.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.UPDATE_WIDTH = exports.UPDATE_WEIGHT = exports.UPDATE_WARN_IF_EDITION_GROUP_EXISTS = exports.UPDATE_STATUS = exports.UPDATE_RELEASE_DATE = exports.UPDATE_PUBLISHER = exports.UPDATE_PAGES = exports.UPDATE_LANGUAGES = exports.UPDATE_HEIGHT = exports.UPDATE_FORMAT = exports.UPDATE_EDITION_GROUP = exports.UPDATE_DEPTH = exports.TOGGLE_SHOW_EDITION_GROUP = exports.ENABLE_PHYSICAL = exports.DISABLE_PHYSICAL = exports.ADD_LANGUAGE = void 0;
exports.addLanguage = addLanguage;
exports.debouncedUpdateDepth = debouncedUpdateDepth;
exports.debouncedUpdateHeight = debouncedUpdateHeight;
exports.debouncedUpdatePages = debouncedUpdatePages;
exports.debouncedUpdateReleaseDate = debouncedUpdateReleaseDate;
exports.debouncedUpdateWeight = debouncedUpdateWeight;
exports.debouncedUpdateWidth = debouncedUpdateWidth;
exports.disablePhysical = disablePhysical;
exports.enablePhysical = enablePhysical;
exports.toggleShowEditionGroup = toggleShowEditionGroup;
exports.updateEditionGroup = updateEditionGroup;
exports.updateFormat = updateFormat;
exports.updateLanguages = updateLanguages;
exports.updatePublisher = updatePublisher;
exports.updateStatus = updateStatus;
/*
 * Copyright (C) 2016  Ben Ockmore
 *
 * 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.
 */

var DISABLE_PHYSICAL = 'DISABLE_PHYSICAL';
exports.DISABLE_PHYSICAL = DISABLE_PHYSICAL;
var ENABLE_PHYSICAL = 'ENABLE_PHYSICAL';
exports.ENABLE_PHYSICAL = ENABLE_PHYSICAL;
var UPDATE_EDITION_GROUP = 'UPDATE_EDITION_GROUP';
exports.UPDATE_EDITION_GROUP = UPDATE_EDITION_GROUP;
var UPDATE_PUBLISHER = 'UPDATE_PUBLISHER';
exports.UPDATE_PUBLISHER = UPDATE_PUBLISHER;
var UPDATE_RELEASE_DATE = 'UPDATE_RELEASE_DATE';
exports.UPDATE_RELEASE_DATE = UPDATE_RELEASE_DATE;
var UPDATE_FORMAT = 'UPDATE_FORMAT';
exports.UPDATE_FORMAT = UPDATE_FORMAT;
var UPDATE_LANGUAGES = 'UPDATE_LANGUAGES';
exports.UPDATE_LANGUAGES = UPDATE_LANGUAGES;
var ADD_LANGUAGE = 'ADD_LANGUAGE';
exports.ADD_LANGUAGE = ADD_LANGUAGE;
var UPDATE_STATUS = 'UPDATE_STATUS';
exports.UPDATE_STATUS = UPDATE_STATUS;
var UPDATE_WEIGHT = 'UPDATE_WEIGHT';
exports.UPDATE_WEIGHT = UPDATE_WEIGHT;
var UPDATE_PAGES = 'UPDATE_PAGES';
exports.UPDATE_PAGES = UPDATE_PAGES;
var UPDATE_WIDTH = 'UPDATE_WIDTH';
exports.UPDATE_WIDTH = UPDATE_WIDTH;
var UPDATE_HEIGHT = 'UPDATE_HEIGHT';
exports.UPDATE_HEIGHT = UPDATE_HEIGHT;
var UPDATE_DEPTH = 'UPDATE_DEPTH';
exports.UPDATE_DEPTH = UPDATE_DEPTH;
var TOGGLE_SHOW_EDITION_GROUP = 'TOGGLE_SHOW_EDITION_GROUP';
exports.TOGGLE_SHOW_EDITION_GROUP = TOGGLE_SHOW_EDITION_GROUP;
var UPDATE_WARN_IF_EDITION_GROUP_EXISTS = 'UPDATE_WARN_IF_EDITION_GROUP_EXISTS';

/**
 * Produces an action indicating that the edition status for the edition being
 * edited should be updated with the provided value.
 *
 * @param {number} newStatusId - The new value to be used for the edition
 *                 status ID.
 * @returns {Action} The resulting UPDATE_STATUS action.
 */
exports.UPDATE_WARN_IF_EDITION_GROUP_EXISTS = UPDATE_WARN_IF_EDITION_GROUP_EXISTS;
function updateStatus(newStatusId) {
  return {
    payload: newStatusId,
    type: UPDATE_STATUS
  };
}

/**
 * Produces an action indicating that the edition format for the edition being
 * edited should be updated with the provided value.
 *
 * @param {number} newFormatId - The new value to be used for the edition
 *                 format ID.
 * @returns {Action} The resulting UPDATE_FORMAT action.
 */
function updateFormat(newFormatId) {
  return {
    payload: newFormatId,
    type: UPDATE_FORMAT
  };
}

/**
 * Produces an action indicating that the release date for the edition
 * should be updated with the provided value. The action is marked to be
 * debounced by the keystroke debouncer defined for redux-debounce.
 *
 * @param {string} newReleaseDate - The new value to be used for the release
 *                 date.
 * @returns {Action} The resulting UPDATE_RELEASE_DATE action.
 */
function debouncedUpdateReleaseDate(newReleaseDate) {
  return {
    meta: {
      debounce: 'keystroke'
    },
    payload: newReleaseDate,
    type: UPDATE_RELEASE_DATE
  };
}

/**
 * Produces an action indicating that the edition languages for the edition
 * being edited should be updated with the provided values.
 *
 * @param {LanguageOption} newLanguages - The new objects to be used for the
 *                         edition languages.
 * @returns {Action} The resulting UPDATE_LANGUAGES action.
 */
function updateLanguages(newLanguages) {
  return {
    payload: newLanguages,
    type: UPDATE_LANGUAGES
  };
}

/**
 * Produces an action indicating that new language should be added to languages field.
 *
 * @param {LanguageOption} newLanguage - The new language to be added/
 * @returns {Action} The resulting ADD_LANGUAGE action.
 */
function addLanguage(newLanguage) {
  return {
    payload: newLanguage,
    type: ADD_LANGUAGE
  };
}

/**
 * Produces an action indicating that the physical section of the edition
 * form should be editable.
 *
 * @returns {Action} The resulting ENABLE_PHYSICAL action.
 */
function enablePhysical() {
  return {
    type: ENABLE_PHYSICAL
  };
}

/**
 * Produces an action indicating that the physical section of the edition
 * form should not be editable.
 *
 * @returns {Action} The resulting DISABLE_PHYSICAL action.
 */
function disablePhysical() {
  return {
    type: DISABLE_PHYSICAL
  };
}

/**
 * Produces an action indicating that the Edition Group section of the edition
 * form should be shown.
 *
 * @param {boolean} showEGSection: Whether to show the Edition Group selection section or not
 *
 * @returns {Action} The resulting TOGGLE_SHOW_EDITION_GROUP action.
 */
function toggleShowEditionGroup(showEGSection) {
  return {
    payload: showEGSection,
    type: TOGGLE_SHOW_EDITION_GROUP
  };
}

/**
 * Produces an action indicating that the publisher for the edition
 * being edited should be updated with the provided value.
 *
 * @param {Publisher} newPublisher - The new publisher object to be set for
 *                                   the edition.
 * @returns {Action} The resulting UPDATE_PUBLISHER action.
 */
function updatePublisher(newPublisher) {
  return {
    payload: newPublisher,
    type: UPDATE_PUBLISHER
  };
}

/**
 * Produces an action indicating that the Edition Group for the edition
 * being edited should be updated with the provided value.
 *
 * @param {EditionGroup} newEditionGroup - The new EditionGroup object to be set
 *                      for the edition.
 * @returns {Action} The resulting UPDATE_EDITION_GROUP action.
 */
function updateEditionGroup(newEditionGroup) {
  return {
    payload: newEditionGroup,
    type: UPDATE_EDITION_GROUP
  };
}

/**
 * Produces an action indicating that the weight for the edition
 * should be updated with the provided value. The action is marked to be
 * debounced by the keystroke debouncer defined for redux-debounce.
 *
 * @param {number} value - The new value to be used for the edition weight.
 * @returns {Action} The resulting UPDATE_WEIGHT action.
 */
function debouncedUpdateWeight(value) {
  return {
    meta: {
      debounce: 'keystroke'
    },
    payload: value,
    type: UPDATE_WEIGHT
  };
}

/**
 * Produces an action indicating that the number of pages for the edition
 * should be updated with the provided value. The action is marked to be
 * debounced by the keystroke debouncer defined for redux-debounce.
 *
 * @param {number} value - The new value to be used for the number of pages.
 * @returns {Action} The resulting UPDATE_PAGES action.
 */
function debouncedUpdatePages(value) {
  return {
    meta: {
      debounce: 'keystroke'
    },
    payload: value,
    type: UPDATE_PAGES
  };
}

/**
 * Produces an action indicating that the width for the edition
 * should be updated with the provided value. The action is marked to be
 * debounced by the keystroke debouncer defined for redux-debounce.
 *
 * @param {number} value - The new value to be used for the width.
 * @returns {Action} The resulting UPDATE_WIDTH action.
 */
function debouncedUpdateWidth(value) {
  return {
    meta: {
      debounce: 'keystroke'
    },
    payload: value,
    type: UPDATE_WIDTH
  };
}

/**
 * Produces an action indicating that the height for the edition
 * should be updated with the provided value. The action is marked to be
 * debounced by the keystroke debouncer defined for redux-debounce.
 *
 * @param {number} value - The new value to be used for the height.
 * @returns {Action} The resulting UPDATE_HEIGHT action.
 */
function debouncedUpdateHeight(value) {
  return {
    meta: {
      debounce: 'keystroke'
    },
    payload: value,
    type: UPDATE_HEIGHT
  };
}

/**
 * Produces an action indicating that the depth for the edition
 * should be updated with the provided value. The action is marked to be
 * debounced by the keystroke debouncer defined for redux-debounce.
 *
 * @param {number} value - The new value to be used for the depth.
 * @returns {Action} The resulting UPDATE_DEPTH action.
 */
function debouncedUpdateDepth(value) {
  return {
    meta: {
      debounce: 'keystroke'
    },
    payload: value,
    type: UPDATE_DEPTH
  };
}
//# sourceMappingURL=actions.js.map