From e926fb9a0a2ff6f8a1a4fcf60f0efbd054d3f59d Mon Sep 17 00:00:00 2001 From: Matthew Mulholland Date: Tue, 5 Jun 2018 17:13:00 +1000 Subject: [PATCH] #805: refactored for breaking changes in 0.xx versions. Removed redundant code. --- handsontable_upgrade_notes.txt.js | 17 ---------- package.json | 2 +- src/renderer/components/Home.vue | 4 +-- src/renderer/hot.js | 46 +++++++++++---------------- src/renderer/partials/FindReplace.vue | 3 +- 5 files changed, 23 insertions(+), 49 deletions(-) delete mode 100644 handsontable_upgrade_notes.txt.js diff --git a/handsontable_upgrade_notes.txt.js b/handsontable_upgrade_notes.txt.js deleted file mode 100644 index 21a26c49f..000000000 --- a/handsontable_upgrade_notes.txt.js +++ /dev/null @@ -1,17 +0,0 @@ -Handsontable upgrade notes to 3.0.0 - -Compatible? -0.36 -hot.alter -// afterSelection -// previously: afterSelection(row, column, rowEnd, columnEnd, preventScrolling) -// now: afterSelection(row, column, rowEnd, columnEnd, preventScrolling, selectionLayerLevel) - -Breaking -0.36 -hot.getSelected() Returns an array of arrays with the coordinates of all layers ([[row, col, rowEnd, colEnd], [row, col, rowEnd, colEnd] ...]); -hot.getSelectedRange() Returns an array of CellRange objects with the coordinates of all layers ([{CellRange}, {CellRange} ...]); -colours: - area borders, was #89aff9 -> is #4b89ff - area background, was #b5d1ff -> is #005eff - current selection border, was #5292f7 -> is #4b89ff diff --git a/package.json b/package.json index 9e6328d4f..850b72af7 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js", "postinstall": "electron-builder install-app-deps", "test-main": "mocha-webpack --webpack-config .electron-vue/webpack.test.config.js --glob *_spec.js test/main/specs", - "test": "yarn run unit && yarn run e2e", + "test": "(yarn run unit || yarn -v) && yarn run e2e", "unit": "karma start test/unit/karma.conf.js", "e2e": "yarn run pack && (yarn run cucumber:postpack:impl || yarn -v) && yarn run cucumber:report", "e2e:dev": "(yarn run cucumber:postpack:dev || yarn -v) && yarn run cucumber:report", diff --git a/src/renderer/components/Home.vue b/src/renderer/components/Home.vue index d306f9342..256a63b94 100644 --- a/src/renderer/components/Home.vue +++ b/src/renderer/components/Home.vue @@ -525,10 +525,9 @@ export default { selectionListener: function() { let hot = HotRegister.getActiveInstance() this.unhighlightPersistedSelection(hot) - let selected = hot.getSelected() + let selected = hot.getSelectedLast() // with deselectOutsideHot set to true, we need to track last selection. this.pushHotSelection({hotId: hot.guid, selected: selected}) - console.log(`selected is`, selected) this.updateActiveColumn(selected) }, inferColumnProperties: async function() { @@ -720,6 +719,7 @@ export default { loadData(activeHotId, data, format, self.closeLoadingScreen) getCurrentColumnIndexOrMin() } catch (error) { + console.error('ERROR: load data problem: ', error) ipc.send('dataParsingError') } }, 1) diff --git a/src/renderer/hot.js b/src/renderer/hot.js index 154741346..9f03ab12e 100644 --- a/src/renderer/hot.js +++ b/src/renderer/hot.js @@ -6,13 +6,7 @@ const Dialog = remote.dialog const _hots = {} const searchCallback = Handsontable.plugins.Search.DEFAULT_CALLBACK -const searchQueryMethod = Handsontable.plugins.Search.DEFAULT_QUERY_METHOD -let hDom = Handsontable.dom -// getFirstSelected: https://github.com/handsontable/handsontable/releases/tag/0.36.0 -Handsontable.prototype.getFirstSelected = function() { - return this.getFirstSelected[0] -} const HotRegister = { register(container, listeners={}, searchParameters = false) { let hot = new Handsontable(container, { @@ -45,7 +39,7 @@ const HotRegister = { // search: true, tabMoves({shiftKey}) { if (!shiftKey) { - const selection = hot.getFirstSelected() + const selection = hot.getSelectedLast() let next = hot.getCell(selection[0], selection[1] + 1) if (next == null) { hot.alter('insert_col', selection[1] + 1) @@ -82,7 +76,7 @@ const HotRegister = { }, enterMoves({shiftKey}) { if (!shiftKey) { - const selection = hot.getFirstSelected() + const selection = hot.getSelectedLast() let next = hot.getCell(selection[0] + 1, selection[1]) if (next == null) { hot.alter('insert_row', selection[0] + 1) @@ -142,49 +136,49 @@ const HotRegister = { export function getActiveSelected() { let activeHot = HotRegister.getActiveInstance() - return activeHot.getFirstSelected() + return activeHot.getSelectedLast() } export function getActiveSelectedOrHotSelectionOrMin() { let activeHot = HotRegister.getActiveInstance() - let currentCell = activeHot.getFirstSelected() + let currentCell = activeHot.getSelectedLast() if (!currentCell) { currentCell = store.getters.getHotSelection(store.state, store.getters)(activeHot.guid) } if (!currentCell) { activeHot.selectCell(0, 0) - currentCell = activeHot.getFirstSelected() + currentCell = activeHot.getSelectedLast() } return currentCell } export function getCurrentColumnIndexOrMin() { let activeHot = HotRegister.getActiveInstance() - let currentCell = activeHot.getFirstSelected() + let currentCell = activeHot.getSelectedLast() if (!currentCell) { activeHot.selectCell(0, 0) - currentCell = activeHot.getFirstSelected() + currentCell = activeHot.getSelectedLast() } return currentCell[1] } export function getCurrentColumnIndexOrMax() { let activeHot = HotRegister.getActiveInstance() - let currentCell = activeHot.getFirstSelected() + let currentCell = activeHot.getSelectedLast() if (!currentCell) { let maxCol = getColumnCount() - 1 activeHot.selectCell(0, maxCol) - currentCell = activeHot.getFirstSelected() + currentCell = activeHot.getSelectedLast() } return currentCell[1] } export function reselectCurrentCellOrMin() { let activeHot = HotRegister.getActiveInstance() - let currentCell = activeHot.getFirstSelected() + let currentCell = activeHot.getSelectedLast() if (!currentCell) { activeHot.selectCell(0, 0) - currentCell = activeHot.getFirstSelected() + currentCell = activeHot.getSelectedLast() } else { activeHot.selectCell(currentCell[0], currentCell[1]) } @@ -192,10 +186,10 @@ export function reselectCurrentCellOrMin() { export function reselectCellOrMin(hotId) { let activeHot = HotRegister.getInstance(hotId) - let currentCell = activeHot.getFirstSelected() + let currentCell = activeHot.getSelectedLast() if (!currentCell) { activeHot.selectCell(0, 0) - // currentCell = activeHot.getFirstSelected() + // currentCell = activeHot.getSelectedLast() } else { activeHot.selectCell(currentCell[0], currentCell[1]) } @@ -203,7 +197,7 @@ export function reselectCellOrMin(hotId) { export function reselectCurrentCellOrMax() { let activeHot = HotRegister.getActiveInstance() - let currentCell = activeHot.getFirstSelected() + let currentCell = activeHot.getSelectedLast() if (!currentCell) { let maxCol = getColumnCount() - 1 activeHot.selectCell(0, maxCol) @@ -255,7 +249,7 @@ export function insertRowBelow() { export function insertRow(offset, mathFn) { let hot = getHotToInsert() - const range = hot.getFirstSelectedRange() + const range = hot.getSelectedRangeLast() if (typeof range !== 'undefined') { const selection = mathFn(range.from.row, range.to.row) + offset hot.alter('insert_row', selection) @@ -273,7 +267,7 @@ export function insertColumnRight() { export function insertColumn(offset, mathFn) { let hot = getHotToInsert() - const range = hot.getFirstSelectedRange() + const range = hot.getSelectedRangeLast() if (typeof range !== 'undefined') { const selection = mathFn(range.from.col, range.to.col) + offset hot.alter('insert_col', selection) @@ -301,7 +295,7 @@ export function removeHeaderAtIndex(hot, index) { export function removeRows() { let hot = HotRegister.getActiveInstance() - const range = hot.getFirstSelectedRange() + const range = hot.getSelectedRangeLast() if (typeof range === 'undefined') { return } @@ -317,7 +311,7 @@ export function removeRows() { export function removeColumns() { let hot = HotRegister.getActiveInstance() - const range = hot.getFirstSelectedRange() + const range = hot.getSelectedRangeLast() if (typeof range === 'undefined') { return } @@ -345,7 +339,5 @@ ipc.on('selectHotCell', function(event, rowCountNumber, ColCountNumber) { export { HotRegister, - searchCallback, - searchQueryMethod, - hDom + searchCallback } diff --git a/src/renderer/partials/FindReplace.vue b/src/renderer/partials/FindReplace.vue index 26f22f1f5..2f5beb749 100644 --- a/src/renderer/partials/FindReplace.vue +++ b/src/renderer/partials/FindReplace.vue @@ -48,7 +48,6 @@ import AsyncComputed from 'vue-async-computed' import { HotRegister, searchCallback, - searchQueryMethod, getActiveSelectedOrHotSelectionOrMin } from '../hot.js' import VueRx from 'vue-rx' @@ -231,7 +230,7 @@ export default { this.replaceData = hot.getData() } // console.timeEnd() - const selectedCoords = hot.getSelected() + const selectedCoords = hot.getSelectedLast() if (selectedCoords) { const row = selectedCoords[0] const col = selectedCoords[1]