Skip to content

Commit

Permalink
Merge branch 'release/0.5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mulholland committed Nov 29, 2017
2 parents ad0b1a3 + 8cfefe3 commit 679323f
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 158 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DataCurator",
"version": "0.5.3",
"version": "0.5.4",
"author": " <matt@redboxresearchdata.com.au>",
"description": "Data Curator is a simple desktop CSV editor to help describe, validate and share usable open data",
"license": "MIT",
Expand Down
149 changes: 78 additions & 71 deletions src/main/menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import {openFile, saveFileAs, saveFile, importDataPackage} from './file.js'
import {guessColumnProperties, createWindowTab, validateTable, showSidePanel, toggleActiveHeaderRow} from './utils.js'
import {
guessColumnProperties,
createWindowTab,
validateTable,
showSidePanel,
toggleActiveHeaderRow,
triggerMenuButton
} from './utils.js'
import {importExcel} from './excel.js'
import {showKeyboardHelp} from './help.js'
import {fileFormats} from '../renderer/file-formats.js'
Expand Down Expand Up @@ -128,54 +135,50 @@ const template = [
label: 'Edit',
submenu: [
{
// role: 'undo',
// turned off for Beta release
label: 'Undo',
enabled: false,
accelerator: 'CmdOrCtrl+Z'
accelerator: 'CmdOrCtrl+Z',
click() {
BrowserWindow.getFocusedWindow().webContents.send('editUndo')
}
}, {
// role: 'redo',
// turned off for Beta release
label: 'Redo',
enabled: false,
accelerator: process.platform === 'darwin'
? 'Shift+CmdOrCtrl+Z'
: 'CmdOrCtrl+Y'
}, {
: 'CmdOrCtrl+Y',
click() {
BrowserWindow.getFocusedWindow().webContents.send('editRedo')
}
},
{
type: 'separator'
}, {
// role: 'cut',
// turned off for Beta release
},
// electron roles for copy/cut/paste seem to be more reliable than equivalent for hot
{
role: 'cut',
label: 'Cut',
enabled: false,
accelerator: 'CmdOrCtrl+X'
}, {
},
{
role: 'copy',
// turned off for Beta release
// label: 'Copy',
// enabled: true,
// accelerator: 'CmdOrCtrl+C',
click() {
BrowserWindow.getFocusedWindow().webContents.send('editCopy')
}
}, {
label: 'Copy',
accelerator: 'CmdOrCtrl+C'
},
{
role: 'paste',
// turned off for Beta release
// label: 'Paste',
// enabled: true,
// accelerator: 'CmdOrCtrl+V',
click() {
BrowserWindow.getFocusedWindow().webContents.send('editPaste')
}
}, {
// turned off for Beta release
// role: 'selectall',
label: 'Select All',
enabled: false,
accelerator: 'CmdOrCtrl+A'
}, {
label: 'Paste',
accelerator: 'CmdOrCtrl+V'
},
// {
// // turned off for Beta release
// // role: 'selectall',
// label: 'Select All',
// enabled: false,
// accelerator: 'CmdOrCtrl+A'
// },
{
type: 'separator'
}, {
},
{
label: 'Insert Row Above',
accelerator: 'CmdOrCtrl+I',
click() {
Expand Down Expand Up @@ -275,8 +278,7 @@ const template = [
menuItem.checked = !menuItem.checked
toggleActiveHeaderRow()
}
},
{
}, {
// Placeholder for future features
// }, {
// type: 'separator'
Expand Down Expand Up @@ -310,37 +312,42 @@ const template = [
type: 'separator'
}, {
label: 'Set Column Properties',
enabled: false
click() {
triggerMenuButton('Column')
}
}, {
label: 'Set Table Properties',
enabled: false
click() {
triggerMenuButton('Table')
}
}, {
// Placeholder for future features
// label: 'Set View Properties',
// enabled: false
// , icon: '/static/img/locked.svg'
// }, {
label: 'Set Provenance Information',
enabled: false
click() {
triggerMenuButton('Provenance')
}
}, {
// Placeholder for future features
// label: 'Generate Data Quality Information',
// enabled: false
// , icon: '/static/img/locked.svg'
// }, {
label: 'Set Data Package Properties',
enabled: false
click() {
triggerMenuButton('Package')
}
}, {
type: 'separator'
}, {
// TO DO: Conditionally enabled based on required properties being set and no changes since last successful validation
label: 'Export Data Package...',
accelerator: 'CmdOrCtrl+D',
// turned off for Beta release
enabled: false
// click: function() {
// datapackage.exportdata()
// }
click() {
triggerMenuButton('Export')
}
}
// Placeholder for future features
// , {
Expand Down Expand Up @@ -432,17 +439,15 @@ const template = [
}
]

// Tailor menu for Windows - add About to Help menu
if (process.platform !== 'darwin') {
template[4].submenu.push({
type: 'separator'
}, {
label: 'About Data Curator',
click: function() {
showSidePanel('about')
}
})
}
// Tailor menu for Windows - add About to Help menu if (process.platform !== 'darwin') {
template[4].submenu.push({
type: 'separator'
}, {
label: 'About Data Curator',
click: function() {
showSidePanel('about')
}
})

// Tailor menu for macOS
if (process.platform === 'darwin') {
Expand All @@ -454,15 +459,15 @@ if (process.platform === 'darwin') {
click: function() {
showSidePanel('about')
}
// Placeholder for future feature
// }, {
// type: 'separator'
// }, {
// label: 'Preferences'
// accelerator: 'CmdOrCtrl+,',
// click: function() {
// showSidePanel('preferences')
// }
// Placeholder for future feature
// }, {
// type: 'separator'
// }, {
// label: 'Preferences'
// accelerator: 'CmdOrCtrl+,',
// click: function() {
// showSidePanel('preferences')
// }
}, {
type: 'separator'
}, {
Expand Down Expand Up @@ -526,4 +531,6 @@ if (process.env.NODE_ENV !== 'production') {
})
}

export {template as menu}
export {
template as menu
}
5 changes: 5 additions & 0 deletions src/main/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export function guessColumnProperties() {
window.webContents.send('guessColumnProperties')
}

export function triggerMenuButton(name) {
let window = BrowserWindow.getFocusedWindow()
window.webContents.send('triggerMenuButton', name)
}

export function validateTable() {
let window = BrowserWindow.getFocusedWindow()
window.webContents.send('validateTable')
Expand Down
34 changes: 27 additions & 7 deletions src/renderer/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ export default {
loadingDataMessage: false,
sideNavFormHeight: '300px',
toolbarMenus: [{
name: 'Validate',
image: 'static/img/validate.svg',
tooltipId: 'tooltip-validate',
tooltipView: 'tooltipValidate'
name: 'Guess',
image: 'static/img/guess-column-properties.svg',
tooltipId: 'tooltip-guess',
tooltipView: 'tooltipGuess'
},
{
name: 'Column',
Expand Down Expand Up @@ -223,6 +223,12 @@ export default {
sideNavPosition: 'right',
sideNavView: 'packager'
},
{
name: 'Validate',
image: 'static/img/validate.svg',
tooltipId: 'tooltip-validate',
tooltipView: 'tooltipValidate'
},
{
name: 'Export',
image: 'static/img/export.svg',
Expand All @@ -239,7 +245,7 @@ export default {
activeTab: 'getActiveTab',
tabIndex: 'getTabIndex'
}),
...mapGetters(['getPreviousTabId', 'tabTitle', 'getHotIdFromTabId', 'getAllHotTablesColumnNames']),
...mapGetters(['getPreviousTabId', 'tabTitle', 'getHotIdFromTabId']),
sideNavPropertiesForMain() {
return this.sideNavStatus === 'closed' ? this.sideNavStatus : this.sideNavPosition
},
Expand Down Expand Up @@ -284,7 +290,7 @@ export default {
this.updateActiveColumn()
this.resetSideNavArrows()
},
updateColumnProperties: async function() {
inferColumnProperties: async function() {
try {
let feedback = await guessColumnProperties()
this.messages = feedback
Expand Down Expand Up @@ -320,6 +326,7 @@ export default {
this.reportFeedback()
},
reportFeedback: function() {
// console.log('updating feedback...')
let ids = ['main-bottom-panel', 'main-middle-panel']
let cssUpdateFunction = this.messages
? this.openMessagesOnIds(ids)
Expand Down Expand Up @@ -549,6 +556,9 @@ export default {
case 'Export':
this.createPackage()
break
case 'Guess':
this.inferColumnProperties()
break
default:
console.log(`Error: No case exists for menu index: ${index}`)
}
Expand Down Expand Up @@ -593,6 +603,12 @@ export default {
this.enableTransition = properties.enableTransition || false
this.sideNavStatus = 'open'
},
triggerMenuButton: function(menuName) {
let index = _.findIndex(this.toolbarMenus, function(o) {
return o.name.toLowerCase() === menuName.toLowerCase()
})
this.updateToolbarMenu(index)
},
forceWrapper: function() {
this.$forceUpdate()
},
Expand Down Expand Up @@ -641,6 +657,10 @@ export default {
}
},
mounted: function() {
const vueTriggerMenuButton = this.triggerMenuButton
ipc.on('triggerMenuButton', function(event, arg) {
vueTriggerMenuButton(arg)
})
const vueToggleHeader = this.toggleHeaderWithFeedback
ipc.on('toggleActiveHeaderRow', function() {
let hot = HotRegister.getActiveInstance()
Expand Down Expand Up @@ -692,7 +712,7 @@ export default {
})
},
created: function() {
const vueGuessProperties = this.updateColumnProperties
const vueGuessProperties = this.inferColumnProperties
ipc.on('guessColumnProperties', function(event, arg) {
vueGuessProperties()
})
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/frictionless.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {includeHeadersInData} from '@/frictionlessUtilities.js'
async function initDataAndInferSchema(data) {
const schema = await Schema.load({})
await schema.infer(data)
// console.log('returning from infer')
return schema
}

Expand All @@ -30,6 +31,7 @@ function storeData(hotId, schema) {
}

export async function guessColumnProperties() {
// console.log('guessing...')
let hot = HotRegister.getActiveInstance()
let id = hot.guid
let data = includeHeadersInData(hot)
Expand All @@ -39,6 +41,7 @@ export async function guessColumnProperties() {
let message = isStored
? 'Success: Guess column properties succeeded.'
: 'Failed: Guess column properties failed.'
console.log('returning from guess column properties...')
return message
}

Expand Down
1 change: 1 addition & 0 deletions src/renderer/hot.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let HotRegister = {
enterBeginsEditing: false,
persistentState: true,
outsideClickDeselects: false,
undo: true,
tabMoves({shiftKey}) {
if (!shiftKey) {
const selection = hot.getSelected()
Expand Down
Loading

0 comments on commit 679323f

Please sign in to comment.