change GridPanel
authorStefanie Stamer <s.stamer@metaways.de>
Wed, 7 Sep 2011 15:04:57 +0000 (17:04 +0200)
committerMichael Spahn <m.spahn@metaways.de>
Thu, 4 Oct 2012 13:54:54 +0000 (15:54 +0200)
tine20/Inventory/Config.php
tine20/Inventory/Frontend/Json.php
tine20/Inventory/Model/InventoryItem.php
tine20/Inventory/Model/InventoryItemFilter.php
tine20/Inventory/Setup/Initialize.php
tine20/Inventory/Setup/setup.xml
tine20/Inventory/js/InventoryItemEditDialog.js
tine20/Inventory/js/InventoryItemGridPanel.js
tine20/Inventory/js/Model.js

index 6f4a823..22390ad 100644 (file)
@@ -20,14 +20,14 @@ class Inventory_Config extends Tinebase_Config_Abstract
      * 
      * @var string
      */
-    const INVENTORY_STATUS = 'inventoryStatus';
+    const INVENTORY_TYPE = 'inventoryType';
     
     /**
      * (non-PHPdoc)
      * @see tine20/Tinebase/Config/Definition::$_properties
      */
     protected static $_properties = array(
-        self::INVENTORY_STATUS => array(
+        self::INVENTORY_TYPE => array(
                                    //_('Status Available')
             'label'                 => 'Status Available',
                                    //_('Possible status. Please note that additional status might impact other Inventory systems on export or syncronisation.')
@@ -35,7 +35,7 @@ class Inventory_Config extends Tinebase_Config_Abstract
             'type'                  => 'keyFieldConfig',
             'options'               => array('recordModel' => 'Inventory_Model_Status'),
             'clientRegistryInclude' => TRUE,
-            'default'               => 'IN-PROCESS'
+            'default'               => 'UNKNOWN'
         ),
     );
     
index 5c73e02..0191ae9 100644 (file)
@@ -88,6 +88,43 @@ class Inventory_Frontend_Json extends Tinebase_Frontend_Json_Abstract
     {
         return $this->_delete($ids, $this->_controller);
     }    
+    
+    /**
+     * return autocomplete suggestions for a given property and value
+     * 
+     * @todo have spechial controller/backend fns for this
+     * @todo move to abstract json class and have tests
+     *
+     * @param  string   $property
+     * @param  string   $startswith
+     * @return array
+     */
+    public function autoCompleteInventoryProperty($property, $startswith)
+    {
+        if (preg_match('/[^A-Za-z0-9_]/', $property)) {
+            // NOTE: it would be better to ask the model for property presece, but we can't atm.
+            throw new Tasks_Exception_UnexpectedValue('bad property name');
+        }
+        
+        $filter = new Inventory_Model_InventoryItemFilter(array(
+            array('field' => $property, 'operator' => 'startswith', 'value' => $startswith),
+        ));
+        
+        $paging = new Tinebase_Model_Pagination(array('sort' => $property));
+        
+        $values = array_unique(Inventory_Controller_InventoryItem::getInstance()->search($filter, $paging)->{$property});
+        
+        $result = array(
+            'results'   => array(),
+            'totalcount' => count($values)
+        );
+        
+        foreach($values as $value) {
+            $result['results'][] = array($property => $value);
+        }
+        
+        return $result;
+    }
 
     /**
      * Returns registry data
index ba306fd..3e98911 100644 (file)
@@ -43,9 +43,15 @@ class Inventory_Model_InventoryItem extends Tinebase_Record_Abstract
     protected $_validators = array(
         'id'                    => array(Zend_Filter_Input::ALLOW_EMPTY => true),
         'name'                  => array(Zend_Filter_Input::ALLOW_EMPTY => true),
-        'status'                => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+        'type'                 => array(Zend_Filter_Input::ALLOW_EMPTY => true),
         'container_id'          => array(Zend_Filter_Input::ALLOW_EMPTY => false, 'presence'=>'required'),
     // @todo add more fields
+        'inventory_id'          => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+        'description'           => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+        'location'              => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+        'add_time'              => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+        'total_number'          => array(Zend_Filter_Input::ALLOW_EMPTY => true),
+        'active_number'         => array(Zend_Filter_Input::ALLOW_EMPTY => true),
     // modlog information
         'created_by'            => array(Zend_Filter_Input::ALLOW_EMPTY => true),
         'creation_time'         => array(Zend_Filter_Input::ALLOW_EMPTY => true),
@@ -68,7 +74,8 @@ class Inventory_Model_InventoryItem extends Tinebase_Record_Abstract
     protected $_datetimeFields = array(
         'creation_time',
         'last_modified_time',
-        'deleted_time'
+        'deleted_time',
+        'add_time'
     );
     
     /**
index 7f3f4c9..97aca32 100644 (file)
@@ -35,7 +35,7 @@ class Inventory_Model_InventoryItemFilter extends Tinebase_Model_Filter_FilterGr
         'query'          => array('filter' => 'Tinebase_Model_Filter_Query', 'options' => array('fields' => array('name', /*'...'*/))),
         'container_id'   => array('filter' => 'Tinebase_Model_Filter_Container', 'options' => array('applicationName' => 'Inventory')),
         'id'             => array('filter' => 'Tinebase_Model_Filter_Id'),
