[attachments] Improved styling of upload button
authorAntonio Moreno <antonio.moreno@openbravo.com>
Thu, 12 May 2011 10:00:22 +0200
changeset 12121 999211f9625a
parent 12120 9069258ded36
child 12122 40eaf826d462
[attachments] Improved styling of upload button
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-attachments.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js	Wed May 11 17:24:52 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js	Thu May 12 10:00:22 2011 +0200
@@ -138,8 +138,8 @@
     buttonType: 'eliminate',
     prompt: OB.I18N.getLabel('OBUIAPP_DeleteRow'),
     updateState: function(){
-      var view = this.view, form = view.viewForm, grid = view.viewGrid, selectedRecords = grid.getSelectedRecords();
-      for (var i = 0; i < selectedRecords.length; i++) {
+      var view = this.view, form = view.viewForm, grid = view.viewGrid, selectedRecords = grid.getSelectedRecords(), i;
+      for (i = 0; i < selectedRecords.length; i++) {
         if (!grid.isWritable(selectedRecords[i])) {
           this.setDisabled(true);
           return;
@@ -186,7 +186,7 @@
     buttonType: 'undo',
     prompt: OB.I18N.getLabel('OBUIAPP_Undo'),
     updateState: function(){
-      var view = this.view, form = view.viewForm, grid = view.viewGrid, hasErrors = false, editRow;
+      var view = this.view, form = view.viewForm, grid = view.viewGrid, hasErrors = false, editRow, i;
       if (view.isShowingForm) {
         this.setDisabled(form.isSaving || form.readOnly || !view.hasValidState() ||
         !form.hasChanged);
@@ -200,7 +200,7 @@
         !form.hasChanged));
       } else {
         var selectedRecords = grid.getSelectedRecords(), allRowsHaveErrors = true;
-        for (var i = 0; i < selectedRecords.length; i++) {
+        for (i = 0; i < selectedRecords.length; i++) {
           var rowNum = grid.getRecordIndex(selectedRecords[i]);
           allRowsHaveErrors = allRowsHaveErrors && grid.rowHasErrors(rowNum);
         }
@@ -276,15 +276,7 @@
             {name: 'buttonId', type: 'hidden', value: this.ID},
             {name: 'inpKey', type: 'hidden', value: this.view.viewGrid.getSelectedRecord().id},
             {name: 'inpTabId', type: 'hidden', value: this.view.tabId},
-            {name: 'inpwindowId', type: 'hidden', value: this.view.windowId},
-            {name: 'submitbutton', type: 'button', title: OB.I18N.getLabel('OBUIAPP_AttachmentSubmit'),
-              click: function(form, item){
-                form.button.customState = 'Progress';
-                form.button.resetBaseStyle();
-                form.submitForm();
-                popup.hide();
-              }
-            }
+            {name: 'inpwindowId', type: 'hidden', value: this.view.windowId}
           ],
           encoding: 'multipart',
           action: './businessUtility/TabAttachments_FS.html',
@@ -298,9 +290,22 @@
           },
           button: this
         });
+
+      	var submitbutton = isc.Button.create({
+      		title: OB.I18N.getLabel('OBUIAPP_AttachmentSubmit'),
+      		theForm: form,
+      		click: function(){
+      		  var form = this.theForm;
+      		  form.button.customState = 'Progress';
+      		  form.button.resetBaseStyle();
+      		  form.submitForm();
+              popup.hide();
+            }
+      	});
         this.oldForm = form;
-        var horizontalLayout = isc.VStack.create({
+        var horizontalLayout = isc.HLayout.create({
           width: '100%',
+          height: '30px',
           align: 'right'
         });
         var popup = isc.OBPopup.create({
@@ -309,6 +314,7 @@
           align: 'right',
           initWidget: function(args){
           horizontalLayout.addMember(form);
+          horizontalLayout.addMember(submitbutton);
           this.items = horizontalLayout;
           this.Super('initWidget', arguments);
           }
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-attachments.js	Wed May 11 17:24:52 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-attachments.js	Thu May 12 10:00:22 2011 +0200
@@ -212,69 +212,75 @@
             {name: 'buttonId', type: 'hidden', value: this.canvas.ID},
             {name: 'inpKey', type: 'hidden', value: this.canvas.recordId},
             {name: 'inpTabId', type: 'hidden', value: this.canvas.tabId},
-            {name: 'inpwindowId', type: 'hidden', value: this.canvas.windowId},
-            {name: 'submitbutton', type: 'button', title: OB.I18N.getLabel('OBUIAPP_AttachmentSubmit'), align:'right',
-              click: function(form, item){
-                var addFunction = function(clickedOK){
-                  if(clickedOK){
-                    var hTempLayout = isc.HLayout.create();
-                    form.theCanvas.addMember(hTempLayout,form.theCanvas.getMembers().size());
-                    var uploadingFile = isc.Label.create({
-                      contents: fileName
-                    });
-                    var uploading = isc.Label.create({
-                        className: 'OBSectionItemControlLinkUploading',
-                        contents: '    '+OB.I18N.getLabel('OBUIAPP_AttachmentUploading')
-                    });
-                    hTempLayout.addMember(uploadingFile);
-                    hTempLayout.addMember(uploading);
-                    var button =  form.theCanvas.getForm().view.toolBar.getLeftMember(isc.OBToolbar.TYPE_ATTACHMENTS);
-                    if(!button) {
-                      button =  form.theCanvas.getForm().view.toolBar.getLeftMember("attachExists");
-                    }
-                    button.customState = 'Progress';
-                    button.resetBaseStyle();
-                    form.submitForm();
-                    form.popup.hide();
-                  }
-                };
-                var value = form.getItem('inpname').getElement().value;
-                value = value?value:'';
-                var lastChar=value.lastIndexOf("\\") + 1;
-                var fileName = lastChar===-1?value:value.substring(lastChar);
-                if(form.theCanvas.fileExists(fileName, attachments)){
-                  isc.confirm(OB.I18N.getLabel('OBUIAPP_ConfirmUploadOverwrite'), addFunction);
-                }else{
-                  addFunction(true);
-                }
-              }
-            }
+            {name: 'inpwindowId', type: 'hidden', value: this.canvas.windowId}
           ],
           encoding: 'multipart',
           action: './businessUtility/TabAttachments_FS.html',
           target: "background_target",
           numCols: 4,
           align: 'right',
+          height: '30px',
           redraw: function(){
           },
           theCanvas: this.canvas
-        });
-        var horizontalLayout = isc.VStack.create({
-          width: '100%',
-          align: 'right'
-        });
-        var popup = isc.OBPopup.create({
-          height: 30,
-          width: 300,
-          align: 'right',
-          initWidget: function(args){
+      });
+      var submitbutton = isc.Button.create({
+        title: OB.I18N.getLabel('OBUIAPP_AttachmentSubmit'),
+        theForm: form,
+        click: function(){
+          var form = this.theForm;
+          var addFunction = function(clickedOK){
+            if(clickedOK){
+              var hTempLayout = isc.HLayout.create();
+               form.theCanvas.addMember(hTempLayout,form.theCanvas.getMembers().size());
+              var uploadingFile = isc.Label.create({
+                contents: fileName
+              });
+              var uploading = isc.Label.create({
+                 className: 'OBSectionItemControlLinkUploading',
+                 contents: '    '+OB.I18N.getLabel('OBUIAPP_AttachmentUploading')
+              });
+              hTempLayout.addMember(uploadingFile);
+              hTempLayout.addMember(uploading);
+              var button =  form.theCanvas.getForm().view.toolBar.getLeftMember(isc.OBToolbar.TYPE_ATTACHMENTS);
+              if(!button) {
+                button =  form.theCanvas.getForm().view.toolBar.getLeftMember("attachExists");
+              }
+              button.customState = 'Progress';
+              button.resetBaseStyle();
+              form.submitForm();
+              form.popup.hide();
+            }
+          };
+          var value = this.theForm.getItem('inpname').getElement().value;
+          value = value?value:'';
+          var lastChar=value.lastIndexOf("\\") + 1;
+          var fileName = lastChar===-1?value:value.substring(lastChar);
+          if(this.theForm.theCanvas.fileExists(fileName, attachments)){
+            isc.confirm(OB.I18N.getLabel('OBUIAPP_ConfirmUploadOverwrite'), addFunction);
+          }else{
+            addFunction(true);
+          }
+        }
+      });
+      var horizontalLayout = isc.HLayout.create({
+        width: '100%',
+        height: '30px',
+        align: 'right'
+      });
+      var popup = isc.OBPopup.create({
+        height: 30,
+        width: 300,
+        align: 'right',
+        initWidget: function(args){
           horizontalLayout.addMember(form);
-            this.items = horizontalLayout;
-            this.Super('initWidget', arguments);
-          }
-        });
-        form.popup = popup;
-        popup.show();
+          horizontalLayout.addMember(submitbutton);
+          this.items = horizontalLayout;
+          this.Super('initWidget', arguments);
+        }
+      });
+      form.popup = popup;
+      popup.show();
       }
     });
     hLayout.addMember(addButton);