Fix model item creation, API explorer (#821)

Signed-off-by: Yannick Schaus <github@schaus.net>
3.0.x
Yannick Schaus 2021-01-18 16:25:40 +01:00
parent d6d63cfa11
commit 6fe442fe91
2 changed files with 5 additions and 3 deletions

View File

@ -54,6 +54,7 @@ export default {
this.createMode = false
this.forceSemantics = false
if (this.model.item.created === false) {
this.$set(this, 'editedItem', Object.assign({}, this.model.item))
this.createMode = true
if (this.model.item.metadata && this.model.item.metadata.semantics) {
this.forceSemantics = true
@ -75,14 +76,15 @@ export default {
this.editMode = false
// TODO properly validate item
if (!this.model.item.name) return
if (!this.editedItem.name) return
this.$oh.api.put('/rest/items/' + this.model.item.name, this.model.item).then((data) => {
this.$oh.api.put('/rest/items/' + this.editedItem.name, this.editedItem).then((data) => {
this.$f7.toast.create({
text: 'Item created',
destroyOnClose: true,
closeTimeout: 2000
}).open()
this.$set(this.model, 'item', JSON.parse(data))
this.model.item.created = true
this.model.item.editable = true
this.$emit('item-created', this.model.item)

View File

@ -85,7 +85,7 @@ export function storeBasicCredentials () {
export function setAccessToken (token, api) {
accessToken = token
if (!token || !api || requireToken !== undefined) return
if (!token || !api || requireToken !== undefined) return Promise.resolve()
// determine whether the token is required for user operations
return api.head('/rest/sitemaps').then((resp) => {