diff --git a/dist/frappe-datatable.cjs.js b/dist/frappe-datatable.cjs.js index 0d523be..92e2adc 100644 --- a/dist/frappe-datatable.cjs.js +++ b/dist/frappe-datatable.cjs.js @@ -320,8 +320,8 @@ function objectToString(value) { var _objectToString = objectToString; /** `Object#toString` result references. */ -var nullTag = '[object Null]'; -var undefinedTag = '[object Undefined]'; +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; /** Built-in value references. */ var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; @@ -469,8 +469,8 @@ var toNumber_1 = toNumber; var FUNC_ERROR_TEXT = 'Expected a function'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; -var nativeMin = Math.min; +var nativeMax = Math.max, + nativeMin = Math.min; /** * Creates a debounced function that delays invoking `func` until after `wait` @@ -742,16 +742,6 @@ function getDefault(a, b) { return a !== undefined ? a : b; } - - - - - - - - - - function copyTextToClipboard(text) { // https://stackoverflow.com/a/30810322/5353542 var textArea = document.createElement('textarea'); @@ -813,7 +803,7 @@ function isNumeric(val) { let throttle$1 = throttle_1; -let debounce$2 = debounce_1; +let debounce$1 = debounce_1; function promisify(fn, context = null) { return (...args) => { @@ -825,9 +815,6 @@ function promisify(fn, context = null) { }); }; } - - - function linkProperties(target, source, properties) { const props = properties.reduce((acc, prop) => { acc[prop] = { @@ -1662,7 +1649,7 @@ class ColumnManager { }); }); }; - $.on(this.header, 'keydown', '.data-table-filter', debounce$2(handler, 300)); + $.on(this.header, 'keydown', '.data-table-filter', debounce$1(handler, 300)); } sortRows(colIndex, sortOrder) { @@ -2105,15 +2092,15 @@ class CellManager { } } - this.$editingCell = $cell; - $cell.classList.add('editing'); - const $editCell = $('.edit-cell', $cell); $editCell.innerHTML = ''; const editor = this.getEditor(colIndex, rowIndex, cell.content, $editCell); if (editor) { + this.$editingCell = $cell; + $cell.classList.add('editing'); + this.currentCellEditor = editor; // initialize editing input with cell value editor.initValue(cell.content, rowIndex, col); @@ -2134,6 +2121,10 @@ class CellManager { const obj = this.options.getEditor(colIndex, rowIndex, value, parent); if (obj && obj.setValue) return obj; + // let the getEditor method determine dynamically + // if the cell is editable or not + if (obj === false) return null; + // editing fallback const $input = $.create('input', { class: 'input-style', @@ -2666,7 +2657,6 @@ class BodyRenderer { return rows.map((row) => this.rowmanager.getRowHTML(row, { rowIndex: row[0].rowIndex })); } } - function getBodyHTML(rows) { return ` @@ -3189,7 +3179,7 @@ var author = "Faris Ansari"; var license = "MIT"; var bugs = {"url":"https://github.com/frappe/datatable/issues"}; var homepage = "https://frappe.github.io/datatable"; -var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","sortablejs":"^1.7.0"}; +var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","rollup":"^0.56.3","sortablejs":"^1.7.0"}; var packageJson = { name: name, version: version, diff --git a/dist/frappe-datatable.js b/dist/frappe-datatable.js index 3bdc2fe..01a37a6 100644 --- a/dist/frappe-datatable.js +++ b/dist/frappe-datatable.js @@ -319,8 +319,8 @@ function objectToString(value) { var _objectToString = objectToString; /** `Object#toString` result references. */ -var nullTag = '[object Null]'; -var undefinedTag = '[object Undefined]'; +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; /** Built-in value references. */ var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; @@ -468,8 +468,8 @@ var toNumber_1 = toNumber; var FUNC_ERROR_TEXT = 'Expected a function'; /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; -var nativeMin = Math.min; +var nativeMax = Math.max, + nativeMin = Math.min; /** * Creates a debounced function that delays invoking `func` until after `wait` @@ -741,16 +741,6 @@ function getDefault(a, b) { return a !== undefined ? a : b; } - - - - - - - - - - function copyTextToClipboard(text) { // https://stackoverflow.com/a/30810322/5353542 var textArea = document.createElement('textarea'); @@ -812,7 +802,7 @@ function isNumeric(val) { let throttle$1 = throttle_1; -let debounce$2 = debounce_1; +let debounce$1 = debounce_1; function promisify(fn, context = null) { return (...args) => { @@ -824,9 +814,6 @@ function promisify(fn, context = null) { }); }; } - - - function linkProperties(target, source, properties) { const props = properties.reduce((acc, prop) => { acc[prop] = { @@ -1661,7 +1648,7 @@ class ColumnManager { }); }); }; - $.on(this.header, 'keydown', '.data-table-filter', debounce$2(handler, 300)); + $.on(this.header, 'keydown', '.data-table-filter', debounce$1(handler, 300)); } sortRows(colIndex, sortOrder) { @@ -2104,15 +2091,15 @@ class CellManager { } } - this.$editingCell = $cell; - $cell.classList.add('editing'); - const $editCell = $('.edit-cell', $cell); $editCell.innerHTML = ''; const editor = this.getEditor(colIndex, rowIndex, cell.content, $editCell); if (editor) { + this.$editingCell = $cell; + $cell.classList.add('editing'); + this.currentCellEditor = editor; // initialize editing input with cell value editor.initValue(cell.content, rowIndex, col); @@ -2133,6 +2120,10 @@ class CellManager { const obj = this.options.getEditor(colIndex, rowIndex, value, parent); if (obj && obj.setValue) return obj; + // let the getEditor method determine dynamically + // if the cell is editable or not + if (obj === false) return null; + // editing fallback const $input = $.create('input', { class: 'input-style', @@ -2665,7 +2656,6 @@ class BodyRenderer { return rows.map((row) => this.rowmanager.getRowHTML(row, { rowIndex: row[0].rowIndex })); } } - function getBodyHTML(rows) { return ` @@ -3188,7 +3178,7 @@ var author = "Faris Ansari"; var license = "MIT"; var bugs = {"url":"https://github.com/frappe/datatable/issues"}; var homepage = "https://frappe.github.io/datatable"; -var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","sortablejs":"^1.7.0"}; +var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","rollup":"^0.56.3","sortablejs":"^1.7.0"}; var packageJson = { name: name, version: version, diff --git a/package.json b/package.json index 757f77a..59783d8 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "dependencies": { "clusterize.js": "^0.18.0", "lodash": "^4.17.5", + "rollup": "^0.56.3", "sortablejs": "^1.7.0" } } diff --git a/src/cellmanager.js b/src/cellmanager.js index 12645e2..b62d3ee 100644 --- a/src/cellmanager.js +++ b/src/cellmanager.js @@ -359,15 +359,15 @@ export default class CellManager { } } - this.$editingCell = $cell; - $cell.classList.add('editing'); - const $editCell = $('.edit-cell', $cell); $editCell.innerHTML = ''; const editor = this.getEditor(colIndex, rowIndex, cell.content, $editCell); if (editor) { + this.$editingCell = $cell; + $cell.classList.add('editing'); + this.currentCellEditor = editor; // initialize editing input with cell value editor.initValue(cell.content, rowIndex, col); @@ -388,6 +388,10 @@ export default class CellManager { const obj = this.options.getEditor(colIndex, rowIndex, value, parent); if (obj && obj.setValue) return obj; + // let the getEditor method determine dynamically + // if the cell is editable or not + if (obj === false) return null; + // editing fallback const $input = $.create('input', { class: 'input-style', diff --git a/yarn.lock b/yarn.lock index 6f874e1..f40743b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2444,6 +2444,10 @@ rollup-pluginutils@^2.0.1: estree-walker "^0.3.0" micromatch "^2.3.11" +rollup@^0.56.3: + version "0.56.3" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.56.3.tgz#7900695531afa1badd3235f285cc4aa0d49ce254" + run-async@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389"