[calendar] Fixed issue 19923: Now the OBImageItem resizes its size
authorDavid Baz Fayos <david.baz@openbravo.com>
Mon, 14 Jan 2013 17:17:26 +0100
changeset 19509 b7f8a63e877c
parent 19508 20a19da0ce17
child 19510 9432da04d548
[calendar] Fixed issue 19923: Now the OBImageItem resizes its size
and added 'disabled' and 'readOnly' visualization
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-image.js
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-form-styles.css
modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-form-styles.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-image.js	Mon Jan 14 17:16:46 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-image.js	Mon Jan 14 17:17:26 2013 +0100
@@ -27,6 +27,12 @@
 
 isc.OBImageItemSmallImageContainer.addProperties({
   imageItem: null,
+  initWidget: function () {
+    if (this.initWidgetStyle) {
+      this.initWidgetStyle();
+    }
+    this.Super('initWidget', arguments);
+  },
   click: function () {
     var imageId = this.imageItem.getValue();
     if (!imageId) {
@@ -107,6 +113,12 @@
     if (this.creator.required) {
       this.imageLayout.setStyleName(this.imageLayout.styleName + 'Required');
     }
+    if (this.creator.disabled) {
+      this.imageLayout.setStyleName(this.imageLayout.styleName + 'Disabled');
+    }
+    if (this.creator.readOnly) {
+      this.imageLayout.setStyleName(this.imageLayout.styleName + 'Disabled');
+    }
     this.addMember(this.imageLayout);
     this.image = isc.OBImageItemSmallImage.create({
       width: '100%'
@@ -248,8 +260,8 @@
       });
     }
     //Buttons will not be shown if the form is readonly
-    this.canvas.deleteButton.updateState(newValue && !this.form.readOnly && !this.readOnly);
-    this.canvas.selectorButton.updateState(!this.form.readOnly && !this.readOnly);
+    this.canvas.deleteButton.updateState(newValue && (this.form && !this.form.readOnly) && !this.readOnly);
+    this.canvas.selectorButton.updateState((this.form && !this.form.readOnly) && !this.readOnly);
     return this.Super('setValue', arguments);
   },
   refreshImage: function (imageId) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-form-styles.css	Mon Jan 14 17:16:46 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-form-styles.css	Mon Jan 14 17:17:26 2013 +0100
@@ -221,7 +221,9 @@
 .OBFormFieldNumberInputRequiredHint,
 
 .OBFormFieldImageInput,
-.OBFormFieldImageInputRequired {
+.OBFormFieldImageInputDisabled,
+.OBFormFieldImageInputRequired,
+.OBFormFieldImageInputRequiredDisabled {
   border: 1px solid #cdd7bb;
   background-color: #F5F7F1;
   color: #333333;
@@ -236,10 +238,12 @@
 .OBFormFieldSelectInputRequiredDisabled,
 .OBFormFieldDateInputRequiredDisabled,
 .OBFormFieldNumberInputRequiredDisabled,
+.OBFormFieldImageInputRequiredDisabled,
 .OBFormFieldInputDisabled,
 .OBFormFieldSelectInputDisabled,
 .OBFormFieldDateInputDisabled,
-.OBFormFieldNumberInputDisabled {
+.OBFormFieldNumberInputDisabled,
+.OBFormFieldImageInputDisabled {
   border: 0px none;
   background-color: transparent;
   color: #7d7d7d;
--- a/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-form-styles.js	Mon Jan 14 17:16:46 2013 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/ob-form-styles.js	Mon Jan 14 17:17:26 2013 +0100
@@ -465,10 +465,21 @@
 
 isc.OBImageItemSmallImageContainer.addProperties({
   styleName: 'OBFormFieldImageInput',
-  height: 66,
+  height: 21,
   width: '100%',
   align: 'center',
-  defaultLayoutAlign: 'center'
+  defaultLayoutAlign: 'center',
+  initWidgetStyle: function () {
+    //To adapt the height this code is used because the automatic height doesn't fill empty rows.
+    var rowSpan = 1;
+    var singleRowHeight = this.getHeight();
+    var multipleRowHeight = singleRowHeight + 24; // 24px = title height + form item padding defined in CSS
+    if (this.imageItem.rowSpan) {
+      rowSpan = this.imageItem.rowSpan;
+    }
+    var newHeight = singleRowHeight + (rowSpan - 1) * multipleRowHeight;
+    this.setHeight(newHeight);
+  }
 });
 
 isc.OBImageItemSmallImage.addProperties({