@tasolutions/express-core
Version:
All libs for express
38 lines (33 loc) • 1.2 kB
JavaScript
// fieldBuilderInterfaceCustom.js
const _ = require('lodash');
const buildFieldListFromInterfaceCustom = (responseFields) => {
if (!(responseFields && responseFields.length)) return [];
const fieldList = [];
responseFields.forEach((field, index) => {
const fieldObject = {
index,
key: field.key,
type: field.type || null,
type_sub: field.type_sub || null,
show: true,
is_required: field.is_required || false,
is_filter: field.is_filter || false,
label: field.label || _.startCase(_.toLower(field.key)),
html: {
placeholder: `Please input ${_.startCase(_.toLower(field.key))}`,
disabled: false,
read_only: false,
col: 12,
},
refresh_change_fields: field.refresh_change_fields || null,
select_options: field.select_options || null,
db_type: field.db_type || null,
max_length: field.max_length || null,
};
fieldList.push(fieldObject);
});
return fieldList;
};
module.exports = {
buildFieldListFromInterfaceCustom,
};