-
@@ -169,7 +175,9 @@ export default {
enableTransition: false,
enableSideNavLeftArrow: true,
enableSideNavRightArrow: true,
- errorMessages: false,
+ messagesType: '',
+ messages: false,
+ messagesTitle: 'Feedback',
loadingDataMessage: false,
sideNavFormHeight: '300px',
toolbarMenus: [{
@@ -254,11 +262,13 @@ export default {
'destroyHotTab',
'destroyTabObject'
]),
- closeErrorMessages: function() {
+ closeMessages: function() {
for (let el of ['main-bottom-panel', 'main-middle-panel']) {
document.getElementById(el).classList.remove('opened')
}
- this.errorMessages = false
+ this.messages = false
+ this.messagesType = ''
+ this.messageTitle = ''
},
selectionListener: function() {
this.updateActiveColumn()
@@ -266,27 +276,43 @@ export default {
},
async updateColumnProperties() {
try {
- await guessColumnProperties()
+ let feedback = await guessColumnProperties()
+ this.messages = feedback
+ this.messagesType = 'feedback'
+ this.messagesTitle = 'Guess column properties'
+ this.reportFeedback()
} catch (err) {
console.log(err)
}
},
- openValidationMessagesOnIds: function(ids) {
+ // TODO: tidy up error view handling
+ openMessagesOnIds: function(ids) {
for (let el of ids) {
document.getElementById(el).classList += ' opened'
}
},
- closeValidationMessagesOnIds: function(ids) {
+ closeMessagesOnIds: function(ids) {
for (let el of ids) {
document.getElementById(el).classList.remove('opened')
}
},
reportValidationRowErrors: function(errorCollection) {
- this.errorMessages = errorCollection
+ if (errorCollection.length > 0) {
+ this.messagesTitle = 'Validation Errors'
+ this.messages = errorCollection
+ this.messagesType = 'error'
+ } else {
+ this.messagesTitle = 'Validation Success'
+ this.messages = 'No validation errors reported.'
+ this.messagesType = 'feedback'
+ }
+ this.reportFeedback()
+ },
+ reportFeedback: function() {
let ids = ['main-bottom-panel', 'main-middle-panel']
- let cssUpdateFunction = this.errorMessages.length > 0
- ? this.openValidationMessagesOnIds(ids)
- : this.closeValidationMessagesOnIds(ids)
+ let cssUpdateFunction = this.messages
+ ? this.openMessagesOnIds(ids)
+ : this.closeMessagesOnIds(ids)
},
async validateTable() {
try {
@@ -575,11 +601,9 @@ export default {
})
},
created: function() {
- const vueForceUpdate = this.forceWrapper
const vueGuessProperties = this.updateColumnProperties
ipc.on('guessColumnProperties', function(event, arg) {
vueGuessProperties()
- vueForceUpdate()
})
const vueValidateTable = this.validateTable
ipc.on('validateTable', function(event, arg) {
diff --git a/src/renderer/frictionless.js b/src/renderer/frictionless.js
index 7b775731d..2f6633773 100644
--- a/src/renderer/frictionless.js
+++ b/src/renderer/frictionless.js
@@ -31,23 +31,19 @@ async function initDataAgainstSchema(data, schema) {
return table
}
-async function storeData(hotId, table) {
- await store.mutations.pushTableSchema(store.state, {
+function storeData(hotId, table) {
+ return store.mutations.pushTableSchema(store.state, {
hotId: hotId,
tableSchema: table
})
}
export async function guessColumnProperties() {
- console.log('about to guess...')
let activeHot = HotRegister.getActiveHotIdData()
let table = await initDataAndInferSchema(activeHot.data)
- await storeData(activeHot.id, table)
- // let tableDescriptor = table.schema.descriptor
- // return {
- // 'hotId': activeHot.id,
- // 'columnProperties': tableDescriptor.fields
- // }
+ let isStored = storeData(activeHot.id, table)
+ let message = isStored ? 'Success: Guess column properties succeeded.' : 'Failed: Guess column properties failed.'
+ return message
}
// function checkRowCells(row, schema) {
diff --git a/src/renderer/store/modules/hots.js b/src/renderer/store/modules/hots.js
index 9eebb979d..7cbd063f9 100644
--- a/src/renderer/store/modules/hots.js
+++ b/src/renderer/store/modules/hots.js
@@ -116,9 +116,9 @@ const mutations = {
pushTableSchema(state, hotTable) {
console.log('pushing table schema')
let hotId = hotTable.hotId
- _.set(state.hotTabs, `${hotId}.tableSchema`, hotTable.tableSchema)
- mutations.mergeTableSchemaOverCurrentColumnProperties(state, hotId)
- console.log(state.hotTabs)
+ let tableSchema = _.set(state.hotTabs, `${hotId}.tableSchema`, hotTable.tableSchema)
+ let columnProperties = mutations.mergeTableSchemaOverCurrentColumnProperties(state, hotId)
+ return tableSchema && columnProperties
},
mergeTableSchemaOverCurrentColumnProperties(state, hotId) {
let hotTab = state.hotTabs[hotId]
@@ -126,7 +126,7 @@ const mutations = {
if (!hotTab.columnProperties) {
hotTab.columnProperties = []
}
- _.merge(hotTab.columnProperties, tableSchemaProperties)
+ return _.merge(hotTab.columnProperties, tableSchemaProperties)
},
mergeCurrentColumnPropertiesOverTableSchema(state, hotId) {
let hotTab = state.hotTabs[hotId]
+
+
-
Validation errors
-
- row no.{{errorMessage.rowNumber}}: {{errorMessage.message}}
-
+ {{messagesTitle}}
+ +
+ row no.{{errorMessage.rowNumber}}: {{errorMessage.message}}
+
+
+
+ {{messages}}
+