Skip to content

Commit

Permalink
#805: refactored for breaking changes in 0.xx versions. Removed redun…
Browse files Browse the repository at this point in the history
…dant code.
  • Loading branch information
Matthew Mulholland committed Jun 5, 2018
1 parent 1e7888b commit e926fb9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 49 deletions.
17 changes: 0 additions & 17 deletions handsontable_upgrade_notes.txt.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
Expand Down
46 changes: 19 additions & 27 deletions src/renderer/hot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -142,68 +136,68 @@ 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])
}
}

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])
}
}

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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -345,7 +339,5 @@ ipc.on('selectHotCell', function(event, rowCountNumber, ColCountNumber) {

export {
HotRegister,
searchCallback,
searchQueryMethod,
hDom
searchCallback
}
3 changes: 1 addition & 2 deletions src/renderer/partials/FindReplace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import AsyncComputed from 'vue-async-computed'
import {
HotRegister,
searchCallback,
searchQueryMethod,
getActiveSelectedOrHotSelectionOrMin
} from '../hot.js'
import VueRx from 'vue-rx'
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit e926fb9

Please sign in to comment.