This commit is contained in:
@@ -88,6 +88,57 @@
|
|||||||
:no-data-text="lt('NoData')"
|
:no-data-text="lt('NoData')"
|
||||||
class="elevation-1"
|
class="elevation-1"
|
||||||
>
|
>
|
||||||
|
<template v-slot:header="props">
|
||||||
|
<div>
|
||||||
|
<v-icon v-if="props.someItems" x-large>fa-square</v-icon>
|
||||||
|
<v-icon x-large>fa-minus-square</v-icon>
|
||||||
|
<v-icon x-large>fa-check-square</v-icon>
|
||||||
|
</div>
|
||||||
|
<div><v-btn @click="handleSelectAllToggle(props)">toggle</v-btn></div>
|
||||||
|
<!-- todo: put a checkbox icon here that is filled or not depending on select all status, also it triggers select all event -->
|
||||||
|
<!--
|
||||||
|
@click="props.toggleSelectAll(false)"
|
||||||
|
|
||||||
|
it('should select all', async () => {
|
||||||
|
const input = jest.fn()
|
||||||
|
const items = [
|
||||||
|
{ id: 'foo' },
|
||||||
|
{ id: 'bar' },
|
||||||
|
]
|
||||||
|
const toggleSelectAll = jest.fn()
|
||||||
|
|
||||||
|
const wrapper = mountFunction({
|
||||||
|
propsData: {
|
||||||
|
items,
|
||||||
|
},
|
||||||
|
listeners: {
|
||||||
|
input,
|
||||||
|
'toggle-select-all': toggleSelectAll,
|
||||||
|
},
|
||||||
|
scopedSlots: {
|
||||||
|
header (props) {
|
||||||
|
return this.$createElement('div', {
|
||||||
|
attrs: {
|
||||||
|
id: 'header',
|
||||||
|
},
|
||||||
|
on: {
|
||||||
|
click: () => props.toggleSelectAll(true),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const header = wrapper.find('#header')
|
||||||
|
header.element.click()
|
||||||
|
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
|
expect(input).toHaveBeenCalledWith(items)
|
||||||
|
expect(toggleSelectAll).toHaveBeenCalledWith({ value: true })
|
||||||
|
}) -->
|
||||||
|
</template>
|
||||||
|
|
||||||
<template v-slot:default="{ items }">
|
<template v-slot:default="{ items }">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col
|
<v-col
|
||||||
@@ -98,13 +149,23 @@
|
|||||||
md="4"
|
md="4"
|
||||||
lg="3"
|
lg="3"
|
||||||
>
|
>
|
||||||
<v-card tile>
|
<v-card elevation="4" tile>
|
||||||
<!-- <v-card-title class="subheading font-weight-bold">{{
|
<!-- <v-card-title class="subheading font-weight-bold">{{
|
||||||
item.columns.c1.v
|
item.columns.c1.v
|
||||||
}}</v-card-title>
|
}}</v-card-title>
|
||||||
|
|
||||||
<v-divider></v-divider> -->
|
<v-divider></v-divider> -->
|
||||||
|
<template v-if="showSelect">
|
||||||
|
<v-card-title class="subheading font-weight-bold">
|
||||||
|
<v-checkbox
|
||||||
|
v-model="selected"
|
||||||
|
:value="item"
|
||||||
|
primary
|
||||||
|
hide-details
|
||||||
|
></v-checkbox>
|
||||||
|
</v-card-title>
|
||||||
|
<v-divider></v-divider>
|
||||||
|
</template>
|
||||||
<v-list dense>
|
<v-list dense>
|
||||||
<v-list-item two-line v-for="c in item.columns" :key="c.key">
|
<v-list-item two-line v-for="c in item.columns" :key="c.key">
|
||||||
<v-list-item-content>
|
<v-list-item-content>
|
||||||
@@ -145,11 +206,11 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-data-iterator>
|
</v-data-iterator>
|
||||||
</template>
|
</template>
|
||||||
<!-- <hr />
|
<hr />
|
||||||
<div>Records: {{ records }}</div>
|
|
||||||
<div>Selected: {{ selected }}</div>
|
|
||||||
<div>Headers: {{ headers }}</div>
|
|
||||||
|
|
||||||
|
<div>Selected: {{ selected }}</div>
|
||||||
|
<!-- <div>Headers: {{ headers }}</div>
|
||||||
|
<div>Records: {{ records }}</div>
|
||||||
<div>TotalRecords: {{ totalRecords }}</div>
|
<div>TotalRecords: {{ totalRecords }}</div>
|
||||||
<div>caption: {{ caption }}</div>
|
<div>caption: {{ caption }}</div>
|
||||||
<div>apiBaseUrl: {{ apiBaseUrl }}</div>
|
<div>apiBaseUrl: {{ apiBaseUrl }}</div>
|
||||||
@@ -214,31 +275,9 @@ export default {
|
|||||||
},
|
},
|
||||||
"$vuetify.breakpoint.xs": function(value) {
|
"$vuetify.breakpoint.xs": function(value) {
|
||||||
this.narrowFormat = value;
|
this.narrowFormat = value;
|
||||||
},
|
|
||||||
"$vuetify.breakpoint.width": function(value) {
|
|
||||||
this.calculateNarrowWidthColumns(value);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
calculateNarrowWidthColumns() {
|
|
||||||
//only need to do this if xs sized narrow format
|
|
||||||
if (this.$vuetify.breakpoint.xs) {
|
|
||||||
var width = this.$vuetify.breakpoint.width;
|
|
||||||
// <!-- at 360 to 388px cols above sb 7, at 389 and above sb 8, at 419 sb9 -->
|
|
||||||
if (width < 389) {
|
|
||||||
this.narrowDataCellColumns = 7;
|
|
||||||
this.narrowHeaderCellColumns = 3;
|
|
||||||
} else if (width < 419) {
|
|
||||||
this.narrowDataCellColumns = 8;
|
|
||||||
this.narrowHeaderCellColumns = 3;
|
|
||||||
} else {
|
|
||||||
this.narrowDataCellColumns = 8;
|
|
||||||
this.narrowHeaderCellColumns = 4;
|
|
||||||
}
|
|
||||||
//this.narrowHeaderCellColumns = 12 - this.narrowDataCellColumns;
|
|
||||||
console.log("narrowDataCellColumns=" + this.narrowDataCellColumns);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//Used by narrow view to get the "header" text for a column based on the column key
|
//Used by narrow view to get the "header" text for a column based on the column key
|
||||||
getHeaderText(key) {
|
getHeaderText(key) {
|
||||||
//key format is row-column e.g."500-2"
|
//key format is row-column e.g."500-2"
|
||||||
@@ -260,6 +299,15 @@ export default {
|
|||||||
//could be more efficient if it just sends the ID's instead:
|
//could be more efficient if it just sends the ID's instead:
|
||||||
this.$emit("update:selected", window.$gz._.map(this.selected, "id"));
|
this.$emit("update:selected", window.$gz._.map(this.selected, "id"));
|
||||||
},
|
},
|
||||||
|
handleSelectAllToggle(vv) {
|
||||||
|
// debugger;
|
||||||
|
vv.toggleSelectAll(!vv.everyItem);
|
||||||
|
// if (vv.everyItem) {
|
||||||
|
// vv.toggleSelectAll(false);
|
||||||
|
// } else if (vv.someItems) {
|
||||||
|
// vv.toggleSelectAll(true);
|
||||||
|
// }
|
||||||
|
},
|
||||||
btnClick(key, i) {
|
btnClick(key, i) {
|
||||||
//translate key to actual object type from header data
|
//translate key to actual object type from header data
|
||||||
//key format is row-column e.g."500-2"
|
//key format is row-column e.g."500-2"
|
||||||
@@ -310,8 +358,7 @@ export default {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
that.loading = true;
|
that.loading = true;
|
||||||
//this is here because my theory is it's set to loading so this won't trigger a re-draw here
|
|
||||||
that.calculateNarrowWidthColumns();
|
|
||||||
var listUrl =
|
var listUrl =
|
||||||
that.apiBaseUrl + "?" + window.$gz.api.buildQuery(listOptions);
|
that.apiBaseUrl + "?" + window.$gz.api.buildQuery(listOptions);
|
||||||
window.$gz.api.get(listUrl).then(res => {
|
window.$gz.api.get(listUrl).then(res => {
|
||||||
|
|||||||
Reference in New Issue
Block a user