This commit is contained in:
@@ -142,7 +142,11 @@ export default {
|
|||||||
//build that.headers here
|
//build that.headers here
|
||||||
that.headers = buildHeaders(res.columns);
|
that.headers = buildHeaders(res.columns);
|
||||||
//Post process data here and then set that.records
|
//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.loading = false;
|
||||||
that.totalRecords = res.paging.count;
|
that.totalRecords = res.paging.count;
|
||||||
})();
|
})();
|
||||||
@@ -186,7 +190,7 @@ function buildHeaders(columnData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Called by getDataFromApi on retrieval of list with 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
|
//iterate data, build each object keyed with index name and display set to correct locale filter and then return
|
||||||
if (!listData) {
|
if (!listData) {
|
||||||
return;
|
return;
|
||||||
@@ -201,7 +205,31 @@ function buildRecords(listData) {
|
|||||||
var o = {};
|
var o = {};
|
||||||
for (var iColumn = 1; iColumn < row.length; iColumn++) {
|
for (var iColumn = 1; iColumn < row.length; iColumn++) {
|
||||||
var column = row[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;
|
o["c" + iColumn.toString()] = column.v;
|
||||||
}
|
}
|
||||||
ret.push(o);
|
ret.push(o);
|
||||||
@@ -209,6 +237,20 @@ function buildRecords(listData) {
|
|||||||
return ret;
|
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
|
// Ensures column names are present in locale table
|
||||||
|
|||||||
@@ -154,14 +154,26 @@ Vue.filter("shortdatelocalized", function vueFilterShortDateLocalized(value) {
|
|||||||
.format(locale.format().shortDateAndTime);
|
.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) {
|
Vue.filter("currency", function vueFilterCurrency(value) {
|
||||||
if (!value) return "";
|
if (!value) return "";
|
||||||
return locale.format().currencySymbol + value;
|
return locale.format().currencySymbol + value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Vue.filter("decimal", function vueFilterDecimal(value) {
|
||||||
|
if (!value) return "";
|
||||||
|
return "dec.fltr." + value;
|
||||||
|
});
|
||||||
|
|
||||||
Vue.filter("boolastext", function vueFilterBoolAsText(value) {
|
Vue.filter("boolastext", function vueFilterBoolAsText(value) {
|
||||||
if (!value) return "";
|
if (!value) return "";
|
||||||
return value ? "Yes" : "Nope";
|
return value ? "Yup" : "Nope";
|
||||||
|
});
|
||||||
|
|
||||||
|
Vue.filter("enum", function vueFilterDecimal(value, enumtype) {
|
||||||
|
if (!value) return "";
|
||||||
|
return enumtype + "." + value;
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user