Skip to content

Commit

Permalink
Accept json files on item import
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jan 21, 2020
1 parent 2d0b2ad commit 8deafe4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/actions/item.js
Expand Up @@ -25,7 +25,7 @@ module.exports = {
history: 'add',
cancel: true,
search: true,
prompt: true,
prompt: 'items',
...meta
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/photo.js
Expand Up @@ -30,7 +30,7 @@ module.exports = {
cancel: true,
cmd: 'project',
history: 'add',
prompt: true,
prompt: 'images',
...meta
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/commands/import.js
Expand Up @@ -44,6 +44,8 @@ class ImportCommand extends Command {
switch (type) {
case 'dir':
return open.dir()
case 'items':
return open.items()
default:
return open.images()
}
Expand All @@ -63,12 +65,14 @@ class ImportCommand extends Command {
if (!files.length && !urls.length && meta.prompt)
files = await this.promptForFilesToImport(meta.prompt)

files = await dir.expand(files, {
let json = files.filter(f => (/^\.json(ld)?$/i).test(extname(f)))

let images = await dir.expand(files, {
filter: this.canImportFile,
recursive: true
})

return [...files, ...urls]
return [...json, ...images, ...urls]
}

*openImage(path) {
Expand Down
30 changes: 20 additions & 10 deletions src/dialog.js
Expand Up @@ -98,38 +98,48 @@ function save(options) {
return show('save', options)
}

function open(options) {
return show('file', options)
function open(opts) {
return show('file', opts)
}

open.images = (options) => open({
open.images = (opts) => open({
filters: [{
name: t('dialog', 'filter', 'images'),
extensions: IMAGE.EXT
}],
defaultPath: ARGS.pictures,
properties: ['openFile', 'multiSelections'],
...options
...opts
})

open.image = (options) => open.images({
open.items = (opts) => open({
filters: [{
name: t('dialog', 'filter', 'items'),
extensions: [...IMAGE.EXT, 'json', 'jsonld']
}],
defaultPath: ARGS.pictures,
properties: ['openFile', 'multiSelections'],
...opts
})

open.image = (opts) => open.images({
properties: ['openFile'],
...options
...opts
})

open.dir = (options) => open({
open.dir = (opts) => open({
properties: ['openDirectory', 'multiSelections'],
...options
...opts
})

open.vocab = (options) => open({
open.vocab = (opts) => open({
filters: [{
name: t('dialog', 'filter', 'rdf'),
extensions: ['n3', 'ttl']
}],
defaultPath: ARGS.documents,
properties: ['openFile', 'multiSelections'],
...options
...opts
})

open.templates = (options) => open({
Expand Down

0 comments on commit 8deafe4

Please sign in to comment.