V0.1
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
{% load i18n %}
|
||||
|
||||
<div>
|
||||
<div class="card mt-4 pt-2 ps-lg-2">
|
||||
<h5 class="card-header">{% trans "Properties" %} [[ this.$route.params.id ]]</h5>
|
||||
<div class="card-body">
|
||||
<PropertyList
|
||||
:items="properties"
|
||||
:items_headers="properties_headers"
|
||||
:items_relations="{}"
|
||||
:hidden_fields="[]"
|
||||
group_by="type"
|
||||
@deleteItem="deleteItem"
|
||||
@createItem="createItem"
|
||||
@editItem="editItem"
|
||||
></PropertyList>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4 pt-2 ps-lg-2">
|
||||
<h5 class="card-header">{% trans "Children" %}</h5>
|
||||
<div class="card-body">
|
||||
<ItemRelationList
|
||||
:items="children"
|
||||
:items_headers="children_headers"
|
||||
:items_relations="{}"
|
||||
:hidden_fields="['parent__name']"
|
||||
group_by="type__name"
|
||||
@deleteItem="deleteItem"
|
||||
@createItem="createItem"
|
||||
@editItem="editItem"
|
||||
></ItemRelationList>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4 pt-2 ps-lg-2">
|
||||
<h5 class="card-header">{% trans "Parents" %}</h5>
|
||||
<div class="card-body">
|
||||
<ItemRelationList
|
||||
:items="parents"
|
||||
:items_headers="parents_headers"
|
||||
:items_relations="{}"
|
||||
:hidden_fields="['child__name']"
|
||||
group_by="type__name"
|
||||
@deleteItem="deleteItem"
|
||||
@createItem="createItem"
|
||||
@editItem="editItem"
|
||||
></ItemRelationList>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,97 @@
|
||||
ItemDetail = {
|
||||
template: "#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)
|
||||
},
|
||||
|
||||
linked_properties_efields: function() {
|
||||
return this.linked_properties_headers.filter(e => e.encrypted).map(e => e.value)
|
||||
},
|
||||
|
||||
children_efields: function() {
|
||||
return this.children_headers.filter(e => e.encrypted).map(e => e.value)
|
||||
},
|
||||
|
||||
parents_efields: function() {
|
||||
return this.parents_headers.filter(e => e.encrypted).map(e => e.value)
|
||||
},
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
|
||||
this.reload()
|
||||
|
||||
},
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
async deleteItem () {
|
||||
|
||||
},
|
||||
|
||||
async createItem () {
|
||||
|
||||
},
|
||||
|
||||
async editItem() {
|
||||
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user