"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_WORKS = exports.UPDATE_WORK = exports.TOGGLE_COPY_AUTHOR_CREDITS = exports.REMOVE_WORK = exports.REMOVE_SERIES = exports.DUPLICATE_WORK = exports.ADD_WORK = exports.ADD_SERIES = void 0;
exports.addSeries = addSeries;
exports.addWork = addWork;
exports.duplicateWork = duplicateWork;
exports.removeSeries = removeSeries;
exports.removeWork = removeWork;
exports.toggleCheck = toggleCheck;
exports.updateWork = updateWork;
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; }
// Work Actions
var ADD_WORK = 'ADD_WORK';
exports.ADD_WORK = ADD_WORK;
var UPDATE_WORKS = 'UPDATE_WORKS';
exports.UPDATE_WORKS = UPDATE_WORKS;
var REMOVE_WORK = 'REMOVE_WORK';
exports.REMOVE_WORK = REMOVE_WORK;
var UPDATE_WORK = 'UPDATE_WORK';
exports.UPDATE_WORK = UPDATE_WORK;
var TOGGLE_COPY_AUTHOR_CREDITS = 'TOGGLE_COPY_AUTHOR_CREDITS';
exports.TOGGLE_COPY_AUTHOR_CREDITS = TOGGLE_COPY_AUTHOR_CREDITS;
var DUPLICATE_WORK = 'DUPLICATE_WORK';
// Series Actions
exports.DUPLICATE_WORK = DUPLICATE_WORK;
var ADD_SERIES = 'ADD_SERIES';
exports.ADD_SERIES = ADD_SERIES;
var REMOVE_SERIES = 'REMOVE_SERIES';
exports.REMOVE_SERIES = REMOVE_SERIES;
var nextWorkId = 0;
var nextSeriesId = 0;
/**
* Produces an action indicating that new Work should be added in `Works`.
*
* @param {Object} value - New work state.
* @returns {Action} The resulting ADD_WORK action.
*/
function addWork() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
return {
payload: {
id: "w".concat(nextWorkId++),
value: _objectSpread({
checked: true
}, value)
},
type: ADD_WORK
};
}
/**
* Produces an action indicating that a given Work should be removed from `Works`.
*
* @param {string} id - id of the work to be removed
* @returns {Action} The resulting REMOVE_WORK action.
*/
function removeWork(id) {
return {
payload: id,
type: REMOVE_WORK
};
}
/**
* Produces an action indicating that `Works` State should be updated with the new `Works`.
*
* @param {string} id - id of work to be updated
* @param {Object} value - updated work state.
* @returns {Action} The resulting UPDATE_WORK action.
*/
function updateWork(id, value) {
return {
payload: {
id: id,
value: value
},
type: UPDATE_WORK
};
}
/**
* Produces an action indicating that a Work's checkbox should be toggled in `Works`.
*
* @param {string} id - id of the work to be toggle
* @returns {Action} The resulting TOGGLE_COPY_AUTHOR_CREDITS action.
*/
function toggleCheck(id) {
return {
payload: id,
type: TOGGLE_COPY_AUTHOR_CREDITS
};
}
/**
* Produces an action indicating that a Work need to be copied.
*
* @param {string} id - id of the work to be copied
* @returns {Action} The resulting DUPLICATE_WORK action.
*/
function duplicateWork(id) {
return {
payload: id,
type: DUPLICATE_WORK
};
}
/**
* Produces an action indicating that new Series should be added in `Series`.
*
* @param {object} value - New series entity state.
* @returns {Action} The resulting ADD_SERIES action.
*/
function addSeries() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
return {
payload: {
id: "s".concat(nextSeriesId),
value: value
},
type: ADD_SERIES
};
}
/**
* Produces an action indicating that a given Series should be removed from `Series`.
*
* @param {string} id - id of the series to be removed
* @returns {Action} The resulting REMOVE_SERIES action.
*/
function removeSeries() {
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "s".concat(nextSeriesId);
return {
payload: id,
type: REMOVE_SERIES
};
}
//# sourceMappingURL=action.js.map