canner
Version:
Build CMS in few lines of code for different data sources
49 lines (38 loc) • 1.66 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _lodash = require("lodash");
var ConnectPattern = function ConnectPattern() {
var _this = this;
(0, _classCallCheck2.default)(this, ConnectPattern);
(0, _defineProperty2.default)(this, "actions", void 0);
(0, _defineProperty2.default)(this, "addAction", function (action) {
_this.actions.push(action);
_this.mergeAction();
});
(0, _defineProperty2.default)(this, "mergeConnectAndDisconnectAndDelete", function () {
_this.actions = (0, _lodash.uniqBy)((0, _toConsumableArray2.default)(_this.actions).reverse(), function (action) {
var _action$payload = action.payload,
key = _action$payload.key,
id = _action$payload.id,
path = _action$payload.path,
value = _action$payload.value;
return "".concat(key, ".").concat(id, ".").concat(path, ".").concat(value.id);
}).reverse();
});
(0, _defineProperty2.default)(this, "mergeAction", function () {
_this.mergeConnectAndDisconnectAndDelete();
return _this.actions;
});
(0, _defineProperty2.default)(this, "getActions", function () {
return _this.actions;
});
this.actions = [];
};
exports.default = ConnectPattern;