You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.9 KiB
77 lines
1.9 KiB
import isEmpty from 'lodash/isEmpty';
|
|
import NotificationMixin from './NotificationMixin';
|
|
import { formatDateTime } from '../utils/dates';
|
|
import {mapActions, mapGetters} from "vuex";
|
|
|
|
export default {
|
|
mixins: [NotificationMixin],
|
|
created() {
|
|
// Changed
|
|
let id = this.$route.params.id;
|
|
if (isEmpty(id)) {
|
|
id = this.$route.query.id;
|
|
}
|
|
this.retrieve(decodeURIComponent(id));
|
|
//this.retrieve(decodeURIComponent(this.$route.params.id));
|
|
},
|
|
computed: {
|
|
item() {
|
|
// Changed
|
|
let id = this.$route.params.id;
|
|
if (isEmpty(id)) {
|
|
id = this.$route.query.id;
|
|
}
|
|
|
|
let item = this.find(decodeURIComponent(id));
|
|
if (item) {
|
|
item.resourceNode.resourceLinks.forEach((link) => {
|
|
this.resourcelinkfind('/api/resource_links/' + link.id).then( data => {
|
|
if (data) {
|
|
link = data;
|
|
return data;
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
return item;
|
|
//return this.find(decodeURIComponent(this.$route.params.id));
|
|
},
|
|
},
|
|
methods: {
|
|
list() {
|
|
this.$router
|
|
.push({ name: `${this.$options.servicePrefix}List` })
|
|
.catch(() => {});
|
|
},
|
|
del() {
|
|
this.deleteItem(this.item).then(() => {
|
|
this.showMessage(`${this.item['@id']} deleted.`);
|
|
this.$router
|
|
.push({ name: `${this.$options.servicePrefix}List` })
|
|
.catch(() => {});
|
|
});
|
|
},
|
|
formatDateTime,
|
|
editHandler() {
|
|
this.$router.push({
|
|
name: `${this.$options.servicePrefix}Update`,
|
|
params: { id: this.item['@id'] }
|
|
});
|
|
},
|
|
...mapActions({
|
|
resourcelinkfind: 'resourcelink/loadItem'
|
|
}),
|
|
},
|
|
watch: {
|
|
error(message) {
|
|
message && this.showError(message);
|
|
},
|
|
deleteError(message) {
|
|
message && this.showError(message);
|
|
}
|
|
},
|
|
beforeDestroy() {
|
|
this.reset();
|
|
}
|
|
};
|
|
|