From e56aac9ef8aa45e5b0cb2c159a8a924c3eff94b3 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Fri, 25 May 2012 10:22:22 +0000 Subject: [PATCH] User editable dashboards... implementation in progress SVN:trunk[2036] --- js/dashboard.js | 4 --- js/property_field.js | 70 ++++++++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/js/dashboard.js b/js/dashboard.js index 37b70e1cb..2e0d2b9b3 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -66,10 +66,6 @@ $(function() { // in 1.9 would use _super $.Widget.prototype._setOption.call( this, key, value ); - if (key == 'layout') - { - _refresh(); - } }, _get_state: function(oMergeInto) { diff --git a/js/property_field.js b/js/property_field.js index a9cfa2540..943e43338 100644 --- a/js/property_field.js +++ b/js/property_field.js @@ -10,7 +10,9 @@ $(function() { field_id: '', submit_to: 'index.php', - submit_parameters: {operation: 'async_action'} + submit_parameters: {operation: 'async_action'}, + do_apply: null, + do_cancel: null }, @@ -98,41 +100,57 @@ $(function() }, _do_apply: function() { - // Validate the field - sFormId = this.element.closest('form').attr('id'); - var oField = $('#'+this.options.field_id); - oField.trigger('validate'); - if ( $.inArray(this.options.field_id, oFormValidation[sFormId]) == -1) + if (this.options.do_apply) { - this.bModified = false; - this.previous_value = this.value; - this.value = this._get_field_value(); - this._do_submit(); - this._refresh(); + // specific behavior... + this.options.do_apply(); + } + else + { + // Validate the field + sFormId = this.element.closest('form').attr('id'); + var oField = $('#'+this.options.field_id); + oField.trigger('validate'); + if ( $.inArray(this.options.field_id, oFormValidation[sFormId]) == -1) + { + this.bModified = false; + this.previous_value = this.value; + this.value = this._get_field_value(); + this._do_submit(); + this._refresh(); + } } }, _do_cancel: function() { - this.bModified = false; - var oField = $('#'+this.options.field_id); - if (oField.attr('type') == 'checkbox') + if (this.options.do_cancel) { - if (this.value) - { - oField.attr('checked', true); - } - else - { - oField.removeAttr('checked'); - } + // specific behavior... + this.options.do_cancel(); } else { - oField.val(this.value); + this.bModified = false; + var oField = $('#'+this.options.field_id); + if (oField.attr('type') == 'checkbox') + { + if (this.value) + { + oField.attr('checked', true); + } + else + { + oField.removeAttr('checked'); + } + } + else + { + oField.val(this.value); + } + this._refresh(); + oField.trigger('reverted', {type: 'designer', previous_value: this.value }); + oField.trigger('validate'); } - this._refresh(); - oField.trigger('reverted', {type: 'designer', previous_value: this.value }); - oField.trigger('validate'); }, _do_submit: function() {