Loading public/javascript/redmic/modules/browser/_Table.js +1 −3 Original line number Diff line number Diff line Loading @@ -40,9 +40,7 @@ define([ _paddingHeaderRow: 45, _correctionHeaderRow: -20, _valueRow: 25, tableConfig: { } tableConfig: {} }; lang.mixin(this, this.config); Loading public/javascript/redmic/modules/browser/row/Row.js +92 −36 Original line number Diff line number Diff line Loading @@ -91,52 +91,93 @@ define([ _updateData: function(item) { put(this.templateNode, "[data-redmic-id=$]", this._getId(item)); this.currentData = item; this._replaceHighlightInItem(item); put(this.templateNode, "[data-redmic-id=$]", this._getId()); this.templateNode.innerHTML = this._insertTemplate(item); this._replaceHighlights(); this.templateNode.innerHTML = this._getContent(); }, _getId: function(item) { _getId: function() { return item[this.idProperty]; return this.currentData[this.idProperty]; }, _insertTemplate: function(item) { _getContent: function() { var json = {data: item}; if (this.itemLabel) { return this._getLabelValue(); } else { return this._insertTemplate(); } }, if (this.i18n) { json.i18n = this.i18n; _getLabelValue: function() { var item = this.currentData; if (this._isItemLabelFunction()) { return this.itemLabel(item); } if (this.shownOptionTemplate) { json.shownOption = this.shownOptionTemplate; if (this._isItemLabelString()) { return this._getItemLabelString(); } if (this.itemLabel) { return this._getLabelValue(item); } else { return this._getTemplate(json); return item[this.itemLabel]; }, _getItemLabelString: function() { var item = this.currentData; if (this.itemLabel.indexOf("{") < 0) { return item[this.itemLabel]; } return lang.replace(this.itemLabel, item); }, _getLabelValue: function(item) { _isItemLabelFunction: function() { if (typeof this.itemLabel === "function") { return this.itemLabel(item); return true; } return false; }, _isItemLabelString: function() { if (typeof this.itemLabel === "string") { if (this.itemLabel.indexOf("{") < 0) { return item[this.itemLabel]; return true; } return lang.replace(this.itemLabel, item); return false; }, _insertTemplate: function() { return this._getTemplate(this._propertiesTemplate()); }, _propertiesTemplate: function() { var obj = { data: this.currentData }; if (this.i18n) { obj.i18n = this.i18n; } return item[this.itemLabel]; if (this.shownOptionTemplate) { obj.shownOption = this.shownOptionTemplate; } return obj; }, _getTemplate: function(dataObj) { Loading @@ -149,29 +190,44 @@ define([ return this.domNode; }, _replaceHighlightInItem: function(item) { _replaceHighlights: function() { var item = this.currentData; if (item && item._meta) { var highlight = item._meta.highlight; for (var content in highlight) { var value = Utilities.getDeepProp(item, content), attr = highlight[content]; for (var property in highlight) { this._replaceHighlight(property, highlight[property]); } } }, _replaceHighlight: function(property, content) { var value = Utilities.getDeepProp(this.currentData, property); if (!value) { return; } for (var i = 0; i < attr.length; i++) { var valueReplace = attr[i], cleanValueReplace = this._cleanValueHighlight(valueReplace); Utilities.setDeepProp(this.currentData, property, this._replaceHighlightInContent(value, content)); }, value = value.replace(cleanValueReplace, valueReplace); } _replaceHighlightInContent: function(value, content) { Utilities.setDeepProp(item, content, value); } var returnValue = value; for (var i = 0; i < content.length; i++) { returnValue = this._replacePartHighlightInContent(returnValue, content[i]); } return returnValue; }, _replacePartHighlightInContent: function(value, content) { return value.replace(this._cleanValueHighlight(content), content); }, _cleanValueHighlight: function(value) { Loading public/javascript/redmic/modules/browser/row/_Select.js +7 −7 Original line number Diff line number Diff line Loading @@ -147,15 +147,15 @@ define([ _eventChecked: function(idProperty, e) { var action = 'SELECT'; if (this._isSelect()) { this._emitEvt('DESELECT', { idProperty: idProperty }); } else { this._emitEvt('SELECT', { action = 'DESELECT'; } this._emitEvt(action, { idProperty: idProperty }); } }, _isSelect: function() { Loading public/javascript/redmic/modules/browser/row/_Table.js +124 −59 Original line number Diff line number Diff line Loading @@ -45,103 +45,168 @@ define([ _updateData: function(item) { put(this.tableRowNode, "[data-redmic-id=$]", this._getId(item)); this.currentData = item; put(this.tableRowNode, "[data-redmic-id=$]", this._getId()); this._clearTableRowNode(); this._updateColumns(); }, _clearTableRowNode: function() { while (this.tableRowNode.firstChild) { put(this.tableRowNode.firstChild, '!'); } }, if (this.columns) { _updateColumns: function() { if (this.columns) { for (var i = 0; i < this.columns.length; i++) { var column = this.columns[i], content = this._getContent(item, column); if (!column.type) { this._createCell({ config: column, content: content }); } else if (column.type === "arrayColumns") { this.columns[i].countData = 16; this._generatorColumnsWithArray(column, content); } this._updateColumn(this.columns[i]); } } }, _getContent: function(item, config, property) { _updateColumn: function(column) { var template = false; this._currentColumn = column; if (!config.type) { if (!config.template) { property = "property"; var content = this._getContent(); if (this._isTypeArrayColumns()) { this._currentColumn.countData = 16; this._generatorColumnsWithArray(content); } else { template = true; this._createCell(content); } }, _getContent: function(property) { if (this._isConfigWithTemplate() && !property) { return this._getContentTemplate(); } } else if (config.type === "arrayColumns") { if (!property) { return this._getContentWithPropertyInData(property); }, _getContentWithPropertyInData: function(property) { var data = this.currentData; if (property) { data = this._currentDataArray; } else { property = "property"; } else if (config.template) { template = true; } var content = Utilities.getDeepProp(data, this._currentColumn[property], this.pathSeparator); if (this._isContent(content)) { return content; } if (template) { return config.template({ data: item, return this._currentColumn.notContent || ""; }, _isContent: function(content) { if (content !== null && content !== undefined) { return true; } return false; }, _getContentTemplate: function() { return this._currentColumn.template({ data: this.currentData, i18n: this.i18n }); }, _createCell: function(content) { var nodeItem = this._createNodeCell(); if (this._isConfigWithTemplate()) { nodeItem.innerHTML = content; } else { nodeItem.innerText = this._formatContent(content); } }, var content = Utilities.getDeepProp(item, config[property], this.pathSeparator); _createNodeCell: function() { if (content !== null && content !== undefined) { return content; return put(this.tableRowNode, 'span' + this._classNewNodeCell() + this._attributeDataRemicProperty()); }, _classNewNodeCell: function() { return '.table-cell.table-col-' + (this.tableRowNode.children.length + 1); }, _attributeDataRemicProperty: function() { return '[data-redmic-property="' + this._getProperty() + '"]'; }, _isConfigWithTemplate: function() { if (this._currentColumn.template) { return true; } return config.notContent || ""; return false; }, _createCell: function(obj) { _formatContent: function(content) { var itemConfig = obj.config, content = obj.content, colClass = 'table-col-' + (this.tableRowNode.children.length + 1), nodeItem = put(this.tableRowNode, 'span.table-cell.' + colClass + "[data-redmic-property=$]", this._generatePropertyRow(itemConfig)), format = itemConfig.format; var format = this._currentColumn.format; if (!itemConfig.template) { if (format) { content = format(content); return format(content); } nodeItem.innerText = content; } else { nodeItem.innerHTML = content; } return content; }, _generatorColumnsWithArray: function(itemConfig, data) { _generatorColumnsWithArray: function(data) { for (var i = 0; i < data.length; i++) { this._currentDataArray = data[i]; this._createCell({ config: itemConfig, content: this._getContent(data[i], itemConfig, "propertyInArrayItem") }); var content = this._getContent("propertyInArrayItem"); this._createCell(content); } }, _generatePropertyRow: function(itemConfig) { _getProperty: function() { if (!itemConfig.type) { return itemConfig.property; } else if (itemConfig.type == "arrayColumns") { return itemConfig.propertyInArrayItem; if (this._isTypeArrayColumns()) { return this._getArrayColumnsType(); } else { return this._currentColumn.property; } }, _isTypeArrayColumns: function() { if (this._currentColumn.type == "arrayColumns") { return true; } return false; }, _getArrayColumnsType: function() { return this._currentColumn.propertyInArrayItem; } }); }); Loading
public/javascript/redmic/modules/browser/_Table.js +1 −3 Original line number Diff line number Diff line Loading @@ -40,9 +40,7 @@ define([ _paddingHeaderRow: 45, _correctionHeaderRow: -20, _valueRow: 25, tableConfig: { } tableConfig: {} }; lang.mixin(this, this.config); Loading
public/javascript/redmic/modules/browser/row/Row.js +92 −36 Original line number Diff line number Diff line Loading @@ -91,52 +91,93 @@ define([ _updateData: function(item) { put(this.templateNode, "[data-redmic-id=$]", this._getId(item)); this.currentData = item; this._replaceHighlightInItem(item); put(this.templateNode, "[data-redmic-id=$]", this._getId()); this.templateNode.innerHTML = this._insertTemplate(item); this._replaceHighlights(); this.templateNode.innerHTML = this._getContent(); }, _getId: function(item) { _getId: function() { return item[this.idProperty]; return this.currentData[this.idProperty]; }, _insertTemplate: function(item) { _getContent: function() { var json = {data: item}; if (this.itemLabel) { return this._getLabelValue(); } else { return this._insertTemplate(); } }, if (this.i18n) { json.i18n = this.i18n; _getLabelValue: function() { var item = this.currentData; if (this._isItemLabelFunction()) { return this.itemLabel(item); } if (this.shownOptionTemplate) { json.shownOption = this.shownOptionTemplate; if (this._isItemLabelString()) { return this._getItemLabelString(); } if (this.itemLabel) { return this._getLabelValue(item); } else { return this._getTemplate(json); return item[this.itemLabel]; }, _getItemLabelString: function() { var item = this.currentData; if (this.itemLabel.indexOf("{") < 0) { return item[this.itemLabel]; } return lang.replace(this.itemLabel, item); }, _getLabelValue: function(item) { _isItemLabelFunction: function() { if (typeof this.itemLabel === "function") { return this.itemLabel(item); return true; } return false; }, _isItemLabelString: function() { if (typeof this.itemLabel === "string") { if (this.itemLabel.indexOf("{") < 0) { return item[this.itemLabel]; return true; } return lang.replace(this.itemLabel, item); return false; }, _insertTemplate: function() { return this._getTemplate(this._propertiesTemplate()); }, _propertiesTemplate: function() { var obj = { data: this.currentData }; if (this.i18n) { obj.i18n = this.i18n; } return item[this.itemLabel]; if (this.shownOptionTemplate) { obj.shownOption = this.shownOptionTemplate; } return obj; }, _getTemplate: function(dataObj) { Loading @@ -149,29 +190,44 @@ define([ return this.domNode; }, _replaceHighlightInItem: function(item) { _replaceHighlights: function() { var item = this.currentData; if (item && item._meta) { var highlight = item._meta.highlight; for (var content in highlight) { var value = Utilities.getDeepProp(item, content), attr = highlight[content]; for (var property in highlight) { this._replaceHighlight(property, highlight[property]); } } }, _replaceHighlight: function(property, content) { var value = Utilities.getDeepProp(this.currentData, property); if (!value) { return; } for (var i = 0; i < attr.length; i++) { var valueReplace = attr[i], cleanValueReplace = this._cleanValueHighlight(valueReplace); Utilities.setDeepProp(this.currentData, property, this._replaceHighlightInContent(value, content)); }, value = value.replace(cleanValueReplace, valueReplace); } _replaceHighlightInContent: function(value, content) { Utilities.setDeepProp(item, content, value); } var returnValue = value; for (var i = 0; i < content.length; i++) { returnValue = this._replacePartHighlightInContent(returnValue, content[i]); } return returnValue; }, _replacePartHighlightInContent: function(value, content) { return value.replace(this._cleanValueHighlight(content), content); }, _cleanValueHighlight: function(value) { Loading
public/javascript/redmic/modules/browser/row/_Select.js +7 −7 Original line number Diff line number Diff line Loading @@ -147,15 +147,15 @@ define([ _eventChecked: function(idProperty, e) { var action = 'SELECT'; if (this._isSelect()) { this._emitEvt('DESELECT', { idProperty: idProperty }); } else { this._emitEvt('SELECT', { action = 'DESELECT'; } this._emitEvt(action, { idProperty: idProperty }); } }, _isSelect: function() { Loading
public/javascript/redmic/modules/browser/row/_Table.js +124 −59 Original line number Diff line number Diff line Loading @@ -45,103 +45,168 @@ define([ _updateData: function(item) { put(this.tableRowNode, "[data-redmic-id=$]", this._getId(item)); this.currentData = item; put(this.tableRowNode, "[data-redmic-id=$]", this._getId()); this._clearTableRowNode(); this._updateColumns(); }, _clearTableRowNode: function() { while (this.tableRowNode.firstChild) { put(this.tableRowNode.firstChild, '!'); } }, if (this.columns) { _updateColumns: function() { if (this.columns) { for (var i = 0; i < this.columns.length; i++) { var column = this.columns[i], content = this._getContent(item, column); if (!column.type) { this._createCell({ config: column, content: content }); } else if (column.type === "arrayColumns") { this.columns[i].countData = 16; this._generatorColumnsWithArray(column, content); } this._updateColumn(this.columns[i]); } } }, _getContent: function(item, config, property) { _updateColumn: function(column) { var template = false; this._currentColumn = column; if (!config.type) { if (!config.template) { property = "property"; var content = this._getContent(); if (this._isTypeArrayColumns()) { this._currentColumn.countData = 16; this._generatorColumnsWithArray(content); } else { template = true; this._createCell(content); } }, _getContent: function(property) { if (this._isConfigWithTemplate() && !property) { return this._getContentTemplate(); } } else if (config.type === "arrayColumns") { if (!property) { return this._getContentWithPropertyInData(property); }, _getContentWithPropertyInData: function(property) { var data = this.currentData; if (property) { data = this._currentDataArray; } else { property = "property"; } else if (config.template) { template = true; } var content = Utilities.getDeepProp(data, this._currentColumn[property], this.pathSeparator); if (this._isContent(content)) { return content; } if (template) { return config.template({ data: item, return this._currentColumn.notContent || ""; }, _isContent: function(content) { if (content !== null && content !== undefined) { return true; } return false; }, _getContentTemplate: function() { return this._currentColumn.template({ data: this.currentData, i18n: this.i18n }); }, _createCell: function(content) { var nodeItem = this._createNodeCell(); if (this._isConfigWithTemplate()) { nodeItem.innerHTML = content; } else { nodeItem.innerText = this._formatContent(content); } }, var content = Utilities.getDeepProp(item, config[property], this.pathSeparator); _createNodeCell: function() { if (content !== null && content !== undefined) { return content; return put(this.tableRowNode, 'span' + this._classNewNodeCell() + this._attributeDataRemicProperty()); }, _classNewNodeCell: function() { return '.table-cell.table-col-' + (this.tableRowNode.children.length + 1); }, _attributeDataRemicProperty: function() { return '[data-redmic-property="' + this._getProperty() + '"]'; }, _isConfigWithTemplate: function() { if (this._currentColumn.template) { return true; } return config.notContent || ""; return false; }, _createCell: function(obj) { _formatContent: function(content) { var itemConfig = obj.config, content = obj.content, colClass = 'table-col-' + (this.tableRowNode.children.length + 1), nodeItem = put(this.tableRowNode, 'span.table-cell.' + colClass + "[data-redmic-property=$]", this._generatePropertyRow(itemConfig)), format = itemConfig.format; var format = this._currentColumn.format; if (!itemConfig.template) { if (format) { content = format(content); return format(content); } nodeItem.innerText = content; } else { nodeItem.innerHTML = content; } return content; }, _generatorColumnsWithArray: function(itemConfig, data) { _generatorColumnsWithArray: function(data) { for (var i = 0; i < data.length; i++) { this._currentDataArray = data[i]; this._createCell({ config: itemConfig, content: this._getContent(data[i], itemConfig, "propertyInArrayItem") }); var content = this._getContent("propertyInArrayItem"); this._createCell(content); } }, _generatePropertyRow: function(itemConfig) { _getProperty: function() { if (!itemConfig.type) { return itemConfig.property; } else if (itemConfig.type == "arrayColumns") { return itemConfig.propertyInArrayItem; if (this._isTypeArrayColumns()) { return this._getArrayColumnsType(); } else { return this._currentColumn.property; } }, _isTypeArrayColumns: function() { if (this._currentColumn.type == "arrayColumns") { return true; } return false; }, _getArrayColumnsType: function() { return this._currentColumn.propertyInArrayItem; } }); });