From 0a93f3dc0ce2ad6edecbba05abf17f34f5b4f97f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 27 Aug 2014 17:28:07 +0000 Subject: [PATCH] backport of Nathans r48352: Fix history log widget no longer working --- .../class.etemplate_widget_historylog.inc.php | 23 ++++++++++++++++++ .../class.etemplate_widget_nextmatch.inc.php | 9 ++++--- etemplate/js/et2_widget_historylog.js | 24 +++++++++++++------ etemplate/js/et2_widget_selectbox.js | 2 +- infolog/templates/pixelegg/app.css | 3 --- infolog/templates/pixelegg/app.less | 12 +++------- 6 files changed, 50 insertions(+), 23 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_historylog.inc.php b/etemplate/inc/class.etemplate_widget_historylog.inc.php index b39ae7a0ac..5b60719eb1 100644 --- a/etemplate/inc/class.etemplate_widget_historylog.inc.php +++ b/etemplate/inc/class.etemplate_widget_historylog.inc.php @@ -63,4 +63,27 @@ class etemplate_widget_historylog extends etemplate_widget } } } + + /** + * Validate input + * + * For dates (except duration), it is always a full timestamp in W3C format, + * which we then convert to the format the application is expecting. This can + * be either a unix timestamp, just a date, just time, or whatever is + * specified in the template. + * + * @param string $cname current namespace + * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' + * @param array $content + * @param array &$validated=array() validated content + * @return boolean true if no validation error, false otherwise + */ + public function validate($cname, array $expand, array $content, &$validated=array()) + { + $form_name = self::form_name($cname, $this->id, $expand); + $value = self::get_array($content, $form_name); + $valid =& self::get_array($validated, $form_name, true); + $valid = $value; + return true; + } } diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index 202de6b2e9..45e49c81bd 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -294,14 +294,17 @@ class etemplate_widget_nextmatch extends etemplate_widget if (($template = etemplate_widget_template::instance(self::$request->template['name'], self::$request->template['template_set'], self::$request->template['version'], self::$request->template['load_via']))) { - $template = $template->getElementById($form_name); + $template = $template->getElementById($form_name, strpos($form_name, 'history') == 0 ? 'historylog' : 'nextmatch'); $expand = array( 'cont' => array($form_name => $filters), ); $valid_filters = array(); - $template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false); // $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret - $filters = $valid_filters[$form_name]; + if($template) + { + $template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false); // $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret + $filters = $valid_filters[$form_name]; + } //error_log($this . " Valid filters: " . array2string($filters)); } diff --git a/etemplate/js/et2_widget_historylog.js b/etemplate/js/et2_widget_historylog.js index ce6d2ee067..2c4768d169 100644 --- a/etemplate/js/et2_widget_historylog.js +++ b/etemplate/js/et2_widget_historylog.js @@ -33,6 +33,7 @@ */ var et2_historylog = et2_valueWidget.extend([et2_IDataProvider], { + createNamespace: true, attributes: { "value": { "name": "Value", @@ -52,8 +53,8 @@ var et2_historylog = et2_valueWidget.extend([et2_IDataProvider], {'id': 'user_ts', caption: 'Date', 'width': '120px', widget_type: 'date-time'}, {'id': 'owner', caption: 'User', 'width': '150px', widget_type: 'select-account'}, {'id': 'status', caption: 'Changed', 'width': '120px', widget_type: 'select'}, - {'id': 'new_value', caption: 'New Value', 'width': 'auto'}, - {'id': 'old_value', caption: 'Old Value', 'width': 'auto'} + {'id': 'new_value', caption: 'New Value', 'width': '50%'}, + {'id': 'old_value', caption: 'Old Value', 'width': '50%'} ], TIMESTAMP: 0, OWNER: 1, FIELD: 2, NEW_VALUE: 3, OLD_VALUE: 4, @@ -415,7 +416,13 @@ var et2_historylog = et2_valueWidget.extend([et2_IDataProvider], { nodes = self.columns[i].nodes.clone(); } - else if (self._needsDiffWidget(_data['status'], _data[self.columns[self.OLD_VALUE].id]) || + else if (( + // Already parsed & cached + typeof _data[self.columns[self.NEW_VALUE].id] == "object" && + typeof _data[self.columns[self.NEW_VALUE].id].new != "undefined") || + // Large old value + self._needsDiffWidget(_data['status'], _data[self.columns[self.OLD_VALUE].id]) || + // Large new value self._needsDiffWidget(_data['status'], _data[self.columns[self.NEW_VALUE].id])) { // Large text value - span both columns, and show a nice diff @@ -426,10 +433,13 @@ var et2_historylog = et2_valueWidget.extend([et2_IDataProvider], widget = self.diff.widget; nodes = self.diff.nodes.clone(); - _data[self.columns[i].id] = { - 'old': _data[self.columns[i+1].id], - 'new': _data[self.columns[i].id] - }; + if (typeof _data[self.columns[self.NEW_VALUE].id] == "string") + { + _data[self.columns[i].id] = { + 'old': _data[self.columns[i+1].id], + 'new': _data[self.columns[i].id] + }; + } // Skip column 4 jthis.parents("td").attr("colspan", 2) diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 1a78c7810a..7c5e9fd1b3 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -944,7 +944,7 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM], for(var o in this.optionValues) { var option = this.optionValues[o]; - var key = typeof option == 'object' && typeof option.value != 'undefined' ? option.value : o; + var key = typeof option == 'object' && option != null && typeof option.value != 'undefined' ? option.value : o; if (key != _value[i]) continue; var label = typeof option == 'object' ? option.label : option; if (_value.length == 1) diff --git a/infolog/templates/pixelegg/app.css b/infolog/templates/pixelegg/app.css index 99d0d2c053..1c2b9a2c89 100755 --- a/infolog/templates/pixelegg/app.css +++ b/infolog/templates/pixelegg/app.css @@ -349,9 +349,6 @@ tr.dialogOperators td, #infolog-edit table.egwGridView_outer { max-width: 100%; } -#infolog-edit #infolog-edit_history { - max-width: 785px; -} #infolog-edit div.et2_hbox { white-space: nowrap; } diff --git a/infolog/templates/pixelegg/app.less b/infolog/templates/pixelegg/app.less index deed78cb57..b9f9a2b7fe 100755 --- a/infolog/templates/pixelegg/app.less +++ b/infolog/templates/pixelegg/app.less @@ -290,19 +290,13 @@ div.et2_box_widget{ table.egwGridView_outer{ max-width: 100%; } - // Tab History - - #infolog-edit_history{ - max-width: 785px; - } - div.et2_hbox { - white-space: nowrap; -} + white-space: nowrap; + } } .infolog_fixedHeight { -height: auto; + height: auto; } //TYP