Skip to content

Commit

Permalink
#852: Refactored name for better description. Ensure lock triggers pe…
Browse files Browse the repository at this point in the history
…rformed after activeTab, then active Hot Id captured. Removed debug logging.
  • Loading branch information
Matthew Mulholland committed Jun 27, 2019
1 parent 8ba88ed commit 644d5fa
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 42 deletions.
13 changes: 6 additions & 7 deletions src/renderer/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
:adjustSidenavFormHeight="adjustSidenavFormHeight"
:sideNavFormHeight="sideNavFormHeight"
:cIndex="currentColumnIndex"
:isLocked="isLocked"
:isLocked="isActiveTabLocked"
/>
</transition>
<div
Expand Down Expand Up @@ -400,7 +400,7 @@ export default {
value: 'tabular-data-package'
}],
reportSiblingClasses: ['main-bottom-panel', 'main-middle-panel'],
isLocked: false
isActiveTabLocked: false
}
},
computed: {
Expand Down Expand Up @@ -438,14 +438,13 @@ export default {
try {
let hotId = await this.getHotIdFromTabId(tabId)
this.currentHotId = hotId
console.log(`current Hot id is: ${this.currentHotId}`)
this.reselectHotCell()
} catch (err) {
console.error('Problem with getting hot id from watched tab', err)
}
this.closeMessages()
this.sendErrorsToErrorsWindow()
console.log('hello active tab 2...')
LockProperties.trigger()
},
messages: function() {
if (this.messages) {
Expand All @@ -457,8 +456,9 @@ export default {
let self = this
this.$subscribeTo(allTableLocks$, async function(allTablesLocks) {
self.isLocked = _.includes(LockProperties.getLockedTables(), hotId)
ipc.send('hasLockedColumns', self.isLocked)
let hotId = self.currentHotId
self.isActiveTabLocked = _.includes(allTablesLocks, self.currentHotId)
ipc.send('hasLockedColumns', self.isActiveTabLocked)
})
// request may be coming from another page - get focus first
ipc.on('showErrorCell', async function(event, arg) {
Expand Down Expand Up @@ -557,7 +557,6 @@ export default {
}
ipc.send('hasCaseSensitiveHeader', isCaseSensitive(hotId))
remote.getGlobal('tab').activeHotId = hotId
LockProperties.trigger()
})
onNextHotIdFromTabRx(getHotIdFromTabIdFunction())
},
Expand Down
1 change: 0 additions & 1 deletion src/renderer/data-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export function saveDataToFile (hot, format, filename, callback) {
csvOptions.quoted = true
}
data = stringify(arrays, csvOptions)
console.log('')
pushCsvFormat(hot.guid, format)
}
reinsertExistingBOM(data, hot.guid)
Expand Down
20 changes: 10 additions & 10 deletions src/renderer/lockProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ const LockProperties = {

toggleLockColumnProperties () {
const hotId = HotRegister.getActiveInstance().guid
let isActiveHotLocked = !!this.isColumnPropertiesLocked(hotId)
isActiveHotLocked = !isActiveHotLocked
this.updateStoredTableLock(hotId, isActiveHotLocked)
ipc.send('hasLockedColumns', isActiveHotLocked)
let currentLock = _.includes(this.getLockedTables(), hotId)
currentLock = !currentLock
this.updateStoredTableLock(hotId, currentLock)
},

getLockedTables() {
return store.getters.hasPropertyFromAllTables(this.storeName)
},

updateStoredTableLock (hotId, value) {
Expand All @@ -21,21 +24,18 @@ const LockProperties = {
key: this.storeName,
value: !!value
})
allTableLocks$.next(store.getters.getPropertyFromAllTables(this.storeName))
this.trigger()
},

isColumnPropertiesLocked (hotId) {
let allLocks = store.getters.getPropertyFromAllTables(this.storeName)
return _.includes(allLocks, hotId)
trigger() {
allTableLocks$.next(this.getLockedTables())
}
}

ipc.on('toggleLockColumnProperties', function (event, arg) {
LockProperties.toggleLockColumnProperties()
})

allTableLocks$.next(store.getters.getPropertyFromAllTables(LockProperties.storeName))

export {
LockProperties
}
33 changes: 10 additions & 23 deletions src/renderer/partials/ColumnProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,14 @@ import {
} from 'rxjs/Subscription'
import {
allTablesAllColumnNames$,
allTablesAllColumnsFromSchema$,
allTableLocks$
allTablesAllColumnsFromSchema$
} from '@/rxSubject.js'
import ColumnTooltip from '@/mixins/ColumnTooltip'
import ValidationRules from '@/mixins/ValidationRules'
import ColumnTooltip from '../mixins/ColumnTooltip'
import ValidationRules from '../mixins/ValidationRules'
import { isValidPatternForType } from '@/dateFormats.js'
import { castBoolean, castNumber, castInteger } from 'tableschema/lib/types'
import { ERROR as tableSchemaError } from 'tableschema/lib/config'
import { LockProperties } from '@/lockProperties'
import * as activeTab$ from 'rxjs'
Vue.use(VueRx, {
Subscription
})
Expand All @@ -275,6 +273,10 @@ export default {
cIndex: {
type: Number,
default: 0
},
isLocked: {
type: Boolean,
default: false
}
},
data() {
Expand All @@ -286,7 +288,6 @@ export default {
constraintInputKeyValues: {},
warningVisibility: false,
allTablesAllColumnsNames: {},
// isLocked: false,
// TODO: setup args so clear for constraints only
debounceSetConstraints: _.debounce(this.pushColumnProperty, 300, {
'leading': true,
Expand Down Expand Up @@ -429,7 +430,7 @@ export default {
}
},
getFormatProperty: {
async get () {
async get() {
// use promise for format's hotid to keep in sync with getTypeProperty
let hotId = await this.currentHotId()
let getter = this.getter(hotId, 'format')
Expand All @@ -445,18 +446,12 @@ export default {
this.formatProperty = property
return property
},
watch () {
watch() {
let temp = this.getActiveTab
let temp2 = this.cIndex
// ensure format also updates after setting type
let temp3 = this.typeProperty
}
},
isLocked: {
async get() {
console.log('getting lock...')
return LockProperties.isColumnPropertiesLocked(this.activeCurrentHotId)
}
}
},
computed: {
Expand Down Expand Up @@ -502,9 +497,6 @@ export default {
'formatPropertiesForType': function() {
this.debounceCheckType()
}
// 'activeCurrentHotId': function(activeId) {
// console.log(`new active id is: ${activeId}`)
// }
},
mounted: function() {
let self = this
Expand All @@ -513,12 +505,7 @@ export default {
})
allTablesAllColumnNames$.next(this.getAllHotTablesColumnNames())
autosize(document.querySelector('textarea'))
// this.$subscribeTo(allTableLocks$, async function(allTablesLocks) {
// const hotId = this.activeCurrentHotId
// self.isLocked = _.includes(allTablesLocks, hotId)
// console.log(`locked is ${self.isLocked}`)
// })
LockProperties.trigger()
},
created: function() {
let vueType = this.typePropertyWrapper
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/store/modules/hots.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const getters = {
}
return hotIdColumnNames
},
getPropertyFromAllTables: (state, getters) => (propertyName) => {
hasPropertyFromAllTables: (state, getters) => (propertyName) => {
let tablesWithProperty = []
for (let hotId in state.hotTabs) {
let tableProps = state.hotTabs[hotId].tableProperties || {}
Expand Down

0 comments on commit 644d5fa

Please sign in to comment.