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.createMode = false
this.forceSemantics = false this.forceSemantics = false
if (this.model.item.created === false) { if (this.model.item.created === false) {
this.$set(this, 'editedItem', Object.assign({}, this.model.item))
this.createMode = true this.createMode = true
if (this.model.item.metadata && this.model.item.metadata.semantics) { if (this.model.item.metadata && this.model.item.metadata.semantics) {
this.forceSemantics = true this.forceSemantics = true
@ -75,14 +76,15 @@ export default {
this.editMode = false this.editMode = false
// TODO properly validate item // 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({ this.$f7.toast.create({
text: 'Item created', text: 'Item created',
destroyOnClose: true, destroyOnClose: true,
closeTimeout: 2000 closeTimeout: 2000
}).open() }).open()
this.$set(this.model, 'item', JSON.parse(data))
this.model.item.created = true this.model.item.created = true
this.model.item.editable = true this.model.item.editable = true
this.$emit('item-created', this.model.item) this.$emit('item-created', this.model.item)

View File

@ -85,7 +85,7 @@ export function storeBasicCredentials () {
export function setAccessToken (token, api) { export function setAccessToken (token, api) {
accessToken = token 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 // determine whether the token is required for user operations
return api.head('/rest/sitemaps').then((resp) => { return api.head('/rest/sitemaps').then((resp) => {