-        'status'         => array('filter' => 'Tinebase_Model_Filter_Text'),
+        'type'           => array('filter' => 'Tinebase_Model_Filter_Text'),
         'tag'            => array('filter' => 'Tinebase_Model_Filter_Tag', 'options' => array('idProperty' => 'inventory_item.id')),
     
         // modlog filters
@@ -46,10 +46,17 @@ class Inventory_Model_InventoryItemFilter extends Tinebase_Model_Filter_FilterGr
         'created_by'           => array('filter' => 'Tinebase_Model_Filter_User'),
     
         // @todo add filters
+        'name'           => array('filter' => 'Tinebase_Model_Filter_Text'),
+        'inventory_id'   => array('filter' => 'Tinebase_Model_Filter_Text'),
+        'description'    => array('filter' => 'Tinebase_Model_Filter_Text'),
+       'location'       => array('filter' => 'Tinebase_Model_Filter_Text'),
+        'add_time'       => array('filter' => 'Tinebase_Model_Filter_Date'),
+        'total_number'   => array('filter' => 'Tinebase_Model_Filter_Text'),
+        'active_number'  => array('filter' => 'Tinebase_Model_Filter_Text'),
         /*
         'title'          => array('filter' => 'Tinebase_Model_Filter_Text'),
         'number'         => array('filter' => 'Tinebase_Model_Filter_Text'),
-        'description'    => array('filter' => 'Tinebase_Model_Filter_Text'),
+        
         */
     );
 }
index 95a757e..8a760f0 100644 (file)
@@ -27,19 +27,21 @@ class Inventory_Setup_Initialize extends Setup_Initialize
             'tableName' => 'config',
         ));
         
-        $statusConfig = array(
-            'name'    => Inventory_Config::INVENTORY_STATUS,
+        $typeConfig = array(
+            'name'    => Inventory_Config::INVENTORY_TYPE,
             'records' => array(
-                array('id' => 'COMPLETED',    'value' => 'Completed',   'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/ok.png',                   'system' => true), //_('Completed')
-                array('id' => 'CANCELLED',    'value' => 'Cancelled',   'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png',        'system' => true), //_('Cancelled')
-                array('id' => 'IN-PROCESS',   'value' => 'In process',  'is_open' => 1, 'icon' => 'images/oxygen/16x16/actions/view-refresh.png',         'system' => true), //_('In process')
+                array('id' => 'BOOK',    'value' => 'book',   'is_open' => 0, /*'icon' => 'images/oxygen/16x16/actions/ok.png',   */               'system' => true), //_('Completed')
+                array('id' => 'SERVER',    'value' => 'server',   'is_open' => 0, /*'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png',  */      'system' => true), //_('Cancelled')
+                array('id' => 'MONITOR',    'value' => 'monitor',   'is_open' => 0, /*'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png',  */      'system' => true),
+                array('id' => 'KEYBOARD',    'value' => 'keyboard',   'is_open' => 0, /*'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png',  */      'system' => true),
+                array('id' => 'UNKNOWN',   'value' => 'unknown',  'is_open' => 1, /*'icon' => 'images/oxygen/16x16/actions/view-refresh.png',   */      'system' => true), //_('In process')
             ),
         );
         
         $cb->create(new Tinebase_Model_Config(array(
             'application_id'    => Tinebase_Application::getInstance()->getApplicationByName('Inventory')->getId(),
-            'name'              => Inventory_Config::INVENTORY_STATUS,
-            'value'             => json_encode($statusConfig),
+            'name'              => Inventory_Config::INVENTORY_TYPE,
+            'value'             => json_encode($typeConfig),
         )));
     }    
 }
