1 var _typeof = typeof Symbol ===
"function" && typeof Symbol.iterator ===
"symbol" ?
function (obj) {
return typeof obj; } :
function (obj) {
return obj && typeof Symbol ===
"function" && obj.constructor === Symbol && obj !== Symbol.prototype ?
"symbol" : typeof obj; };
5 var Mutator =
function Mutator(table) {
7 this.allowedTypes = [
"",
"data",
"edit",
"clipboard"];
12 Mutator.prototype.initializeColumn =
function (column) {
17 this.allowedTypes.forEach(
function (type) {
18 var key =
"mutator" + (type.charAt(0).toUpperCase() + type.slice(1)),
21 if (column.definition[key]) {
22 mutator =
self.lookupMutator(column.definition[key]);
29 params: column.definition[key +
"Params"] || {}
36 column.modules.mutate = config;
40 Mutator.prototype.lookupMutator =
function (value) {
44 switch (typeof value ===
"undefined" ?
"undefined" : _typeof(value)) {
46 if (this.mutators[value]) {
47 mutator = this.mutators[value];
49 console.warn(
"Mutator Error - No such mutator found, ignoring: ", value);
62 Mutator.prototype.transformRow =
function (data, type, updatedData) {
64 key =
"mutator" + (type.charAt(0).toUpperCase() + type.slice(1)),
69 self.table.columnManager.traverse(
function (column) {
70 var mutator, params, component;
72 if (column.modules.mutate) {
73 mutator = column.modules.mutate[key] || column.modules.mutate.mutator ||
false;
75 if (mutator && updatedData) {
76 value = column.getFieldValue(updatedData);
78 if (type ==
"data" || typeof value !==
"undefined") {
79 component = column.getComponent();
80 params = typeof mutator.params ===
"function" ? mutator.params(value, data, type, component) : mutator.params;
81 column.setFieldValue(data, mutator.mutator(value, data, type, params, component));
92 Mutator.prototype.transformCell =
function (cell, value) {
93 var mutator = cell.column.modules.mutate.mutatorEdit || cell.column.modules.mutate.mutator ||
false,
97 tempData = Object.assign(tempData, cell.row.getData());
98 cell.column.setFieldValue(tempData, value);
99 return mutator.mutator(value, tempData,
"edit", mutator.params, cell.getComponent());
105 Mutator.prototype.enable =
function () {
109 Mutator.prototype.disable =
function () {
110 this.enabled =
false;
114 Mutator.prototype.mutators = {};
116 Tabulator.prototype.registerModule(
"mutator", Mutator);