Merge branch '2014.11-develop' into 2014.09
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 8 Apr 2015 16:43:45 +0000 (18:43 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 8 Apr 2015 16:43:45 +0000 (18:43 +0200)
tests/tine20/Addressbook/Import/CsvTest.php
tine20/Crm/js/LeadEditDialog.js
tine20/Tinebase/Controller/Record/Abstract.php
tine20/Tinebase/js/common.js
tine20/Tinebase/js/widgets/dialog/DuplicateResolveGridPanel.js
tine20/Tinebase/js/widgets/grid/RendererManager.js

index 5e8b626..aaad147 100644 (file)
@@ -347,7 +347,8 @@ class Addressbook_Import_CsvTest extends ImportTestCase
         $this->assertEquals('Straßbough', $result['results'][1]['adr_one_locality'],
                 'should have changed the locality of contact #2: ' . print_r($result['results'][1]->toArray(), true));
         $this->assertEquals('Dr. Schutheiss', $result['results'][3]['n_family']);
-        $this->assertEquals(1, $result['results'][2]['seq'], 'Wolfer should not be updated - nothing changed');
+        // TODO this should be researched, imho the relation should not trigger an update of the record
+        $this->assertEquals(1, $result['results'][3]['seq'], 'Wolfer has been updated - relations changed');
         $this->assertEquals('Weixdorf DD', $result['results'][0]['adr_one_locality'], 'locality should persist');
         $this->assertEquals('Gartencenter Röhr & Vater', $result['results'][4]['n_fileas']);
         $this->assertEquals('Straßback', $result['results'][5]['adr_one_locality']);
index 887fdc9..22e736c 100644 (file)
@@ -195,9 +195,9 @@ Tine.Crm.LeadEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
             } else if (newLinkObject.relation_type === 'task') {
                 tasks.push(newLinkObject);
             } else if (newLinkObject.relation_type === 'product') {
-                newLinkObject.remark_description = relations[i].remark.description;
-                newLinkObject.remark_price = relations[i].remark.price;
-                newLinkObject.remark_quantity = relations[i].remark.quantity;
+                newLinkObject.remark_description = (relations[i].remark) ? relations[i].remark.description : '';
+                newLinkObject.remark_price = (relations[i].remark) ? relations[i].remark.price : 0;
+                newLinkObject.remark_quantity = (relations[i].remark) ? relations[i].remark.quantity : 1;
                 products.push(newLinkObject);
             }
         }
index 456f397..b41e297 100644 (file)
@@ -209,9 +209,9 @@ abstract class Tinebase_Controller_Record_Abstract
             . ' Got ' . count($result) . ' search results');
         
         if (! $_onlyIds) {
-            if ($_getRelations) {
+            if ($_getRelations && count($result) > 0 && $result->getFirstRecord()->has('relations')) {
                 // if getRelations is true, all relations should be fetched
-                if ($_getRelations === TRUE) {
+                if ($_getRelations === true) {
                     $_getRelations = NULL;
                 }
                 $result->setByIndices('relations', Tinebase_Relations::getInstance()->getMultipleRelations($this->_modelName, $this->_getBackendType(), $result->getId(), NULL, array(), FALSE, $_getRelations));
@@ -661,7 +661,7 @@ abstract class Tinebase_Controller_Record_Abstract
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .
             ' Doing duplicate check.');
 
-        $duplicates = $this->search($duplicateFilter, new Tinebase_Model_Pagination(array('limit' => 5)));
+        $duplicates = $this->search($duplicateFilter, new Tinebase_Model_Pagination(array('limit' => 5)), /* $_getRelations = */ true);
 
         if (count($duplicates) > 0) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .
index 34b30ad..e860b9d 100644 (file)
@@ -404,7 +404,28 @@ Tine.Tinebase.common = {
         
         return result;
     },
-    
+
+    /**
+     * Returns rendered relations
+     *
+     * @param {mixed} container
+     * @return {String}
+     *
+     * TODO use/invent renderer registry to show more information on relations
+     */
+    relationsRenderer: function(relations, metaData) {
+        var result = '';
+        if (relations) {
+            for (var i = 0; i < relations.length; i += 1) {
+                if (relations[i]) {
+                    var qtipText = Tine.Tinebase.common.doubleEncode(relations[i].type);
+                    result += '<div ext:qtip="' + qtipText + '" class="tb-grid-tags" style="background-color:white"' + ';">&#160;</div>';
+                }
+            }
+        }
+        return result;
+    },
+
     /**
      * Returns prettyfied minutes
      * 
index bb236a0..8ba70a7 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @author      Cornelius Weiss <c.weiss@metaways.de>
- * @copyright   Copyright (c) 2007-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2007-2015 Metaways Infosystems GmbH (http://www.metaways.de)
  */
 Ext.ns('Tine.widgets.dialog');
 
@@ -133,7 +133,23 @@ Tine.widgets.dialog.DuplicateResolveGridPanel = Ext.extend(Ext.grid.EditorGridPa
             resolveRecord = this.store.getAt(rowIndex);
 
         if (resolveRecord && dataIndex && dataIndex.match(/clientValue|value\d+/)) {
-            resolveRecord.set('finalValue', resolveRecord.get(dataIndex));
+            if (e.shiftKey && Ext.isString(resolveRecord.get(dataIndex))) {
+                // combine string values if shift is pressed
+                var record = this.store.getAt(rowIndex),
+                    combined = record.get('clientValue') + ' / ' + record.get('value0'),
+                    colToSelect = (colIndex == 2) ? 3 : 2,
+                    otherCellEl = this.getView().getCell(rowIndex, colToSelect);
+
+                if (otherCellEl) {
+                    // TODO it would be nicer if this worked ...
+                    //Ext.fly(otherCellEl).addClass('x-grid3-cell-selected');
+                    Ext.fly(otherCellEl).highlight();
+                }
+
+                resolveRecord.set('finalValue', combined);
+            } else {
+                resolveRecord.set('finalValue', resolveRecord.get(dataIndex));
+            }
 
             var celEl = this.getView().getCell(rowIndex, this.getColumnModel().getIndexById('finalValue'));
             if (celEl) {
@@ -370,7 +386,7 @@ Tine.widgets.dialog.DuplicateResolveStore = Ext.extend(Ext.data.GroupingStore, {
             });
         }
 
-        // forece dublicate 0 atm.
+        // forece duplicate 0 atm.
         this.duplicateIdx = 0;
 
         if (initialData) {
index b52ae16..25dea09 100644 (file)
@@ -53,8 +53,7 @@ Tine.widgets.grid.RendererManager = function() {
                 // @TODO
                 renderer = function(value) {return value ? _('has notes') : '';};
             } else if (fieldName == 'relations') {
-                // @TODO
-                renderer = function(value) {return value ? _('has relations') : '';};
+                renderer = Tine.Tinebase.common.relationsRenderer;
             } else if (fieldName == 'customfields') {
                 // @TODO
                 // we should not come here!