瀏覽代碼

Optimisation : select2 ajax

develop
Guillaume Bourgeois 6 月之前
父節點
當前提交
db89434ee0
共有 4 個檔案被更改,包括 23 行新增0 行删除
  1. +5
    -0
      Controller/ControllerTrait.php
  2. +7
    -0
      Repository/User/UserRepositoryQuery.php
  3. +6
    -0
      Repository/User/UserStore.php
  4. +5
    -0
      Resources/assets/functions/widgets.js

+ 5
- 0
Controller/ControllerTrait.php 查看文件

return $this->get(AdminUrlGenerator::class); return $this->get(AdminUrlGenerator::class);
} }


public function getUrlGenerator(): UrlGeneratorInterface
{
return $this->get(UrlGeneratorInterface::class);
}

public function getKernel(): KernelInterface public function getKernel(): KernelInterface
{ {
return $this->get(KernelInterface::class); return $this->get(KernelInterface::class);

+ 7
- 0
Repository/User/UserRepositoryQuery.php 查看文件

->setParameter('email', $email); ->setParameter('email', $email);
} }


public function filterByTerm(string $term): self
{
return $this
->andWhere('.email LIKE :term OR .firstname LIKE :term OR .lastname LIKE :term')
->setParameter('term', '%'.$term.'%');
}

} }

+ 6
- 0
Repository/User/UserStore.php 查看文件

return $query->findOne(); return $query->findOne();
} }


public function getByTerm(string $term, $query = null)
{
$query = $this->createQuery($query);
$query->filterByTerm($term);
return $query->find();
}
} }

+ 5
- 0
Resources/assets/functions/widgets.js 查看文件

minimumResultsForSearch: 8 minimumResultsForSearch: 8
}; };


if ($select.data('ajax')) {
options.ajax = $select.data('ajax');
options.minimumInputLength = 3;
}

if ($select.data('allow-clear') == 'false') { if ($select.data('allow-clear') == 'false') {
options.allowClear = false; options.allowClear = false;
} }

Loading…
取消
儲存