Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
fix: not being able to define a workflow setting
Browse files Browse the repository at this point in the history
  • Loading branch information
moranje committed Oct 5, 2018
1 parent c6650c8 commit 5c042ea
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 41 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -71,6 +71,7 @@
"CHANGELOG.md",
"package.json",
"package-lock.json",
"dist/workflow/info.plist",
"dist/Alfred Workflow Todoist.alfredworkflow"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
Expand Down
92 changes: 51 additions & 41 deletions src/workflow/settings.ts
Expand Up @@ -27,7 +27,7 @@ const SettingsList = compose(
init(this: List, { settings }: { settings: Settings }) {
this.items = this.items || []

Object.keys(settings).forEach((key: string) => {
Object.keys(Schema.properties).forEach((key: string) => {
if (key !== 'uuid') {
this.items.push(
Item({
Expand Down Expand Up @@ -55,50 +55,60 @@ const SettingList = compose(
}: { key: string; value: string | number | boolean; settings: Settings }
) {
this.items = this.items || []
let subtitle = `Current value: ${settings[key]}`
let valid = '\u2713'

// Type cast value to a number
if (Schema.properties[key].type === 'number') {
value = +value
}

if (!isValid(key, value, settings)) {
subtitle += ` (${Schema.properties[key].explanation})`
valid = '\u2715'
}

if (Schema.properties[key].type === 'boolean') {
this.items.push(
Item({
title: 'New: true',
subtitle: `Current value: ${settings[key]}`,
arg: { key, value: true }
})
)
this.items.push(
Item({
title: 'New: false ',
subtitle: `Current value: ${settings[key]}`,
arg: { key, value: false }
})
)
} else if (Schema.properties[key].type === 'string') {
this.items.push(
Item({
title: `New: ${value} (${valid})`,
subtitle,
arg: { key, value }
})
)
} else if (Schema.properties[key].type === 'number') {
if (!Schema.properties[key]) {
this.items.push(
Item({
title: `New: ${value} (${valid})`,
subtitle,
arg: { key, value: +value }
title: `NO SUCH SETTING`,
subtitle: `Alas, but dust yourself off and try again`,
valid: false
})
)
} else {
let subtitle = `Current value: ${settings[key]}`
let valid = '\u2713'

// Type cast value to a number
if (Schema.properties[key].type === 'number') {
value = +value
}

if (!isValid(key, value, settings)) {
subtitle += ` (${Schema.properties[key].explanation})`
valid = '\u2715'
}

if (Schema.properties[key].type === 'boolean') {
this.items.push(
Item({
title: 'New: true',
subtitle: `Current value: ${settings[key]}`,
arg: { key, value: true }
})
)
this.items.push(
Item({
title: 'New: false ',
subtitle: `Current value: ${settings[key]}`,
arg: { key, value: false }
})
)
} else if (Schema.properties[key].type === 'string') {
this.items.push(
Item({
title: `New: ${value} (${valid})`,
subtitle,
arg: { key, value }
})
)
} else if (Schema.properties[key].type === 'number') {
this.items.push(
Item({
title: `New: ${value} (${valid})`,
subtitle,
arg: { key, value: +value }
})
)
}
}
}
}
Expand Down

0 comments on commit 5c042ea

Please sign in to comment.