Add more components + base for history
This commit is contained in:
@@ -1 +1,55 @@
|
||||
<div>[[ this.$route.params.id ]]</div>
|
||||
{% load i18n %}
|
||||
|
||||
<div>
|
||||
<div class="card mt-4 pt-2 ps-lg-2">
|
||||
<h5 class="card-header">{% trans "Relation" %} [[ this.$route.params.id ]]</h5>
|
||||
<div class="card-body">
|
||||
|
||||
<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>
|
||||
<template v-if="field.value == 'parent' || field.value == 'child'">
|
||||
<v-col cols="7">
|
||||
<v-text-field :value="object[field.value]" readonly dense></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="1">
|
||||
<v-btn color="primary" dark class="mb-2" @click="showItem(object[field.value])">
|
||||
<v-icon small class="mr-2">mdi-eye</v-icon>
|
||||
{% trans "Link" %}
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<v-col cols="8">
|
||||
<v-text-field :value="object[field.value]" readonly dense></v-text-field>
|
||||
</v-col>
|
||||
</template>
|
||||
</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">
|
||||
<RelationPropertyList
|
||||
:items="relation_properties"
|
||||
:items_headers="relation_properties_headers"
|
||||
:items_relations="{'property': all_properties}"
|
||||
:hidden_fields="['name', 'description', 'custom_identifier', 'relation__name']"
|
||||
:non_editable_fields="['relation']"
|
||||
show_item="property"
|
||||
show_url="PropertyDetail"
|
||||
@deleteItem="deleteRelationProperty"
|
||||
@createItem="createRelationProperty"
|
||||
@editItem="editRelationProperty"
|
||||
></RelationPropertyList>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,24 +3,55 @@ ItemRelationDetail = {
|
||||
router_path: "/ItemRelationDetail/:id",
|
||||
delimiters: ["[[", "]]"],
|
||||
|
||||
data: function() {
|
||||
return {
|
||||
data: null
|
||||
computed: {
|
||||
object: function() {
|
||||
return this.$store.state.relations.items.find(i => i.id == this.$route.params.id)
|
||||
},
|
||||
|
||||
headers: function() {
|
||||
return this.$store.state.relations.headers
|
||||
},
|
||||
|
||||
relation_properties: function() {
|
||||
return this.$store.state.relationProperties.items.filter(i => i.relation == this.$route.params.id)
|
||||
},
|
||||
|
||||
relation_properties_headers: function() {
|
||||
return this.$store.state.relationProperties.headers
|
||||
},
|
||||
|
||||
all_properties: function() {
|
||||
return this.$store.state.properties.items
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
|
||||
this.reload()
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
async reload () {
|
||||
showItem (id) {
|
||||
this.$router.push({ name: 'ItemDetail', params: { id: id }})
|
||||
},
|
||||
|
||||
const response = await this.$http.get(Urls["items:relation.details"](this.$route.params.id))
|
||||
relationPropertyEdition (method, item) {
|
||||
return this.object_edit("items:relation.property.edit", "items:relation.property.create", 'relationProperties', method, item)
|
||||
},
|
||||
|
||||
async deleteRelationProperty (item) {
|
||||
await this.relationPropertyEdition("delete", item)
|
||||
this.$store.commit("relationProperties/removeItem", item.id)
|
||||
},
|
||||
|
||||
async createRelationProperty (item) {
|
||||
item.relation = this.$route.params.id
|
||||
const new_item = await this.relationPropertyEdition("post", item)
|
||||
this.$store.commit("relationProperties/addItem", new_item)
|
||||
},
|
||||
|
||||
async editRelationProperty (item) {
|
||||
item.relation = this.$route.params.id
|
||||
const new_item = await this.relationPropertyEdition("post", item)
|
||||
this.$store.commit("relationProperties/editItem", new_item)
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user