This commit is contained in:
2020-02-04 18:53:52 +00:00
parent 983be5c96d
commit b61e03abad
2 changed files with 73 additions and 31 deletions

View File

@@ -61,16 +61,18 @@
</template> </template>
<template v-else> <template v-else>
<!-- Narrow width template --> <!-- Narrow width template -->
<tr <tr
class="v-data-table__mobile-table-row" class="v-data-table__mobile-table-row"
v-for="item in items" v-for="item in items"
:key="item.id" :key="item.id"
> >
<div class="mt-6" />
<!-- HEADER TO THE LEFT --> <!-- HEADER TO THE LEFT -->
<!-- FIELD VALUE TO THE RIGHT --> <!-- FIELD VALUE TO THE RIGHT -->
<template v-if="showSelect"> <template v-if="showSelect">
<td class="v-data-table__mobile-row"> <td class="v-data-table__mobile-row pl-2">
<div class="v-data-table__mobile-row__header"></div> <div class="v-data-table__mobile-row__header"></div>
<div class="v-data-table__mobile-row__cell"> <div class="v-data-table__mobile-row__cell">
<v-checkbox <v-checkbox
@@ -88,33 +90,46 @@
v-for="c in item.columns" v-for="c in item.columns"
:key="c.key" :key="c.key"
> >
<!-- NOTE: the mr-n6 is critical here or else in 360px (galaxy s9) small phone size the data column is cut off to the right --> <v-row no-gutters>
<div class="v-data-table__mobile-row__header mr-n6"> <v-col :cols="narrowHeaderCellColumns">
{{ getHeaderText(c.key) }} <!-- NOTE: the mr-n6 is critical here or else in 360px (galaxy s9) small phone size the data column is cut off to the right -->
</div> <div class="v-data-table__mobile-row__header text-truncate">
<div class="v-data-table__mobile-row__cell"> {{ getHeaderText(c.key) }}
<!-- Handle all plain text types right up to and including enums --> </div>
<!--TODO when get to coloured stuff will need to add that as a prop to column data but leaving out for now--> </v-col>
<template v-if="c.t < 11"> <v-col :cols="narrowDataCellColumns">
<template v-if="c.i"> <!-- at 360 to 388px cols above sb 7, at 389 and above sb 8, at 419 sb9 -->
<!-- openable object with an ID --> <div class="v-data-table__mobile-row__cell text-truncate">
<v-btn depressed small @click="btnClick(c.key, c.i)">{{ <!-- Handle all plain text types right up to and including enums -->
c.v <!--TODO when get to coloured stuff will need to add that as a prop to column data but leaving out for now-->
}}</v-btn> <template v-if="c.t < 11">
</template> <template v-if="c.i">
<template v-else> <!-- openable object with an ID -->
{{ c.v }} <!-- <a @click="btnClick(c.key, c.i)" href="#">{{ c.v }}</a> -->
</template> <!-- <v-btn @click="btnClick(c.key, c.i)">{{ c.v }}</v-btn> -->
</template> <span
<template v-if="c.t == 11"> @click="btnClick(c.key, c.i)"
<a :href="'mailto:' + c.v">{{ c.v }}</a> class="secondary--text subtitle-2 font-weight-bold"
</template> >{{ c.v }}</span
<template v-if="c.t == 12"> >
<!-- Expects full url with protocol etc in c.v so might need to add to record builder --> </template>
<a :href="c.v" target="_blank">{{ c.v }}</a> <template v-else>
</template> {{ c.v }}
</div> </template>
</template>
<template v-if="c.t == 11">
<a :href="'mailto:' + c.v">{{ c.v }}</a>
</template>
<template v-if="c.t == 12">
<!-- Expects full url with protocol etc in c.v so might need to add to record builder -->
<a :href="c.v" target="_blank">{{ c.v }}</a>
</template>
</div>
</v-col>
</v-row>
</td> </td>
<!-- <hr class="mt-12" /> -->
<div class="mt-6"><hr /></div>
</tr> </tr>
</template> </template>
</tbody> </tbody>
@@ -148,7 +163,9 @@ export default {
records: [], records: [],
rowsPerPageItems: [5, 10, 25, 50, 100], rowsPerPageItems: [5, 10, 25, 50, 100],
selected: [], selected: [],
narrowFormat: this.$vuetify.breakpoint.xs narrowFormat: this.$vuetify.breakpoint.xs,
narrowDataCellColumns: 7,
narrowHeaderCellColumns: 3
}; };
}, },
props: { props: {
@@ -185,16 +202,38 @@ 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"
var columnIndex = key.split("-")[1]; var columnIndex = key.split("-")[1];
var header = this.headers[columnIndex - 1]; var header = this.headers[columnIndex - 1];
if (header && header.text) { if (header && header.text) {
return header.text; return header.text + "_HERE_IS_A_REALLY_LONG_CUSTOMIZATION";
} }
return ""; return "";
}, },
@@ -259,6 +298,8 @@ 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 => {
@@ -357,7 +398,7 @@ function buildRecords(listData, columndefinitions, filters) {
var column = row[iColumn]; var column = row[iColumn];
var dataType = columndefinitions[iColumn].dt; var dataType = columndefinitions[iColumn].dt;
var display = column.v; var display = column.v + "_SOME_EXTRA_TEXT";
switch (dataType) { switch (dataType) {
case 1: //datetime format to shortdatetime case 1: //datetime format to shortdatetime
display = filters.shortdatelocalized(display); display = filters.shortdatelocalized(display);

View File

@@ -20,7 +20,8 @@ export default new Vuetify({
//accent: "#BD491A", //dark orangey red, more clarity, less friendly looking //accent: "#BD491A", //dark orangey red, more clarity, less friendly looking
error: "#ff5252", //lighter red, have to see if it's good for all screens and sizes as it's a bit light but it stands out as an error condition better error: "#ff5252", //lighter red, have to see if it's good for all screens and sizes as it's a bit light but it stands out as an error condition better
disabled: "#e0e0e0" disabled: "#e0e0e0",
anchor: "colors.purple"
} }
} }
}, },