Skip to content

Commit

Permalink
Inbox: Fix error when deleting, add ability to set custom ID (#775)
Browse files Browse the repository at this point in the history
Fixes #744.
Closes #474.

Signed-off-by: Yannick Schaus <[email protected]>
  • Loading branch information
ghys authored Jan 8, 2021
1 parent 6026e93 commit 874af99
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,26 @@ export default {
entry.label)
}
},
{
text: 'Add as Thing (with custom ID)',
color: 'blue',
bold: true,
onClick: () => {
this.$f7.dialog.prompt(`This will create a new Thing of type ${entry.thingTypeUID}. You can change the suggested thing ID below:`,
'Add as Thing',
(newThingId) => {
this.$f7.dialog.prompt(`Enter the desired name of the new Thing:`,
'Add as Thing',
(name) => {
this.approveEntry(entry, name, newThingId)
},
null,
entry.label)
},
null,
entry.thingUID.substring(entry.thingUID.indexOf(':', entry.thingUID.indexOf(':') + 1) + 1))
}
},
{
text: (!ignored) ? 'Ignore' : 'Unignore',
color: (!ignored) ? 'orange' : 'blue',
Expand Down Expand Up @@ -263,8 +283,8 @@ export default {
actions.open()
},
approveEntry (entry, name) {
this.$oh.api.postPlain(`/rest/inbox/${entry.thingUID}/approve`, name).then((res) => {
approveEntry (entry, name, newThingId) {
this.$oh.api.postPlain(`/rest/inbox/${entry.thingUID}/approve${newThingId ? '?newThingId=' + newThingId : ''}`, name).then((res) => {
this.$f7.toast.create({
text: 'Entry approved',
destroyOnClose: true,
Expand Down Expand Up @@ -321,14 +341,14 @@ export default {
destroyOnClose: true,
closeTimeout: 2000
}).open()
self.load()
this.load()
}).catch((err) => {
this.$f7.toast.create({
text: 'Error while removing entry: ' + err,
destroyOnClose: true,
closeTimeout: 2000
}).open()
self.load()
this.load()
})
},
toggleIgnored () {
Expand Down

0 comments on commit 874af99

Please sign in to comment.