window design, error correction, Validity
authorStefanie Stamer <s.stamer@metaways.de>
Thu, 8 Sep 2011 15:14:44 +0000 (17:14 +0200)
committerMichael Spahn <m.spahn@metaways.de>
Thu, 4 Oct 2012 13:54:55 +0000 (15:54 +0200)
tine20/Inventory/Setup/setup.xml
tine20/Inventory/js/InventoryItemEditDialog.js
tine20/Inventory/js/InventoryItemGridPanel.js
tine20/Inventory/js/Model.js

index a40584f..f0bc4a6 100644 (file)
@@ -40,7 +40,7 @@
                     <name>inventory_id</name>
                     <type>text</type>
                     <length>255</length>
-                    <notnull>true</notnull>
+                    <notnull>false</notnull>
                 </field>
                 <field>
                     <name>description</name>
@@ -57,7 +57,7 @@
                 <field>
                     <name>add_time</name>
                     <type>datetime</type>
-                    <notnull>true</notnull>
+                    <notnull>false</notnull>
                 </field>
                 <field>
                     <name>total_number</name>
index cd40659..7915b5d 100644 (file)
@@ -69,6 +69,20 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
     },
     
     /**
+     * check validity of activ numer field
+     */
+    isValid: function () {
+        var form = this.getForm();
+        var isValid = true;
+        if (form.findField('total_number').getValue() < form.findField('active_number').getValue()) {
+            var invalidString = String.format(this.app.i18n._('The active number must be less than or equal total number.'));
+            form.findField('active_number').markInvalid(invalidString);
+            isValid = false;
+        }
+        return isValid && Tine.Inventory.InventoryItemEditDialog.superclass.isValid.apply(this, arguments);
+    },
+    
+    /**
      * returns dialog
      * 
      * NOTE: when this method gets called, all initalisation is done.
@@ -100,55 +114,78 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
                         columnWidth: .333
                     },
                     items: [[{
+                        
                         columnWidth: 1,
                         xtype: 'tine.widget.field.AutoCompleteField',
                         recordClass: this.recordClass,
                         fieldLabel: this.app.i18n._('Name'),
                         name: 'name',
+                        columnWidth: 0.5,
                         allowBlank: false
-                        }], [new Tine.Tinebase.widgets.keyfield.ComboBox({
+                        }new Tine.Tinebase.widgets.keyfield.ComboBox({
                             app: 'Inventory',
                             keyFieldName: 'inventoryType',
                             fieldLabel: this.app.i18n._('Type'),
                             name: 'type',
-                            columnWidth: 0.5
+                            columnWidth: 0.5,
+                            allowBlank: false
                         })],
                         [{
-                            columnWidth: 0.5,
+                            columnWidth: 1,
                             fieldLabel: this.app.i18n._('ID'),
                             name: 'inventory_id',
-                            allowBlank: false
+                            
+                        }],
+                        [{
+                               xtype: 'textarea',
+                            name: 'description',
+                            fieldLabel: this.app.i18n._('Description'),
+                            grow: false,
+                            preventScrollbars: false,
+                            columnWidth: 1,
+                            height: 150,
+   
+                            emptyText: this.app.i18n._('Enter description')
                         }],
                         [{
                             columnWidth: 0.5,
                             xtype: 'tine.widget.field.AutoCompleteField',
                             recordClass: this.recordClass,
                             fieldLabel: this.app.i18n._('Location'),
-                            name: 'location',
-                            allowBlank: false
-                        }],
-                        [{
+                            name: 'location'
+                            
+                        },
+                        {
                                xtype: 'extuxclearabledatefield',
                             columnWidth: 0.5,
                             fieldLabel: this.app.i18n._('Added'),
-                            name: 'add_time',
+                            name: 'add_time'
+                            
                         }],
                         [{
+                               
+                               xtype:'numberfield',
                             columnWidth: 0.5,
                             fieldLabel: this.app.i18n._('Total number'),
                             name: 'total_number',
-                            allowBlank: false
-                        }],
-                        [{
+                            value: 1,
+                            minValue: 1
+                            
+                        },
+                        {
+                               xtype:'numberfield',
                             columnWidth: 0.5,
                             fieldLabel: this.app.i18n._('Active number'),
                             name: 'active_number',
-                            allowBlank: false
+                            value: 1,
+                            minValue: 0,
+                            
                         }],
                         
                     ] 
                    
-                }, {
+                },
+                {
                     // activities and tags
                     layout: 'accordion',
                     animate: true,
@@ -163,29 +200,6 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
                     
                           
                     items: [
-                            
-                     new Ext.Panel({
-                          // @todo generalise!
-                         title: this.app.i18n._('Description'),
-                         iconCls: 'descriptionIcon',
-                         layout: 'form',
-                         labelAlign: 'top',
-                         border: false,
-                          items: [{
-                               style: 'margin-top: -4px; border 0px;',
-                               labelSeparator: '',
-                               xtype: 'textarea',
-                               name: 'description',
-                               hideLabel: true,
-                               grow: false,
-                               preventScrollbars: false,
-                               anchor: '100% 100%',
-                               emptyText: this.app.i18n._('Enter description'),
-                               requiredGrant: 'editGrant'  
-                          
-                        }]
-                    }),  
-                    
                     new Tine.widgets.activities.ActivitiesPanel({
                         app: 'Inventory',
                         showAddNoteForm: false,
index e656e39..9af6d39 100644 (file)
@@ -100,7 +100,7 @@ Tine.Inventory.InventoryItemGridPanel = Ext.extend(Tine.widgets.grid.GridPanel,
             },{
                 id: 'add_time',
                 header: this.app.i18n._("Added"),
-                width: 50,
+                width: 25,
                 sortable: true,
                 dataIndex: 'add_time', 
                 renderer: Tine.Tinebase.common.dateRenderer
@@ -113,19 +113,19 @@ Tine.Inventory.InventoryItemGridPanel = Ext.extend(Tine.widgets.grid.GridPanel,
             },{
                 id: 'total_number',
                 header: this.app.i18n._("Total number"),
-                width: 50,
+                width: 30,
                 sortable: true,
                 dataIndex: 'total_number'
             },{
                 id: 'active_number',
                 header: this.app.i18n._("Active number"),
-                width: 50,
+                width: 30,
                 sortable: true,
                 dataIndex: 'active_number'
             },{
                 id: 'description',
                 header: this.app.i18n._("Description"),
-                width: 50,
+                width: 80,
                 sortable: true,
                 dataIndex: 'description'
             }
index 7413db1..d76800a 100644 (file)
@@ -23,8 +23,8 @@ Tine.Inventory.Model.InventoryItem = Tine.Tinebase.data.Record.create(Tine.Tineb
     { name: 'location' },
     { name: 'description' },
     { name: 'add_time', type: 'date', dateFormat: Date.patterns.ISO8601Long},
-    { name: 'total_number', type: 'integer'},
-    { name: 'active_number', type: 'integer' },
+    { name: 'total_number', type: 'int'},
+    { name: 'active_number', type: 'int'},
     // TODO add more record fields here
     // tine 2.0 notes + tags
     { name: 'notes'},
@@ -72,8 +72,8 @@ Tine.Inventory.Model.InventoryItem.getFilterModel = function() {
     var app = Tine.Tinebase.appMgr.get('Inventory');
     
     return [
-        {label: _('Quick search'),    field: 'query',       operators: ['contains']},
-        {label: _('Name'),    field: 'name',       operators: ['contains']},
+        {label: app.i18n._('Quick search'),    field: 'query',       operators: ['contains']},
+        {label: app.i18n._('Name'),    field: 'name',       operators: ['contains']},
         {
             label: app.i18n._('Type'),
             field: 'type',
@@ -81,8 +81,8 @@ Tine.Inventory.Model.InventoryItem.getFilterModel = function() {
             app: app, 
             keyfieldName: 'inventoryType'
         },
-        {label: _('ID'),    field: 'inventory_id',       operators: ['contains']},
-        {label: _('Location'),    field: 'location',       operators: ['contains']},
+        {label: app.i18n._('ID'),    field: 'inventory_id',       operators: ['contains']},
+        {label: app.i18n._('Location'),    field: 'location',       operators: ['contains']},
         {label: app.i18n._('Added'),         field: 'add_time', valueType: 'date', pastOnly: true},
         {filtertype: 'tinebase.tag', app: app},
         {filtertype: 'tine.widget.container.filtermodel', app: app, recordClass: Tine.Inventory.Model.InventoryItem},