mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-23 13:45:33 +02:00
🚧 Able to display form data from schema
This commit is contained in:
parent
716bb7419a
commit
677f0eea4e
@ -2,18 +2,29 @@
|
|||||||
<modal
|
<modal
|
||||||
:name="modalName"
|
:name="modalName"
|
||||||
:resizable="true"
|
:resizable="true"
|
||||||
width="55%"
|
width="50%"
|
||||||
height="80%"
|
height="50%"
|
||||||
classes="dashy-modal edit-item"
|
classes="dashy-modal edit-item"
|
||||||
@closed="modalClosed"
|
@closed="modalClosed"
|
||||||
>
|
>
|
||||||
<span>Item Editor</span>
|
<h3>Edit Item</h3>
|
||||||
<input />
|
<form>
|
||||||
|
<div class="row" v-for="row in formData" :key="row.name">
|
||||||
|
<Input
|
||||||
|
:label="row.name"
|
||||||
|
:value="row.value"
|
||||||
|
:description="row.description"
|
||||||
|
layout="horizontal"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</modal>
|
</modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Input from '@/components/FormElements/Input';
|
||||||
import StoreKeys from '@/utils/StoreMutations';
|
import StoreKeys from '@/utils/StoreMutations';
|
||||||
|
import DashySchema from '@/utils/ConfigSchema';
|
||||||
import { modalNames } from '@/utils/defaults';
|
import { modalNames } from '@/utils/defaults';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -21,24 +32,64 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
modalName: modalNames.EDIT_ITEM,
|
modalName: modalNames.EDIT_ITEM,
|
||||||
|
schema: DashySchema.properties.sections.items.properties.items.items.properties,
|
||||||
|
formData: [],
|
||||||
|
item: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {},
|
props: {
|
||||||
|
itemId: String,
|
||||||
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
components: {},
|
components: {
|
||||||
|
Input,
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.item = this.getItemFromState(this.itemId);
|
||||||
|
this.formData = this.makeInitialFormData();
|
||||||
this.$modal.show(modalNames.EDIT_ITEM);
|
this.$modal.show(modalNames.EDIT_ITEM);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
makeInitialFormData() {
|
||||||
|
const formData = [];
|
||||||
|
Object.keys(this.schema).forEach((property) => {
|
||||||
|
if (this.item[property]) {
|
||||||
|
formData.push({
|
||||||
|
name: property,
|
||||||
|
description: this.schema[property].description,
|
||||||
|
value: this.item[property] || '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return formData;
|
||||||
|
},
|
||||||
|
getItemFromState(id) {
|
||||||
|
return this.$store.getters.getItemById(id);
|
||||||
|
},
|
||||||
modalClosed() {
|
modalClosed() {
|
||||||
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);
|
this.$store.commit(StoreKeys.SET_MODAL_OPEN, false);
|
||||||
|
this.$emit('closeEditMenu');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style lang="scss">
|
||||||
@import '@/styles/style-helpers.scss';
|
@import '@/styles/style-helpers.scss';
|
||||||
@import '@/styles/media-queries.scss';
|
@import '@/styles/media-queries.scss';
|
||||||
|
|
||||||
|
.edit-item {
|
||||||
|
padding: 1rem;
|
||||||
|
background: var(--config-settings-background);
|
||||||
|
color: var(--config-settings-color);
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
|
.row {
|
||||||
|
padding: 0.5rem 0.25rem;
|
||||||
|
&:not(:last-child) {
|
||||||
|
border-bottom: 1px dotted var(--config-settings-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
@launchItem="launchItem"
|
@launchItem="launchItem"
|
||||||
@openItemSettings="openItemSettings"
|
@openItemSettings="openItemSettings"
|
||||||
/>
|
/>
|
||||||
<EditItem v-if="editMenuOpen" />
|
<EditItem v-if="editMenuOpen" :itemId="id" @closeEditMenu="closeEditMenu" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -226,6 +226,10 @@ export default {
|
|||||||
this.$modal.show(modalNames.EDIT_ITEM);
|
this.$modal.show(modalNames.EDIT_ITEM);
|
||||||
this.$store.commit(StoreKeys.SET_MODAL_OPEN, true);
|
this.$store.commit(StoreKeys.SET_MODAL_OPEN, true);
|
||||||
},
|
},
|
||||||
|
/* Ensure conditional is updated, once menu closed */
|
||||||
|
closeEditMenu() {
|
||||||
|
this.editMenuOpen = false;
|
||||||
|
},
|
||||||
/* Used for smart-sort when sorting items by most used apps */
|
/* Used for smart-sort when sorting items by most used apps */
|
||||||
incrementMostUsedCount(itemId) {
|
incrementMostUsedCount(itemId) {
|
||||||
const mostUsed = JSON.parse(localStorage.getItem(localStorageKeys.MOST_USED) || '{}');
|
const mostUsed = JSON.parse(localStorage.getItem(localStorageKeys.MOST_USED) || '{}');
|
||||||
@ -298,7 +302,7 @@ export default {
|
|||||||
/* Text in tile */
|
/* Text in tile */
|
||||||
.tile-title {
|
.tile-title {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
// overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user