aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/src/components/model/OrphanCategory.vue
blob: 316b80956bedb931bdbb27e87d9746afb7b6eafe (plain)
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
65
<template>
  <div class="list-group col-lg-3">
    <h3 class="list-group-item active">{{title}}</h3>
    <div v-for="category in categories" class="list-group-item" :key="category.id">
      <h4 class="list-group-item-heading inline">{{ category.name }}</h4>
      <button
        type="button"
        class="fa fa-trash pull-right btn btn-dark btn-sm"
        @click="removeCategory(category)"
        :title="buttonTitle"
      ></button>
      <p class="list-group-item-text">{{ category.description }}</p>
    </div>
  </div>
</template>

<script>
import ModelService from "./../../services/Model.service.js";

var categoryMap = {
  subject: {
    title: "Orphan Subject categories",
    removeButtonTitle: "Remove Subject category",
    removeTitle: "Are you sure to remove this Subject Category?",
    listName: "subject_categories",
    serviceListName: "subjectCategories"
  },
  object: {
    title: "Orphan Object categories",
    removeButtonTitle: "Remove Object category",
    removeTitle: "Are you sure to remove this Object Category?",
    listName: "object_categories",
    serviceListName: "objectCategories"
  },
  action: {
    title: "Orphan Action categories",
    removeButtonTitle: "Remove Action category",
    removeTitle: "Are you sure to remove this Action Category?",
    listName: "action_categories",
    serviceListName: "actionCategories"
  }
};

export default {
  props: {
    categories: Array,
    type: String
  },
  computed: {
    title() {
      return categoryMap[this.type].title;
    },
    buttonTitle() {
      return categoryMap[this.type].removeButtonTitle;
    }
  },
  methods: {
    removeCategory(category) {
      if (confirm(categoryMap[this.type].removeTitle)) {
        ModelService.removeCategory(this.type, category);
      }
    }
  }
};
</script>