1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<template>
<div>
<span :title="category.description">{{ category.name }}</span>
<button type="button" class="fa fa-trash pull-right btn btn-dark btn-sm" @click="removeCategory()" title="Remove"></button>
<div v-for="attribute in attributes" :key="attribute.id">
<b>attributes: </b> {{attribute.id}}
</div>
</div>
</template>
<script>
import ModelService from "./../../services/Model.service.js";
import util from "./../../services/Util.service.js";
var categoryMap = {
subject: {
addTitle: "Add Subject Category",
removeTitleFromMetaRule:
"Are you sure to remove from meta rule this Subject Category?",
removeTitle: "Are you sure to remove this Subject Category?",
listName: "subject_categories",
serviceListName: "subjectCategories"
},
object: {
addTitle: "Add Object Category",
removeTitleFromMetaRule:
"Are you sure to remove from meta rule this Object Category?",
removeTitle: "Are you sure to remove this Object Category?",
listName: "object_categories",
serviceListName: "objectCategories"
},
action: {
addTitle: "Add Action Category",
removeTitleFromMetaRule:
"Are you sure to remove from meta rule this Action Category?",
removeTitle: "Are you sure to remove this Action Category?",
listName: "action_categories",
serviceListName: "actionCategories"
}
};
export default {
name: "category",
props: {
metarule: Object,
category: Object,
attributes: Array,
type: String
},
methods: {
removeCategory() {
var typeValue = categoryMap[this.type];
if (confirm(typeValue.removeTitleFromMetaRule)) {
var metaruleCopy = util.clone(this.metarule);
metaruleCopy[typeValue.listName].splice(
metaruleCopy[typeValue.listName].indexOf(this.category),
1
);
ModelService.updateMetaRule(metaruleCopy);
}
}
}
};
</script>
|