Loading...
<% var filtered_cols = args['_c'] && args['_c'].length != options.columns.length ? options.columns.filter(function(col) { return args['_c'].indexOf('-' + col.name) < 0 }) : options.columns var cols = options.columns.length ? filtered_cols : meta.columns; cols = cols.filter(function(col) { return col.hide !== true}) var form_id = idcount %> <% _.each(cols, function(colinfo) { col_defaults(colinfo, data) var menu_item = false var col_id = idcount++ var qsort = parse('?') var isSorted = _.includes(args['_sort'], colinfo.name) ? {op: '', cls: 'table-primary'} : _.includes(args['_sort'], '-' + colinfo.name) ? {op: '-', cls: 'table-danger'} : {} %> <% }) %> <% if (isAdd) { %> <% _.each(cols, function(colinfo) { if (!colinfo.template) { %> <% } else { %> <% } %> <% }) %> <% } %> <% if (options.rowTemplate) { %> <% _.each(data, function(row, rowIndex) { %> <%= typeof options.rowTemplate == 'function' ? options.rowTemplate({row: row, data: data, index: rowIndex}) : _.template(options.rowTemplate)({row: row, data: data, index: rowIndex}) %> <% }) %> <% } else {%> <% _.each(data, function(row, rowIndex) { %> <% _.each(cols, function(colinfo) { %> <% var fmt = typeof(colinfo.format), val = row[colinfo.name], isEditable = colinfo.editable === undefined ? true : colinfo.editable, disp = fmt == "function" ? colinfo.format({name: colinfo.name, value: val, index: rowIndex, row: row, data:data }) : fmt === "string" && colinfo.type === "number" ? numeral(val).format(colinfo.format) : fmt === "string" && colinfo.type === "date" ? moment(val).format(colinfo.format): val, col_link %> <% if (!isEdit && 'link' in colinfo) var col_link = typeof colinfo.link == 'function' ? colinfo.link({name: colinfo.name, value: val, format: disp, index: rowIndex, row: row, data: data}) : _.template(colinfo.link)({name: colinfo.name, value: val, format: disp, index: rowIndex, row: row, data: data}) %> <% if (colinfo.template) { %> <%= typeof colinfo.template == 'function' ? colinfo.template({name: colinfo.name, value: val, format: disp, link: col_link, index: rowIndex, row: row, data: data}) : _.template(colinfo.template)(({name: colinfo.name, value: val, format: disp, link: col_link, index: rowIndex, row: row, data: data})) %> <% } else if (col_link) { %> <% } else if (isEdit && isEditable) { %> <% } else { %> <% } %> <% }) %> <% }) %> <% } %>
<% var isEditable = colinfo.editable === undefined ? true : colinfo.editable %> <%= _.template(templates['template_editable'])({isEditable: isEditable, val: undefined}) %>
<%= disp %> <%= _.template(templates['template_editable'])({isEditable: isEditable, val: val}) %> <%= disp %>
<% if (isEditable.input == 'select') { %> <% } else if (isEditable.input == 'radio') { %> <% _.each(isEditable.options, function(item) { %> value="<%- item %>" <% for (key in isEditable.attrs) { %> <%= key + '="' + isEditable.attrs[key] + '"' %> <% } %> class="form-control form-control-sm" /> <%- item %>
<% }) %> <% } else { %> <%= key + '="' + isEditable.attrs[key] + '"' %> <% } %> class="form-control form-control-sm" /> <% } %> <% if (isEditable.validationMessage) { %>
<%- isEditable.validationMessage %>
<% } %> <% var page = 1 + Math.floor(meta.offset / meta.limit), last_page = 'count' in meta ? Math.floor((meta.count + meta.limit - 1) / meta.limit) : meta.rows < meta.limit ? page : null, lo = Math.max(page - 2, 1), hi = last_page !== null ? Math.min(last_page, page + 2) : page + 2 %>
<% if (meta.limit) { %>
<% } %> <% if ('count' in meta) { %> <%- meta.count %> rows <% } %>
<% var qparts = parse('?') _.each(args['_c'], function(col_name) { qparts.update({_c: col_name}, 'add') var hide_col = col_name[0] == '-' var display_name = hide_col ? col_name.slice(1) : col_name %> <%- display_name %> <% }) _.each(args, function(list_values, key) { if (key.charAt(0) !== '_' && key !== 'c') { _.each(args[key], function(col_name) { var update = {} update[key] = col_name qparts.update(update, 'add') %> <%- key %> = <%- col_name %> <% }) } }) qparts = qparts.toString() if (qparts && qparts != '?') { %> × <% } %>
<% var filtered_cols = args['_c'] && args['_c'].length != options.columns.length ? options.columns.filter(function(col) { return args['_c'].indexOf('-' + col.name) < 0 }) : options.columns var cols = options.columns.length ? filtered_cols : meta.columns var form_id = idcount, img if (options.rowTemplate) { _.each(data, function(row, rowIndex) { %> <%= typeof options.rowTemplate == 'function' ? options.rowTemplate({row: row, index: rowIndex, data: data}) : _.template(options.rowTemplate)({row: row, data: data, index: rowIndex}) %> <% }) } else { %>
<% _.each(data, function(row, rowIndex) { %>
<% img = options.icon ? ((typeof(options.icon) == 'function' ? options.icon({row: row, data: data, index: rowIndex}) : options.icon)) : 'fa fa-home' %> <% if (img.indexOf('fa ') >= 0) { %> <% } else { %> <% } %>
<% _.each(cols, function(colinfo) { var fmt = typeof(colinfo.format), val = row[colinfo.name], disp = (fmt == "function" ? colinfo.format({index: rowIndex, name: colinfo.name, value: val, row: row, data:data }) : fmt === "string" && colinfo.type === "number" ? numeral(val).format(colinfo.format) : fmt === "string" && colinfo.type === "date" ? moment(val).format(colinfo.format) : val) %>
<%= colinfo.name %>: <% if ('link' in colinfo) { var col_link = typeof colinfo.link == 'function' ? colinfo.link({row: row, value: val, index: rowIndex, name: colinfo.name, data: data, format: disp}) : _.template(colinfo.link)({row: row, value: val, index: rowIndex, name: colinfo.name, data: data, format: disp}) %> <%= disp %> <% } else { %> <%= disp %> <% } %>
<% }) %>
<% }) %>
<% } %>