mirror of
https://github.com/Mintplex-Labs/express-admin.git
synced 2026-07-21 00:45:22 -04:00
Load static values fomr settings
This commit is contained in:
@@ -34,6 +34,38 @@ var otm = {
|
||||
}
|
||||
};
|
||||
|
||||
// load static values from settings
|
||||
// modifies `args.config.columns` with `value`
|
||||
var stc = {
|
||||
getSelect: function (options) {
|
||||
var values = [];
|
||||
for (var i=0; i < options.length; i++) {
|
||||
values.push({__pk: options[i], __text: options[i]});
|
||||
}
|
||||
return values;
|
||||
},
|
||||
getRadio: function (options) {
|
||||
return [
|
||||
{text: options[0], value: 1},
|
||||
{text: options[1], value: 0}
|
||||
];
|
||||
},
|
||||
loopColumns: function (args) {
|
||||
var columns = args.config.columns;
|
||||
for (var i=0; i < columns.length; i++) {
|
||||
var control = columns[i].control;
|
||||
if (!(control.options instanceof Array)) continue;
|
||||
|
||||
switch (true) {
|
||||
case control.select:
|
||||
columns[i].value = stc.getSelect(control.options); break;
|
||||
case control.radio:
|
||||
columns[i].value = stc.getRadio(control.options); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// get table records
|
||||
var tbl = {
|
||||
getSql: function (args) {
|
||||
@@ -132,6 +164,7 @@ function getData (args, cb) {
|
||||
|
||||
otm.loopColumns(args, function (err) {
|
||||
if (err) return cb(err);
|
||||
stc.loopColumns(args);
|
||||
tbl.getRecords(args, function (err, rows) {
|
||||
if (err) return cb(err);
|
||||
mtm.loopRecords(args, rows, function (err) {
|
||||
|
||||
Reference in New Issue
Block a user