243 lines
7.2 KiB
Vue
243 lines
7.2 KiB
Vue
<template>
|
|
<div>
|
|
<h2>
|
|
{{ destination }} Links
|
|
</h2>
|
|
<p class="text-instructions">
|
|
The following are links to other objects like
|
|
projects/tasks/requirements. You can link a {{ destination }}
|
|
to these other objects to symbolise a connection between the two.
|
|
</p>
|
|
|
|
<!-- OBJECT LINKS -->
|
|
<div
|
|
v-if="linkResults.length === 0"
|
|
class="requirement-item-spacer"
|
|
>
|
|
<div class="alert alert-dark">
|
|
Sorry - there are no Links for this requirement.
|
|
</div>
|
|
</div>
|
|
<div v-else>
|
|
<!-- Relates To -->
|
|
<sub-object-links
|
|
title="Relates To"
|
|
:link-results="relatesTo"
|
|
@update_link_results="updateLinkResults($event)"
|
|
></sub-object-links>
|
|
|
|
<!-- Kanban Cards -->
|
|
<sub-object-links
|
|
title="Kanban Cards"
|
|
:link-results="kanbanCard"
|
|
:can-delete="false"
|
|
></sub-object-links>
|
|
|
|
<!-- Is Blocked By -->
|
|
<sub-object-links
|
|
title="Is Blocked By"
|
|
:link-results="isBlockedBy"
|
|
@update_link_results="updateLinkResults($event)"
|
|
></sub-object-links>
|
|
|
|
<!-- Is Currently Blocking -->
|
|
<sub-object-links
|
|
title="Is Currently Blocking"
|
|
:link-results="isCurrentlyBlocking"
|
|
@update_link_results="updateLinkResults($event)"
|
|
></sub-object-links>
|
|
|
|
<!-- Is Sub Object Of -->
|
|
<sub-object-links
|
|
title="Is Subobject Of"
|
|
:link-results="isSubObjectOf"
|
|
@update_link_results="updateLinkResults($event)"
|
|
></sub-object-links>
|
|
|
|
<!-- Is Parent Object Of -->
|
|
<sub-object-links
|
|
title="Is Parent Object Of"
|
|
:link-results="isParentOf"
|
|
@update_link_results="updateLinkResults($event)"
|
|
></sub-object-links>
|
|
|
|
<!-- Has Duplicate Object Of -->
|
|
<sub-object-links
|
|
title="Has Duplicate Object Of"
|
|
:link-results="hasDuplicateObjectOf"
|
|
@update_link_results="updateLinkResults($event)"
|
|
></sub-object-links>
|
|
|
|
<!-- Is Duplicate Object Of -->
|
|
<sub-object-links
|
|
title="Is Duplicate Object Of"
|
|
:link-results="isDuplicateObjectOf"
|
|
@update_link_results="updateLinkResults($event)"
|
|
></sub-object-links>
|
|
</div>
|
|
|
|
<!-- Submit Button -->
|
|
<hr v-if="userLevel > 1" />
|
|
<div class="row submit-row">
|
|
<div class="col-md-12">
|
|
<a
|
|
v-if="userLevel > 1"
|
|
href="javascript:void(0)"
|
|
class="btn btn-primary save-changes"
|
|
@click="newLink"
|
|
>Create new Link</a
|
|
>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MODAL FOR NEW OBJECT LINKS -->
|
|
<new-link-wizard
|
|
:destination="destination"
|
|
:location-id="locationId"
|
|
@update_link_results="updateLinkResults"
|
|
></new-link-wizard>
|
|
|
|
<!-- MODAL FOR CONFIRM DELETE LINK -->
|
|
<confirm-link-delete
|
|
@update_link_results="updateLinkResults"
|
|
></confirm-link-delete>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {Modal} from "bootstrap";
|
|
|
|
import NewLinkWizard from "../wizards/NewLinkWizard.vue";
|
|
import SubObjectLinks from "./SubObjectLinks.vue";
|
|
import ConfirmLinkDelete from "../wizards/ConfirmLinkDelete.vue";
|
|
|
|
//VueX
|
|
import {mapGetters} from "vuex";
|
|
|
|
export default {
|
|
name: "ObjectLinks",
|
|
components: {
|
|
ConfirmLinkDelete,
|
|
NewLinkWizard,
|
|
SubObjectLinks,
|
|
},
|
|
data() {
|
|
return {
|
|
hasDuplicateObjectOf: [],
|
|
isBlockedBy: [],
|
|
isCurrentlyBlocking: [],
|
|
isDuplicateObjectOf: [],
|
|
isParentOf: [],
|
|
isSubObjectOf: [],
|
|
kanbanCard: [],
|
|
linkResults: [],
|
|
relatesTo: [],
|
|
};
|
|
},
|
|
computed: {
|
|
...mapGetters({
|
|
destination: "getDestination",
|
|
locationId: "getLocationId",
|
|
rootUrl: "getRootUrl",
|
|
userLevel: "getUserLevel",
|
|
}),
|
|
},
|
|
mounted() {
|
|
this.$nextTick(() => {
|
|
this.updateLinkResults();
|
|
});
|
|
},
|
|
methods: {
|
|
isLinkedObject(object) {
|
|
let results = false;
|
|
|
|
if (object.fields.project !== null) results = true;
|
|
if (object.fields.task !== null) results = true;
|
|
if (object.fields.requirement !== null) results = true;
|
|
|
|
return results;
|
|
},
|
|
newLink() {
|
|
//Open up the modal
|
|
|
|
const elem_modal = new Modal(
|
|
document.getElementById("newLinkModal")
|
|
);
|
|
|
|
elem_modal.show();
|
|
},
|
|
updateLinkResults() {
|
|
//Clear the data
|
|
this.linkResults = [];
|
|
|
|
//Get the data from the database
|
|
this.axios.post(
|
|
`${this.rootUrl}object_data/${this.destination}/${this.locationId}/object_link_list/`
|
|
).then((response) => {
|
|
this.linkResults = response.data
|
|
|
|
//Filter out the data for relates to
|
|
this.relatesTo = response.data.filter(row => {
|
|
//We only have one condition - if there is a relate
|
|
return row.link_relationship === 'Relate' || row.link_relationship === null;
|
|
});
|
|
|
|
//Filter out the data for is blocked by
|
|
this.isBlockedBy = response.data.filter(row => {
|
|
const condition_1 = row.link_relationship === 'Block' && row.parent_link !== this.destination && row.reverse_relation === false;
|
|
const condition_2 = row.link_relationship === 'Block' && row.parent_link === this.destination && row.reverse_relation === true; //reverse
|
|
return condition_1 || condition_2;
|
|
})
|
|
|
|
//Filter out the data for kanban cards
|
|
this.kanbanCard = response.data.filter(row => {
|
|
//We only have one condition - if there is a kanban card
|
|
return row.link_relationship === 'Card'
|
|
})
|
|
|
|
//Filter out the data for is currently blocking
|
|
this.isCurrentlyBlocking = response.data.filter(row => {
|
|
const condition_1 = row.link_relationship === 'Block' && row.parent_link === this.destination && row.reverse_relation === false;
|
|
const condition_2 = row.link_relationship === 'Block' && row.parent_link !== this.destination && row.reverse_relation === true; //reverse
|
|
return condition_1 || condition_2;
|
|
})
|
|
|
|
//Filter out the dat for is subobject of
|
|
this.isSubObjectOf = response.data.filter(row => {
|
|
const condition_1 = row.link_relationship === 'Subobject' && row.parent_link !== this.destination && row.reverse_relation === false;
|
|
const condition_2 = row.link_relationship === 'Subobject' && row.parent_link === this.destination && row.reverse_relation === true;
|
|
return condition_1 || condition_2;
|
|
})
|
|
|
|
this.isParentOf = response.data.filter(row => {
|
|
const condition_1 = row.link_relationship === 'Subobject' && row.parent_link === this.destination && row.reverse_relation === false;
|
|
const condition_2 = row.link_relationship === 'Subobject' && row.parent_link !== this.destination && row.reverse_relation === true;
|
|
return condition_1 || condition_2;
|
|
})
|
|
|
|
this.hasDuplicateObjectOf = response.data.filter(row => {
|
|
const condition_1 = row.link_relationship === 'Duplicate' && row.parent_link === this.destination && row.reverse_relation === false;
|
|
const condition_2 = row.link_relationship === 'Duplicate' && row.parent_link !== this.destination && row.reverse_relation === true;
|
|
return condition_1 || condition_2;
|
|
})
|
|
|
|
this.isDuplicateObjectOf = response.data.filter(row => {
|
|
const condition_1 = row.link_relationship === 'Duplicate' && row.parent_link !== this.destination && row.reverse_relation === false;
|
|
const condition_2 = row.link_relationship === 'Duplicate' && row.parent_link === this.destination && row.reverse_relation === true;
|
|
return condition_1 || condition_2;
|
|
})
|
|
}).catch((error) => {
|
|
this.$store.dispatch("newToast", {
|
|
heading: "Object Links failed to get data",
|
|
message: `Failed to get data - Error -> ${error}`,
|
|
extra_classes: "bg-danger",
|
|
delay: 0,
|
|
});
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
|