main
HerrHase 2 years ago
parent a57724e43a
commit b7fdfb042c

@ -18,7 +18,6 @@
* @link https://gitea.node001.net/HerrHase/potato-launcher.git
*
*/
export default {
/**

@ -108,6 +108,9 @@ class AppsDatabase extends DatabaseHandler {
find(parameters) {
const query = {
'selector': {
},
'fields': [
'_id',
'_rev',

@ -1,4 +1,5 @@
import DatabaseHandler from './databaseHandler.js'
import AppsStore from './apps.js'
/**
* apps
@ -40,28 +41,69 @@ class TagsDatabase extends DatabaseHandler {
// check for existings tags and remove
// adding tags that are not removed
this.db.find(query).then((documents) => {
if (documents.docs.length > 0) {
documents.docs.forEach((data) => {
return this.filterTags(documents, tags)
}).then(async (tags) => {
if (tags.length > 0) {
// getting
const index = tags.indexOf(data.name)
// adding tags to entries
for (let i = 0; i < tags.length; i++) {
await this.db.post({
'name': tags[i]
})
}
if (index >= 0) {
tags.splice(index, 1)
}
})
this.removeNotNeeded()
}
})
}
if (tags.length > 0) {
tags.forEach((tag) => {
this.db.post({
'name': tag
})
/**
*
*
*/
removeNotNeeded() {
this.find().then((tags) => {
const appsStore = new AppsStore()
for (let i = 0; i < tags.length; i++) {
const parameters = {
tags: []
}
parameters.tags.push(tags[i].name)
appsStore.find(parameters).then((documents) => {
if (!documents) {
this.db.remove(tags[i])
}
})
}
})
}
/**
* filter tags, if they are already exists
*
* @param {array} documents
* @param {array} tags
* @return {array}
*
*/
filterTags(documents, tags) {
if (documents.docs.length > 0) {
for (let i; i < documents.docs.length; i++) {
const index = tags.indexOf(documents.docs[i].name)
if (index >= 0) {
tags.splice(index, 1)
}
}
}
return tags
}
/**
* find apps
*

@ -18,8 +18,9 @@
<div class="field-group">
<label class="field-label">
name*
<input type="text" class="field-text" name="name" value="{ state.current.name ? state.current.name : '' }" />
<input type="text" class="field-text" name="name" value={ state.current.name } />
</label>
<field-error name="name"></field-error>
</div>
<!-- command -->
@ -27,7 +28,7 @@
<label class="field-label">
command*
<div class="field-input-group">
<input class="field-text" type="text" name="command" value="{ state.current.command ? state.current.command : '' }" />
<input class="field-text" type="text" name="command" value="{ state.current.command }" />
<button class="button button--hover-icon-contrast m-bottom-0" type="button" onclick={ (event) => { handleOpenCommand(event) }}>
<svg class="icon">
<use xlink:href="symbol-defs.svg#icon-folder" />
@ -52,7 +53,7 @@
<div class="field-group">
<label class="field-label">
description
<textarea class="field-text" name="description" value="{ state.current.description ? state.current.description : '' }"></textarea>
<textarea class="field-text" name="description" value="{ state.current.description }"></textarea>
</label>
</div>
@ -124,6 +125,12 @@
...sidebarMixin, // adding basic funtion for sidebar
state: {
open: false, // if sidebar is open
loading: false, // if loading is shown
current: false
},
/**
*
*
@ -133,15 +140,17 @@
// adding event for open sidebar
formStore.on('open', (id) => {
this.reset()
tagsStore.trigger('update', [])
this.state.current = false
this.state.open = true
// if id is send, load apps from pouchdb
if (id) {
appsStore.getOne(id)
} else {
this.update()
}
this.state.open = true
this.update()
})
// creating formValidator
@ -228,6 +237,7 @@
handleSuccess(event, data) {
event.preventDefault()
this.state.current = data
this.state.loading = true
this.update()
@ -297,18 +307,6 @@
*/
toImage(media) {
return 'data:image/png;base64,' + media
},
/**
* reset data of current form
*
*/
reset() {
this.state.current = {
}
tagsStore.trigger('update', [])
}
}
}

@ -9,21 +9,12 @@
export default {
state: {
open: false, // if sidebar is open
loading: false, // if loading is shown
current: { // current data of form
}
},
/**
* close current sidebar
*
*
*/
handleClose() {
this.reset()
this.state.open = false
this.update()
},
@ -32,7 +23,6 @@ export default {
* getting css classes for sidebar
*
*
* @return {String}
*/
getCssClasses() {
const classes = [
@ -44,17 +34,5 @@ export default {
}
return classes.join(' ')
},
/**
*
*
*/
onBeforeMount() {
if (!this.hasOwnProperty('reset')) {
throw new Error('reset-Function in Form is missing')
}
this.reset()
}
}
Loading…
Cancel
Save