diff --git a/phpgwapi/inc/class.egw_grid_columns.inc.php b/phpgwapi/inc/class.egw_grid_columns.inc.php index 5e0e7481e9..30fdb5d30f 100644 --- a/phpgwapi/inc/class.egw_grid_columns.inc.php +++ b/phpgwapi/inc/class.egw_grid_columns.inc.php @@ -167,6 +167,7 @@ define("EGW_COL_TYPE_NAME_ICON_FIXED", 1); define("EGW_COL_VISIBILITY_ALWAYS", 0); define("EGW_COL_VISIBILITY_VISIBLE", 1); define("EGW_COL_VISIBILITY_INVISIBLE", 2); +define("EGW_COL_VISIBILITY_ALWAYS_NOSELECT", 3); define("EGW_COL_SORTABLE_NONE", 0); define("EGW_COL_SORTABLE_ALPHABETIC", 1); @@ -210,7 +211,7 @@ class egw_grid_column extends egw_json_object public function set_visible($val) { - if ($this->visibility != EGW_COL_VISIBILITY_ALWAYS) + if ($this->visibility != EGW_COL_VISIBILITY_ALWAYS && $this->visibility != EGW_COL_VISIBILITY_ALWAYS_NOSELECT) { $this->visibility = $val ? EGW_COL_VISIBILITY_VISIBLE : EGW_COL_VISIBILITY_INVISIBLE; } diff --git a/phpgwapi/js/egw_action/egw_action_common.js b/phpgwapi/js/egw_action/egw_action_common.js index 37bdbc2de3..132af76739 100644 --- a/phpgwapi/js/egw_action/egw_action_common.js +++ b/phpgwapi/js/egw_action/egw_action_common.js @@ -128,6 +128,18 @@ function egwCallAbstract(_obj, _fn, _args) return false; } +function egwArraysEqual(_ar1, _ar2) +{ + var result = _ar1.length == _ar2.length; + + for (var i = 0; i < _ar1.length; i++) + { + result = result && (_ar1[i] == _ar2[i]) + } + + return result; +} + /** sprintf() for JavaScript 0.6 diff --git a/phpgwapi/js/egw_action/egw_action_dragdrop.js b/phpgwapi/js/egw_action/egw_action_dragdrop.js index 0c0e701fa1..ee2c2d931a 100644 --- a/phpgwapi/js/egw_action/egw_action_dragdrop.js +++ b/phpgwapi/js/egw_action/egw_action_dragdrop.js @@ -32,6 +32,11 @@ _egwActionClasses["drop"] = { "implementation": getDropImplementation } +function _getTopBody() +{ + return $("body", window.top); +} + /** * The egwDragAction class overwrites the egwAction class and adds the new @@ -112,7 +117,7 @@ function egwDragActionImplementation() // fixes a bug in IE: If the element isn't inserted into // the DOM-tree jquery appends it to the parent node. // In case this is a table it doesn't work correctly - $("body").append(ai.helper); + _getTopBody().append(ai.helper); return ai.helper; } diff --git a/phpgwapi/js/egw_action/egw_grid.js b/phpgwapi/js/egw_action/egw_grid.js index 1c13ffa4c0..a2dfe6a2d9 100644 --- a/phpgwapi/js/egw_action/egw_grid.js +++ b/phpgwapi/js/egw_action/egw_grid.js @@ -173,3 +173,12 @@ egwGrid.prototype.reload = function() this.gridOuter.empty(); } +/** + * Returns the height of the data inserted into the grid + */ +egwGrid.prototype.getDataHeight = function() +{ + return this.gridOuter.grid.getHeight(); +} + + diff --git a/phpgwapi/js/egw_action/egw_grid_columns.js b/phpgwapi/js/egw_action/egw_grid_columns.js index c6c994d604..117467ea7e 100644 --- a/phpgwapi/js/egw_action/egw_grid_columns.js +++ b/phpgwapi/js/egw_action/egw_grid_columns.js @@ -26,6 +26,7 @@ var EGW_COL_TYPE_NAME_ICON_FIXED = 1; var EGW_COL_VISIBILITY_ALWAYS = 0; var EGW_COL_VISIBILITY_VISIBLE = 1; var EGW_COL_VISIBILITY_INVISIBLE = 2; +var EGW_COL_VISIBILITY_ALWAYS_NOSELECT = 3; var EGW_COL_SORTABLE_NONE = 0; var EGW_COL_SORTABLE_ALPHABETIC = 1; @@ -141,11 +142,6 @@ egwGridColumn.prototype.set_type = function(_value) if (typeof _value == "number" && (_value == EGW_COL_TYPE_DEFAULT || _value == EGW_COL_TYPE_NAME_ICON_FIXED)) { - if (_value == EGW_COL_TYPE_NAME_ICON_FIXED) - { - this.visibility = EGW_COL_VISIBILITY_ALWAYS; - } - this.type = _value; } } @@ -157,22 +153,16 @@ egwGridColumn.prototype.set_type = function(_value) egwGridColumn.prototype.set_visibility = function(_value) { if (typeof _value == "number" && (_value == EGW_COL_VISIBILITY_ALWAYS || - _value == EGW_COL_VISIBILITY_INVISIBLE || _value == EGW_COL_VISIBILITY_VISIBLE)) + _value == EGW_COL_VISIBILITY_INVISIBLE || _value == EGW_COL_VISIBILITY_VISIBLE || + _value == EGW_COL_VISIBILITY_ALWAYS_NOSELECT)) { - if (this.type == EGW_COL_TYPE_NAME_ICON_FIXED) + if (_value != this.visibility) { - this.visibility = EGW_COL_VISIBILITY_ALWAYS; - } - else - { - if (_value != this.visibility) - { - this.visibility = _value; + this.visibility = _value; - if (this.visibilityChangeCallback) - { - this.visibilityChangeCallback.call(this.context, this); - } + if (this.visibilityChangeCallback) + { + this.visibilityChangeCallback.call(this.context, this); } } } @@ -518,11 +508,15 @@ egwGridColumns.prototype.getColumnVisibilitySet = function() for (var i = 0; i < this.columns.length; i++) { - result[this.columns[i].id] = { - "caption": this.columns[i].caption, - "enabled": this.columns[i].visibility != EGW_COL_VISIBILITY_ALWAYS, - "visible": this.columns[i].visibility != EGW_COL_VISIBILITY_INVISIBLE - }; + if (this.columns[i].visibility != EGW_COL_VISIBILITY_ALWAYS_NOSELECT) + { + result[this.columns[i].id] = { + "caption": this.columns[i].caption, + "enabled": (this.columns[i].visibility != EGW_COL_VISIBILITY_ALWAYS) && + (this.columns[i].type == EGW_COL_TYPE_DEFAULT), + "visible": this.columns[i].visibility != EGW_COL_VISIBILITY_INVISIBLE + }; + } } return result; diff --git a/phpgwapi/js/egw_action/egw_grid_data.js b/phpgwapi/js/egw_action/egw_grid_data.js index 500fc25c0f..bd67b39ea2 100644 --- a/phpgwapi/js/egw_action/egw_grid_data.js +++ b/phpgwapi/js/egw_action/egw_grid_data.js @@ -60,6 +60,7 @@ function egwGridDataElement(_id, _parent, _columns, _readQueue, _objectManager) this.caption = false; this.iconUrl = false; this.iconSize = false; + this.iconOverlay = []; this.opened = _parent == null; this.index = 0; this.canHaveChildren = false; @@ -69,6 +70,7 @@ function egwGridDataElement(_id, _parent, _columns, _readQueue, _objectManager) this.actionLinkGroups = {}; this.group = false; this.capColTime = 0; + this.rowClass = ""; this.gridViewObj = null; } @@ -80,6 +82,14 @@ egwGridDataElement.prototype.free = function() //TODO } +egwGridDataElement.prototype.set_rowClass = function(_value) +{ + if (_value != this.rowClass) + { + this.rowClass = _value; + } +} + egwGridDataElement.prototype.set_caption = function(_value) { if (_value != this.caption) @@ -98,6 +108,16 @@ egwGridDataElement.prototype.set_iconUrl = function(_value) } } +egwGridDataElement.prototype.set_iconOverlay = function(_value) +{ + if (!egwArraysEqual(_value, this.iconOverlay)) + { + this.capColTime = EGW_GRID_DATA_UPDATE_TIME; + this.iconOverlay = _value; + } +} + + egwGridDataElement.prototype.set_iconSize = function(_value) { if (_value != this.iconSize) @@ -207,8 +227,9 @@ egwGridDataElement.prototype.set_data = function(_value) * [ * { * ["entryType": (EGW_DATA_TYPE_ELEMENT | EGW_DATA_TYPE_RANGE)] // Defaults to EGW_DATA_TYPE_ELEMENT - * "type": "[Typeclass]" // Typeclass of the view-container: specifies the chars after the egwGridView-prefix. Defaults to "Row" which becomes "egwGridViewRow" + * "type": "[Typeclass]" // Typeclass of the view-container: specifies the chars after the egwGridView-prefix. Defaults to "Row" which becomes "egwGridViewRow", * IF EGW_DATA_TYPE_ELEMENT: + * "id": [ Name of the element ] * "children": [ Objects which will be added to the children of the element ] * ELEMENT DATA // See below IF EGW_DATA_TYPE_RANGE: @@ -217,7 +238,10 @@ egwGridDataElement.prototype.set_data = function(_value) * } * ] * - * 2. If an object with element dara is passed, the properties of the element will + * 2. If a string or number is passed, inside an array, it is encapsulated into + * an empty entry with that id + * + * 3. If an object with element dara is passed, the properties of the element will * be updated to the given values. * * { @@ -247,6 +271,15 @@ egwGridDataElement.prototype.loadData = function(_data, _doCallUpdate) { var entry = _data[i]; + // Single string entries are automatically converted to an entry + // with that id + if (typeof entry == String || typeof entry == Number) + { + entry = { + "id": (entry + '') // The "+ ''" converts the entry to a string + } + } + if (entry.constructor != Object) { continue; diff --git a/phpgwapi/js/egw_action/egw_grid_view.js b/phpgwapi/js/egw_action/egw_grid_view.js index ed592a4b27..76d6ef2abd 100644 --- a/phpgwapi/js/egw_action/egw_grid_view.js +++ b/phpgwapi/js/egw_action/egw_grid_view.js @@ -1295,6 +1295,7 @@ function egwGridViewRow(_grid, _heightChangeProc, _item) container.containerClass = "row"; container.childGrid = null; container.opened = false; + container.rowClass = ""; // Overwrite the inherited abstract functions container.doInsertIntoDOM = egwGridViewRow_doInsertIntoDOM; @@ -1433,6 +1434,19 @@ function egwGridViewRow_doUpdateData(_immediate) var data = this.item.getData(ids); var vis_idx = 0; + // Set the row class + if (this.rowClass != this.item.rowClass) + { + if (this.rowClass != "") + { + this.parentNode.removeClass(this.rowClass); + } + + this.parentNode.addClass(this.item.rowClass); + this.rowClass = this.item.rowClass; + } + + // Set the column data for (var i = 0; i < this.tdObjects.length; i++) { var col = this.columns[i]; @@ -1509,6 +1523,9 @@ function egwGridViewRow_doUpdateData(_immediate) iconContainer.css("min-height", this.grid.avgIconHeight + "px"); // Build the icon + var overlayCntr = $(document.createElement("span")); + overlayCntr.addClass("iconOverlayContainer"); + var icon = $(document.createElement("img")); if (this.item.iconSize) { @@ -1526,8 +1543,18 @@ function egwGridViewRow_doUpdateData(_immediate) }, 100); e.data.item.callHeightChangeProc(); }); + overlayCntr.append(icon); + + for (var i = 0; i < this.item.iconOverlay.length; i++) + { + var overlay = $(document.createElement("img")); + overlay.addClass("overlay"); + overlay.attr("src", this.item.iconOverlay[i]); + overlayCntr.append(overlay); + } + icon.addClass("icon"); - iconContainer.append(icon); + iconContainer.append(overlayCntr); cont.append(iconContainer); } diff --git a/phpgwapi/js/egw_action/test/test_grid_view.html b/phpgwapi/js/egw_action/test/test_grid_view.html index b5bdd2f737..aa8745340d 100644 --- a/phpgwapi/js/egw_action/test/test_grid_view.html +++ b/phpgwapi/js/egw_action/test/test_grid_view.html @@ -242,6 +242,7 @@ ] ); grid.resize(1500, 500); + grid.reload(); }); function check_positions(_grid, _delta) diff --git a/phpgwapi/templates/idots/css/traditional.css b/phpgwapi/templates/idots/css/traditional.css index e0fda73237..78a8a301fd 100755 --- a/phpgwapi/templates/idots/css/traditional.css +++ b/phpgwapi/templates/idots/css/traditional.css @@ -595,7 +595,7 @@ Preferences tabs border-spacing: 0; border-collapse: collapse; padding: 0; - margin: 5px; +/* margin: 5px;*/ } .egwGridView_outer td, .egwGridView_outer tr { @@ -645,12 +645,25 @@ Preferences tabs vertical-align: middle; } -.egwGridView_grid img.icon { - vertical-align: middle; +.egwGridView_grid span.iconOverlayContainer { margin: 2px 5px 2px 2px; + position: relative; -moz-user-select: none; -khtml-user-select: none; user-select: none; + overflow: visible; +} + +.egwGridView_grid span.iconOverlayContainer img.overlay { + position: absolute; + right: -2px; + bottom: -2px; + vertical-align: bottom; +} + +.egwGridView_grid img.icon { + vertical-align: middle; + margin: 0; } .egwGridView_grid span.arrow {