Mercurial > hg > ng2-query-ismi
diff src/app/result-type.js @ 58:3b4046e0cc02 default
Merge from ng2-table branch.
d7c947909ab888c013171b8c037e4f9fab30fe57
author | casties |
---|---|
date | Wed, 29 Mar 2017 17:19:12 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/result-type.js Wed Mar 29 17:19:12 2017 +0200 @@ -0,0 +1,49 @@ +"use strict"; +var result_column_1 = require('./result-column'); +var ResultType = (function () { + function ResultType(name, idAttribute, allowedAttributes, deniedAttributes) { + if (allowedAttributes === void 0) { allowedAttributes = []; } + if (deniedAttributes === void 0) { deniedAttributes = []; } + this.name = name; + this.idAttribute = idAttribute; + this.allowedAttributes = allowedAttributes; + this.deniedAttributes = deniedAttributes; + } + /** + * Return columns for the given list of attributes. + */ + ResultType.prototype.getColumns = function (attributes, allAttributes) { + var _this = this; + if (allAttributes === void 0) { allAttributes = true; } + var atts = attributes.slice(); + var cols = []; + // allowed attributes + this.allowedAttributes.forEach(function (att) { + var idx = atts.indexOf(att); + if (idx > -1) { + cols.push(new result_column_1.ResultColumn(att, att, '', true)); + atts[idx] = null; + } + }); + // then other attributes + if (allAttributes) { + atts.forEach(function (att) { + if (att != null && att[0] != '_' && _this.deniedAttributes.indexOf(att) < 0) { + cols.push(new result_column_1.ResultColumn(att, att, '', false)); + } + }); + } + return cols; + }; + return ResultType; +}()); +exports.ResultType = ResultType; +function getResultType(name, resultTypes) { + var rt = resultTypes[name]; + if (rt == null) { + rt = resultTypes['*']; + } + return rt; +} +exports.getResultType = getResultType; +//# sourceMappingURL=result-type.js.map \ No newline at end of file