Add more components + base for history
This commit is contained in:
@@ -2,18 +2,40 @@
|
||||
|
||||
<div>
|
||||
<div class="card mt-4 pt-2 ps-lg-2">
|
||||
<h5 class="card-header">{% trans "Properties" %} [[ this.$route.params.id ]]</h5>
|
||||
<h5 class="card-header">{% trans "Item" %} [[ this.$route.params.id ]]</h5>
|
||||
<div class="card-body">
|
||||
<PropertyList
|
||||
:items="properties"
|
||||
:items_headers="properties_headers"
|
||||
:items_relations="{}"
|
||||
:hidden_fields="[]"
|
||||
|
||||
<v-container fluid v-if="object">
|
||||
<template v-for="field in headers">
|
||||
<v-row v-if="field.details">
|
||||
<v-col cols="4">
|
||||
<v-subheader>[[ field.text ]]</v-subheader>
|
||||
</v-col>
|
||||
<v-col cols="8">
|
||||
<v-text-field :value="object[field.value]" readonly dense></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
</v-container>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4 pt-2 ps-lg-2">
|
||||
<h5 class="card-header">{% trans "Properties" %}</h5>
|
||||
<div class="card-body">
|
||||
<LinkedPropertyList
|
||||
:items="linked_properties"
|
||||
:items_headers="linked_properties_headers"
|
||||
:items_relations="{'property': all_properties}"
|
||||
:hidden_fields="['name', 'description', 'custom_identifier']"
|
||||
:non_editable_fields="['item']"
|
||||
show_item="property"
|
||||
group_by="type"
|
||||
@deleteItem="deleteItem"
|
||||
@createItem="createItem"
|
||||
@editItem="editItem"
|
||||
></PropertyList>
|
||||
@deleteItem="deleteLinkedProperty"
|
||||
@createItem="createLinkedProperty"
|
||||
@editItem="editLinkedProperty"
|
||||
></LinkedPropertyList>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,12 +45,12 @@
|
||||
<ItemRelationList
|
||||
:items="children"
|
||||
:items_headers="children_headers"
|
||||
:items_relations="{}"
|
||||
:hidden_fields="['parent__name']"
|
||||
:items_relations="{'parent': [object], 'child': all_items}"
|
||||
group_by="type__name"
|
||||
@deleteItem="deleteItem"
|
||||
@createItem="createItem"
|
||||
@editItem="editItem"
|
||||
@deleteItem="deleteRelation"
|
||||
@createItem="createRelation"
|
||||
@editItem="editRelation"
|
||||
></ItemRelationList>
|
||||
</div>
|
||||
</div>
|
||||
@@ -38,13 +60,13 @@
|
||||
<div class="card-body">
|
||||
<ItemRelationList
|
||||
:items="parents"
|
||||
:items_headers="parents_headers"
|
||||
:items_relations="{}"
|
||||
:items_headers="children_headers"
|
||||
:hidden_fields="['child__name']"
|
||||
:items_relations="{'child': [object], 'parent': all_items}"
|
||||
group_by="type__name"
|
||||
@deleteItem="deleteItem"
|
||||
@createItem="createItem"
|
||||
@editItem="editItem"
|
||||
@deleteItem="deleteRelation"
|
||||
@createItem="createRelation"
|
||||
@editItem="editRelation"
|
||||
></ItemRelationList>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,95 +3,109 @@ ItemDetail = {
|
||||
router_path: "/ItemDetail/:id",
|
||||
delimiters: ["[[", "]]"],
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
properties: [],
|
||||
linked_properties: [],
|
||||
children: [],
|
||||
parents: [],
|
||||
// TODO: Also remove this tedious things
|
||||
properties_headers: [],
|
||||
linked_properties_headers: [],
|
||||
children_headers: [],
|
||||
parents_headers: [],
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
// TODO: Remove this by a generic things at some points, this become tedious and repetitive
|
||||
properties_efields: function() {
|
||||
return this.properties_headers.filter(e => e.encrypted).map(e => e.value)
|
||||
object: function() {
|
||||
return this.$store.state.items.items.find(i => i.id == this.$route.params.id)
|
||||
},
|
||||
|
||||
linked_properties_efields: function() {
|
||||
return this.linked_properties_headers.filter(e => e.encrypted).map(e => e.value)
|
||||
linked_properties: function() {
|
||||
return this.$store.state.linkedProperties.items.filter(lp => lp.item == this.$route.params.id)
|
||||
},
|
||||
|
||||
children_efields: function() {
|
||||
return this.children_headers.filter(e => e.encrypted).map(e => e.value)
|
||||
linked_properties_headers: function() {
|
||||
return this.$store.state.linkedProperties.headers
|
||||
},
|
||||
|
||||
parents_efields: function() {
|
||||
return this.parents_headers.filter(e => e.encrypted).map(e => e.value)
|
||||
properties: function() {
|
||||
return this.$store.state.properties.items.filter(p => this.linked_properties.map(e => e.property).includes(p.id))
|
||||
},
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
properties_headers: function() {
|
||||
return this.$store.state.properties.headers
|
||||
},
|
||||
|
||||
this.reload()
|
||||
children: function() {
|
||||
return this.$store.state.relations.items.filter(p => p.parent == this.$route.params.id)
|
||||
},
|
||||
|
||||
parents: function() {
|
||||
return this.$store.state.relations.items.filter(p => p.child == this.$route.params.id)
|
||||
},
|
||||
|
||||
children_headers: function() {
|
||||
return this.$store.state.relations.headers
|
||||
},
|
||||
|
||||
headers: function() {
|
||||
return this.$store.state.items.headers
|
||||
},
|
||||
|
||||
all_items: function() {
|
||||
return this.$store.state.items.items
|
||||
},
|
||||
|
||||
all_properties: function() {
|
||||
return this.$store.state.properties.items
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
async reload () {
|
||||
|
||||
try {
|
||||
|
||||
const response = await this.$http.get(Urls["items:details"](this.$route.params.id))
|
||||
|
||||
this.properties_headers = response.data.properties_headers
|
||||
this.linked_properties_headers = response.data.linked_properties_headers
|
||||
this.children_headers = response.data.children_headers
|
||||
this.parents_headers = response.data.parents_headers
|
||||
|
||||
// TODO: TEDIOUUUUUS
|
||||
response.data.parents.forEach(async e => {
|
||||
this.parents.push(await this.decryptObject(this.parents_efields, e))
|
||||
})
|
||||
|
||||
response.data.children.forEach(async e => {
|
||||
this.children.push(await this.decryptObject(this.children_efields, e))
|
||||
})
|
||||
|
||||
response.data.properties.forEach(async e => {
|
||||
this.properties.push(await this.decryptObject(this.properties_efields, e))
|
||||
})
|
||||
|
||||
response.data.linked_properties.forEach(async e => {
|
||||
this.linked_properties.push(await this.decryptObject(this.linked_properties_efields, e))
|
||||
})
|
||||
|
||||
} catch (err) {
|
||||
|
||||
Swal.fire({title: "{{_('Error during loading of items') | escapejs}}", icon: "error", position:"top-end", showConfirmButton: false, toast: true, timer: 1000})
|
||||
|
||||
throw err
|
||||
|
||||
}
|
||||
|
||||
linkedPropertyEdition (method, item) {
|
||||
return this.object_edit("items:linked.property.edit", "items:linked.property.create", 'linkedProperties', method, item)
|
||||
},
|
||||
|
||||
async deleteItem () {
|
||||
|
||||
relationPropertiesEdition (method, item) {
|
||||
return this.object_edit("items:relation.property.edit", "items:relation.property.create", 'relationProperties', method, item)
|
||||
},
|
||||
|
||||
async createItem () {
|
||||
|
||||
relationEdition (method, item) {
|
||||
return this.object_edit("items:relation.edit", "items:relation.create", 'relations', method, item)
|
||||
},
|
||||
|
||||
async editItem() {
|
||||
|
||||
async deleteLinkedProperty (item) {
|
||||
await this.linkedPropertyEdition("delete", item)
|
||||
this.$store.commit("linkedProperties/removeItem", item.id)
|
||||
},
|
||||
|
||||
async createLinkedProperty (item) {
|
||||
item.item = this.$route.params.id
|
||||
const new_item = await this.linkedPropertyEdition("post", item)
|
||||
this.$store.commit("linkedProperties/addItem", new_item)
|
||||
},
|
||||
|
||||
async editLinkedProperty (item) {
|
||||
item.item = this.$route.params.id
|
||||
const new_item = await this.linkedPropertyEdition("post", item)
|
||||
this.$store.commit("linkedProperties/editItem", new_item)
|
||||
},
|
||||
|
||||
async deleteProperty (item) {
|
||||
console.log(item)
|
||||
},
|
||||
|
||||
async createProperty (item) {
|
||||
console.log(item)
|
||||
},
|
||||
|
||||
async editProperty (item) {
|
||||
console.log(item)
|
||||
},
|
||||
|
||||
async deleteRelation (item) {
|
||||
await this.relationEdition("delete", item)
|
||||
this.$store.commit("relations/removeItem", item.id)
|
||||
},
|
||||
|
||||
async createRelation (item) {
|
||||
const new_item = await this.relationEdition("post", item)
|
||||
this.$store.commit("relations/addItem", new_item)
|
||||
},
|
||||
|
||||
async editRelation (item) {
|
||||
const new_item = await this.relationEdition("post", item)
|
||||
this.$store.commit("relations/editItem", new_item)
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user