summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/DataTableItem.vue
blob: 5210efad83a6bcb5494a4dcdb9df888c4e47b2e5 (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
<i18n>
{
  "en": {
  },
  "de": {
  }
}
</i18n>

<template>
  <tr
    :style="row.selected && { backgroundColor: $vuetify.theme.primary + '11' }"
    @click="selectRow(row)"
    @dblclick="$emit('dbclick', row.item)"
  >
    <td class="narrow-td">
      <v-icon style="cursor: pointer">{{ row.selected ? 'check_box' : 'check_box_outline_blank' }}</v-icon>
    </td>
    <td v-for="header in headers" :key="header.key">
      {{ row.item[header.key] }}
    </td>
  </tr>
</template>

<script>

export default {
  name: 'DataTableItem',
  props: {
    row: {
      type: Object,
      required: true
    },
    headers: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
    }
  },
  methods: {
    selectRow (row) {
      row.selected = !row.selected
      this.$emit('select', row)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.narrow-td {
  width: 10px;
}

tr {
  height: 48px;
  box-sizing: border-box;
}

td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme--dark td {
  border-bottom: 1px solid hsla(0,0%,100%,.12);
}

.theme--light td {
  border-bottom: 1px solid rgba(0,0,0,.12);
}

.theme--dark tr:hover {
  background: #616161;
}

.theme--light tr:hover {
  background: #eee;
}

td {
  padding: 0 24px;
}
</style>