Bläddra i källkod

Merged in FD3-789 (pull request #1)

Mejora webservice para corregir filtro cliente
Maximiliano Schvindt 6 år sedan
förälder
incheckning
9557443e98

+ 3 - 1
Controller/RESTController.php

@@ -43,7 +43,7 @@ abstract class RESTController extends VoryxController
      * @QueryParam(name="limit", requirements="\d+", default="20", description="How many notes to return.")
      * @QueryParam(name="order_by", nullable=true, array=true, description="Order by fields. Must be an array ie. &order_by[name]=ASC&order_by[description]=DESC")
      * @QueryParam(name="filters", nullable=true, array=true, description="Filter by fields. Must be an array ie. &filters[id]=3")
-     * &filters[qb-criteria] => Utilizará el matching con criteria donde los parámetros filters realizarán "field like %value%".
+     * &filters[qb-criteria] => Utilizar� el matching con criteria donde los par�metros filters realizar�n "field like %value%".
      * &filters[qb-ids] => Require qb-criteria. This option filter by ids separated by ','. ie. &filters[qb-ids]=1,2,8,9.
      */
     public function cgetAction(ParamFetcherInterface $paramFetcher)
@@ -84,12 +84,14 @@ abstract class RESTController extends VoryxController
                             if (is_numeric($value)) {                              
                                 $criteria->orWhere($criteria->expr()->in("$field", (is_array($value) ? $value : [$value])));
                             } else {
+                                $value = urldecode($value);
                                 $criteria->orWhere($criteria->expr()->contains("$field", "$value"));
                             }
                         } else {
                             if (is_numeric($value)) {
                                 $criteria->andWhere($criteria->expr()->in("$field", (is_array($value) ? $value : [$value])));
                             } else {
+                                $value = urldecode($value);
                                 $criteria->andWhere($criteria->expr()->contains("$field", "$value"));
                             }
                         }                    

+ 4 - 3
Form/ChoiceList/Loader/ClientChoiceLoader.php

@@ -167,7 +167,8 @@ class ClientChoiceLoader implements ChoiceLoaderInterface
      */
     public function getChoicesList($filter)
     {
-        $params = array();
+        $limit = 100;
+        
         if ($filter !== false) {
             $params['name'] = urlencode($filter);
             if ($this->filterTenancy) {
@@ -175,11 +176,11 @@ class ClientChoiceLoader implements ChoiceLoaderInterface
             }
         }
 
-        $choices = $this->webservice->getChoices($this->webserviceParameter, $params);
+        $choices = $this->webservice->getChoices($this->webserviceParameter, $params, true, array(), $limit);
 
         $result = [];
         $cnt = 0;
-        $limit = 10;
+        
         $filter = mb_strtolower($filter);
         $filter_len = mb_strlen($filter);
 

+ 4 - 4
Services/Webservice.php

@@ -49,10 +49,10 @@ class Webservice
      *
      * @return array
      */
-    public function getChoices($webservice, $params = array())
+    public function getChoices($webservice, $params = array(), $qbCriteria = false, $order_by = array(), $limit = 20, $offset = null)
     {
         $choices = array();
-        $results = $this->getArray($webservice, $params);
+        $results = $this->getArray($webservice, $params, $qbCriteria, $order_by, $limit, $offset);
         foreach ($results as $row) {
             if (isset($row['name']) && isset($row['id'])) {
                 $choices[$row['name']] = $row['id'];
@@ -70,13 +70,13 @@ class Webservice
      *
      * @return array
      */
-    public function getArray($webservice, $params = array())
+    public function getArray($webservice, $params = array(), $qbCriteria = true, $order_by = array(), $limit = 20, $offset = null)
     {
         $results = array();
         if ($this->serviceContainer->hasParameter($webservice)) {
             try {
                 // Por defecto agrega filters[qb-criteria] y limit=20
-                $url = $this->buildUrl($webservice, $params, true);
+                $url = $this->buildUrl($webservice, $params, $qbCriteria, $order_by, $limit, $offset);
                 $results = json_decode($this->makeGetRequest($url), true);
             } catch (\Exception $ex) {
                 $this->log($ex->getMessage(), 'error');