This commit is contained in:
2020-01-30 00:34:07 +00:00
parent ba1a76842f
commit edb2527a4b
2 changed files with 58 additions and 4 deletions

View File

@@ -142,7 +142,11 @@ export default {
//build that.headers here
that.headers = buildHeaders(res.columns);
//Post process data here and then set that.records
that.records = buildRecords(res.data);
that.records = buildRecords(
res.data,
res.columns,
that.$options.filters
);
that.loading = false;
that.totalRecords = res.paging.count;
})();
@@ -186,7 +190,7 @@ function buildHeaders(columnData) {
}
//Called by getDataFromApi on retrieval of list with columnData
function buildRecords(listData) {
function buildRecords(listData, columndefinitions, filters) {
//iterate data, build each object keyed with index name and display set to correct locale filter and then return
if (!listData) {
return;
@@ -201,7 +205,31 @@ function buildRecords(listData) {
var o = {};
for (var iColumn = 1; iColumn < row.length; iColumn++) {
var column = row[iColumn];
var dataType = columndefinitions[iColumn].dt;
var display = column.v;
switch (dataType) {
case 1: //datetime format to shortdatetime
display = filters.shortdatelocalized(display);
break;
case 2: //date only
break;
case 3: //time only
break;
case 6: //bool
display = filters.boolastext(display);
break;
case 7: //decimal
display = filters.decimal(display);
break;
case 8: //currency
display = filters.currency(display);
break;
case 10: //enum
display = filters.enum(display, columndefinitions[iColumn].et);
break;
default:
//do nothing, allow it to stay as is
}
o["c" + iColumn.toString()] = column.v;
}
ret.push(o);
@@ -209,6 +237,20 @@ function buildRecords(listData) {
return ret;
}
/*UiDataTypes
NoType = 0,
DateTime = 1,
Date = 2,
Time = 3,
Text = 4,
Integer = 5,
Bool = 6,
Decimal = 7,
Currency = 8,
Tags = 9,
Enum = 10,
EmailAddress = 11
*/
//////////////////////////////////////////////////////////
//
// Ensures column names are present in locale table

View File

@@ -154,14 +154,26 @@ Vue.filter("shortdatelocalized", function vueFilterShortDateLocalized(value) {
.format(locale.format().shortDateAndTime);
});
//TODO: These need more work to format as proper numeric value (comma versus decimal etc)
Vue.filter("currency", function vueFilterCurrency(value) {
if (!value) return "";
return locale.format().currencySymbol + value;
});
Vue.filter("decimal", function vueFilterDecimal(value) {
if (!value) return "";
return "dec.fltr." + value;
});
Vue.filter("boolastext", function vueFilterBoolAsText(value) {
if (!value) return "";
return value ? "Yes" : "Nope";
return value ? "Yup" : "Nope";
});
Vue.filter("enum", function vueFilterDecimal(value, enumtype) {
if (!value) return "";
return enumtype + "." + value;
});
/////////////////////////////////////////////////////////////