summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/ConfigChip.vue
blob: f278fe3349f0074c96fd6d2f39b99acf73b2fc72 (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<i18n>
{
  "en": {
    "assigned": "Assigned",
    "active": "Active",
    "source": "Source",
    "id": "ID",
    "name": "Name"
  },
  "de": {
    "assigned": "Zugewiesen",
    "active": "Aktiv",
    "source": "Quelle",
    "id": "ID",
    "name": "Name"
  }
}
</i18n>

<template>
  <v-tooltip top open-delay="200">
    <template #activator="{ on }">
      <v-chip v-on="on" small :color="color" :text-color="color ? 'white' : ''" :label="isEvent">
        <span class="chip-text">{{ config.name || config.id }}</span>
      </v-chip>
    </template>
    <div>
      <div v-if="active" class="success--text" style="text-align: center; font-weight: bold; font-size: 1.2em">{{ $t('active') }}</div>
      <div v-if="assigned" class="primary--text" style="text-align: center; font-weight: bold; font-size: 1.2em">{{ $t('assigned') }}</div>
      <div v-if="config.source">
        <table>
          <tr><td class="config-source-key">{{ $t('source') }}</td><td>{{ config.source.type }}</td></tr>
          <tr v-if="config.source.id"><td class="config-source-key">{{ $t('id') }}</td><td>{{ config.source.id }}</td></tr>
          <tr v-if="config.source.name"><td class="config-source-key">{{ $t('name') }}</td><td>{{ config.source.name }}</td></tr>
        </table>
      </div>
      <div v-else-if="config.configs">
        <div v-for="(subConfig, index) in config.configs" :key="subConfig.id">
          <v-divider v-if="index > 0" style="margin-bottom: 4px"></v-divider>
          <div style="text-align: center; font-weight: bold;">[{{ subConfig.id}}] {{ subConfig.name }}</div>
          <table>
            <tr><td class="config-source-key">{{ $t('source') }}</td><td>{{ subConfig.source.type }}</td></tr>
            <tr v-if="subConfig.source.id"><td class="config-source-key">{{ $t('id') }}</td><td>{{ subConfig.source.id }}</td></tr>
            <tr v-if="subConfig.source.name"><td class="config-source-key">{{ $t('name') }}</td><td>{{ subConfig.source.name }}</td></tr>
          </table>
        </div>
      </div>
      <span v-else>{{ config.name || config.id }}</span>
    </div>
  </v-tooltip>
</template>

<script>

export default {
  name: 'ConfigChip',
  props: {
    config: {
      type: Object,
      default: () => {}
    },
    active: {
      type: Boolean,
      default: false
    },
    assigned: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
    }
  },
  computed: {
    color () {
      if (this.assigned) return 'primary'
      if (this.active) return 'success'
      return ''
    },
    isEvent () {
      return this.config.source && (this.config.source.type === 'IMPORTANT_EVENT' || this.config.source.type === 'EVENT')
    }
  },
  methods: {
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.config-source-key {
  vertical-align: top;
  font-weight: bold;
  text-align: right;
  padding-right: 16px;
}
</style>