index 9b138ba..a40584f 100644 (file)
                 </field>
                 <!-- keyfield 'status' -->
                 <field>
-                    <name>status</name>
+                    <name>type</name>
                     <type>text</type>
                     <length>40</length>
-                    <default>IN-PROCESS</default>
+                    <default>UNKNOWN</default>
                     <notnull>true</notnull>
                 </field>
                 <!-- add more fields here -->
+                <field>
+                    <name>inventory_id</name>
+                    <type>text</type>
+                    <length>255</length>
+                    <notnull>true</notnull>
+                </field>
+                <field>
+                    <name>description</name>
+                    <type>text</type>
+                    <length>255</length>
+                    <notnull>true</notnull>
+                </field>
+                <field>
+                    <name>location</name>
+                    <type>text</type>
+                    <length>255</length>
+                    <notnull>true</notnull>
+                </field>
+                <field>
+                    <name>add_time</name>
+                    <type>datetime</type>
+                    <notnull>true</notnull>
+                </field>
+                <field>
+                    <name>total_number</name>
+                    <type>integer</type>
+                    <notnull>true</notnull>
+                </field>
+                <field>
+                    <name>active_number</name>
+                    <type>integer</type>
+                    <notnull>true</notnull>
+                </field>
+              
                 <!-- defaults for tine system -->
                 <field>
                     <name>created_by</name>
                         <name>container_id</name>
                     </field>
                 </index>
             </declaration>
         </table>
     </tables>
index 61c038b..fbae5c7 100644 (file)
@@ -84,13 +84,13 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
             activeTab: 0,
             border: false,
             items:[{               
-                title: this.app.i18n._('InventoryItem'),
+                title: this.app.i18n._('Inventory Item'),
                 autoScroll: true,
                 border: false,
                 frame: true,
                 layout: 'border',
                 items: [{
-                    region: 'center',
+                       region: 'center',
                     xtype: 'columnform',
                     labelAlign: 'top',
                     formDefaults: {
@@ -106,12 +106,44 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
                         allowBlank: false
                         }], [new Tine.Tinebase.widgets.keyfield.ComboBox({
                             app: 'Inventory',
-                            keyFieldName: 'inventoryStatus',
-                            fieldLabel: this.app.i18n._('Status'),
-                            name: 'status',
+                            keyFieldName: 'inventoryType',
+                            fieldLabel: this.app.i18n._('Type'),
+                            name: 'type',
                             columnWidth: 0.5
-                        })]
+                        })],
+                        [{
+                            columnWidth: 0.5,
+                            fieldLabel: this.app.i18n._('ID'),
+                            name: 'inventory_id',
+                            allowBlank: false
+                        }],
+                        [{
+                            columnWidth: 0.5,
+                            fieldLabel: this.app.i18n._('Location'),
+                            name: 'location',
+                            allowBlank: false
+                        }],
+                        [{
+                               xtype: 'extuxclearabledatefield',
+                            columnWidth: 0.5,
+                            fieldLabel: this.app.i18n._('Added'),
+                            name: 'add_time',
+                        }],
+                        [{
+                            columnWidth: 0.5,
+                            fieldLabel: this.app.i18n._('Total number'),
+                            name: 'total_number',
+                            allowBlank: false
+                        }],
+                        [{
+                            columnWidth: 0.5,
+                            fieldLabel: this.app.i18n._('Active number'),
+                            name: 'active_number',
+                            allowBlank: false
+                        }],
+                        
                     ] 
+                   
                 }, {
                     // activities and tags
                     layout: 'accordion',
@@ -124,19 +156,47 @@ Tine.Inventory.InventoryItemEditDialog = Ext.extend(Tine.widgets.dialog.EditDial
                     header: false,
                     margins: '0 5 0 5',
                     border: true,
+                    
+                          
                     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,
                         border: false,
                         bodyStyle: 'border:1px solid #B5B8C8;'
                     }),
