@afeefa/vue-app 0.0.226 → 0.0.227

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 0.0.226
1
+ 0.0.227
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.226",
3
+ "version": "0.0.227",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -32,6 +32,8 @@
32
32
  <div class="a-table-wrapper">
33
33
  <a-table>
34
34
  <a-table-header>
35
+ <div v-if="bulkselection" />
36
+
35
37
  <div v-if="$has.icon">
36
38
  <slot name="header-icon" />
37
39
  </div>
@@ -39,29 +41,67 @@
39
41
  <slot name="header-table" />
40
42
  </a-table-header>
41
43
 
42
- <a-table-row
43
- v-for="(model, index) in models_"
44
- :key="model.id"
45
- v-flying-context-trigger="hasFlyingContext"
46
- :class="getRowClasses(model)"
47
- v-bind="getRowAttributes(model)"
48
- v-on="getRowListeners(model)"
49
- @click="emitFlyingContext(model)"
50
- >
51
- <v-icon
52
- v-if="$has.icon"
53
- :color="model.getIcon().color"
54
- size="1.2rem"
55
- v-text="model.getIcon().icon"
56
- />
57
-
58
- <slot
59
- name="model-table"
60
- :model="model"
61
- :index="index"
62
- :filters="filters"
63
- />
64
- </a-table-row>
44
+ <template v-for="(model, index) in models_">
45
+ <a-table-row
46
+ :key="'model' + model.id"
47
+ v-flying-context-trigger="hasFlyingContext"
48
+ :class="[
49
+ getRowClasses(model),
50
+ { hasSubModels: !!getSubModels(model).length }
51
+ ]"
52
+ v-bind="getRowAttributes(model)"
53
+ v-on="getRowListeners(model)"
54
+ @click="emitFlyingContext(model)"
55
+ >
56
+ <div
57
+ v-if="bulkselection"
58
+ class="pr-2"
59
+ >
60
+ <a-checkbox
61
+ :value="isSelected(model)"
62
+ hide-details
63
+ class="pa-0"
64
+ @input="selectClient(model)"
65
+ />
66
+ </div>
67
+
68
+ <v-icon
69
+ v-if="$has.icon"
70
+ :color="model.getIcon().color"
71
+ size="1.2rem"
72
+ v-text="model.getIcon().icon"
73
+ />
74
+
75
+ <slot
76
+ name="model-table"
77
+ :model="model"
78
+ :index="index"
79
+ :filters="filters"
80
+ />
81
+ </a-table-row>
82
+
83
+ <a-table-row
84
+ v-for="(subModel, subIndex) in getSubModels(model)"
85
+ :key="subModel.id"
86
+ small
87
+ :class="{
88
+ ...getRowClasses(model),
89
+ last: subIndex === getSubModels(model).length - 1,
90
+ subModel: true
91
+ }"
92
+ >
93
+ <div v-if="bulkselection" />
94
+
95
+ <div v-if="$has.icon" />
96
+
97
+ <slot
98
+ name="subModel-table"
99
+ :model="subModel"
100
+ :index="subIndex"
101
+ :filters="filters"
102
+ />
103
+ </a-table-row>
104
+ </template>
65
105
  </a-table>
66
106
  </div>
67
107
  </template>
@@ -122,7 +162,17 @@ import { ListViewMixin } from '@a-vue/components/list/ListViewMixin'
122
162
  import { LoadingEvent } from '@a-vue/events'
123
163
 
124
164
  @Component({
125
- props: ['rowAttributes', 'rowClasses', 'rowListeners']
165
+ props: [
166
+ 'rowAttributes',
167
+ 'rowClasses',
168
+ 'rowListeners',
169
+ {
170
+ bulkselection: false,
171
+ getSubModels: {
172
+ default: () => model => []
173
+ }
174
+ }
175
+ ]
126
176
  })
127
177
  export default class ListView extends Mixins(ListViewMixin) {
128
178
  $hasOptions = ['icon', 'filters']
@@ -134,6 +184,20 @@ export default class ListView extends Mixins(ListViewMixin) {
134
184
  scrollTopStart = null
135
185
  scrollContainerY = null
136
186
 
187
+ selectedModels = []
188
+
189
+ isSelected (model) {
190
+ return this.selectedModels.includes(model)
191
+ }
192
+
193
+ selectClient (model) {
194
+ if (!this.isSelected(model)) {
195
+ this.selectedModels.push(model)
196
+ } else {
197
+ this.selectedModels = this.selectedModels.filter(m => m !== model)
198
+ }
199
+ }
200
+
137
201
  @Watch('isLoading')
138
202
  isLoadingChanged () {
139
203
  if (this.events) {
@@ -308,4 +372,19 @@ filters-below:not(:empty) {
308
372
  .a-table-row.clickable {
309
373
  cursor: pointer;
310
374
  }
375
+
376
+ :deep(.a-table-row.hasSubModels) > * {
377
+ padding-bottom: 0;
378
+ border: none;
379
+ }
380
+
381
+ :deep(.a-table-row.small.subModel) > * {
382
+ padding-top: 0;
383
+ color: gray;
384
+ }
385
+
386
+ :deep(.a-table-row.small.subModel):not(.last) > * {
387
+ border: none;
388
+ padding-bottom: 0;
389
+ }
311
390
  </style>