+                    
                     new Tine.widgets.tags.TagPanel({
                         app: 'Inventory',
                         border: false,
                         bodyStyle: 'border:1px solid #B5B8C8;'
                     })]
                 }]
+                
+                
             }, new Tine.widgets.activities.ActivitiesTabPanel({
                 app: this.appName,
                 record_id: this.record.id,
index cf5eac0..cfa35cb 100644 (file)
@@ -45,7 +45,7 @@ Tine.Inventory.InventoryItemGridPanel = Ext.extend(Tine.widgets.grid.GridPanel,
      */
     defaultSortInfo: {field: 'creation_time', direction: 'DESC'},
     gridConfig: {
-        autoExpandColumn: 'name'
+        autoExpandColumn: 'inventory_id'
     },
      
     /**
@@ -79,19 +79,61 @@ Tine.Inventory.InventoryItemGridPanel = Ext.extend(Tine.widgets.grid.GridPanel,
                 resizable: true
             },
             columns: [{
+                id: 'inventory_id',
+                header: this.app.i18n._("ID"),
+                width: 50,
+                sortable: true,
+                dataIndex: 'inventory_id'
+            }, {
                 id: 'name',
                 header: this.app.i18n._("Name"),
-                width: 100,
+                width: 50,
                 sortable: true,
                 dataIndex: 'name'
             }, {
-                id: 'status',
-                header: this.app.i18n._("Status"),
-                width: 150,
+                id: 'type',
+                header: this.app.i18n._("Type"),
+                width: 50,
+                sortable: true,
+                dataIndex: 'type',
+                renderer: Tine.Tinebase.widgets.keyfield.Renderer.get('Inventory', 'inventoryType')
+            },{
+                id: 'add_time',
+                header: this.app.i18n._("Added"),
+                width: 50,
+                sortable: true,
+                dataIndex: 'add_time'
+            },{
+                id: 'location',
+                header: this.app.i18n._("Location"),
+                width: 50,
+                sortable: true,
+                dataIndex: 'location'
+            },{
+                id: 'total_number',
+                header: this.app.i18n._("Total number"),
+                width: 50,
+                sortable: true,
+                dataIndex: 'total_number'
+            },{
+                id: 'active_number',
+                header: this.app.i18n._("Active number"),
+                width: 50,
+                sortable: true,
+                dataIndex: 'active_number'
+            },{
+                id: 'description',
+                header: this.app.i18n._("Description"),
+                width: 50,
                 sortable: true,
-                dataIndex: 'status',
-                renderer: Tine.Tinebase.widgets.keyfield.Renderer.get('Inventory', 'inventoryStatus')
-            }/*,{
+                dataIndex: 'description'
+            }
+            
+            
+            
+            
+            
+            /*,{
                 id: 'title',
                 header: this.app.i18n._("Title"),
                 width: 350,
index 96e8cea..c70384f 100644 (file)
@@ -18,7 +18,13 @@ Ext.ns('Tine.Inventory.Model');
 Tine.Inventory.Model.InventoryItem = Tine.Tinebase.data.Record.create(Tine.Tinebase.Model.genericFields.concat([
     { name: 'id' },
     { name: 'name' },
-    { name: 'status' },
+    { name: 'type' },
+    { name: 'inventory_id' },
+    { name: 'location' },
+    { name: 'description' },
+    { name: 'add_time' },
+    { name: 'total_number' },
+    { name: 'active_number' },
     // TODO add more record fields here
     // tine 2.0 notes + tags
     { name: 'notes'},
@@ -68,11 +74,11 @@ Tine.Inventory.Model.InventoryItem.getFilterModel = function() {
     return [
         {label: _('Quick search'),    field: 'query',       operators: ['contains']},
         {
-            label: app.i18n._('Status'),
-            field: 'status',
+            label: app.i18n._('Type'),
+            field: 'type',
             filtertype: 'tine.widget.keyfield.filter', 
             app: app, 
-            keyfieldName: 'inventoryStatus'
+            keyfieldName: 'inventoryType'
         },
         {filtertype: 'tinebase.tag', app: app},
         {filtertype: 'tine.widget.container.filtermodel', app: app, recordClass: Tine.Inventory.Model.InventoryItem},