Followed bool filter
This commit is contained in:
@@ -44,13 +44,13 @@ class SelectManagerFactory
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
|
||||
public function create($entityName)
|
||||
public function create($entityType)
|
||||
{
|
||||
$normalizedName = Util::normilizeClassName($entityName);
|
||||
$normalizedName = Util::normilizeClassName($entityType);
|
||||
|
||||
$className = '\\Espo\\Custom\\SelectManagers\\' . $normalizedName;
|
||||
if (!class_exists($className)) {
|
||||
$moduleName = $this->metadata->getScopeModuleName($entityName);
|
||||
$moduleName = $this->metadata->getScopeModuleName($entityType);
|
||||
if ($moduleName) {
|
||||
$className = '\\Espo\\Modules\\' . $moduleName . '\\SelectManagers\\' . $normalizedName;
|
||||
} else {
|
||||
@@ -62,7 +62,7 @@ class SelectManagerFactory
|
||||
}
|
||||
|
||||
$selectManager = new $className($this->entityManager, $this->user, $this->acl, $this->metadata);
|
||||
$selectManager->setEntityName($entityName);
|
||||
$selectManager->setEntityType($entityType);
|
||||
|
||||
return $selectManager;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class Base
|
||||
|
||||
protected $entityManager;
|
||||
|
||||
protected $entityName;
|
||||
protected $entityType;
|
||||
|
||||
protected $metadata;
|
||||
|
||||
@@ -65,9 +65,14 @@ class Base
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setEntityName($entityName)
|
||||
public function setEntityType($entityType)
|
||||
{
|
||||
$this->entityName = $entityName;
|
||||
$this->entityType = $entityType;
|
||||
}
|
||||
|
||||
protected function getEntityType()
|
||||
{
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
protected function limit($params, &$result)
|
||||
@@ -84,7 +89,7 @@ class Base
|
||||
{
|
||||
if (!empty($params['sortBy'])) {
|
||||
$result['orderBy'] = $params['sortBy'];
|
||||
$type = $this->metadata->get("entityDefs.{$this->entityName}.fields." . $result['orderBy'] . ".type");
|
||||
$type = $this->metadata->get("entityDefs.{$this->entityType}.fields." . $result['orderBy'] . ".type");
|
||||
if ($type == 'link') {
|
||||
$result['orderBy'] .= 'Name';
|
||||
} else if ($type == 'linkParent') {
|
||||
@@ -102,13 +107,13 @@ class Base
|
||||
|
||||
protected function getTextFilterFields()
|
||||
{
|
||||
return $this->metadata->get("entityDefs.{$this->entityName}.collection.textFilterFields", array('name'));
|
||||
return $this->metadata->get("entityDefs.{$this->entityType}.collection.textFilterFields", array('name'));
|
||||
}
|
||||
|
||||
protected function getSeed()
|
||||
{
|
||||
if (empty($this->seed)) {
|
||||
$this->seed = $this->entityManager->getEntity($this->entityName);
|
||||
$this->seed = $this->entityManager->getEntity($this->entityType);
|
||||
}
|
||||
return $this->seed;
|
||||
}
|
||||
@@ -311,10 +316,10 @@ class Base
|
||||
|
||||
protected function access(&$result)
|
||||
{
|
||||
if ($this->acl->checkReadOnlyOwn($this->entityName)) {
|
||||
if ($this->acl->checkReadOnlyOwn($this->entityType)) {
|
||||
$this->accessOnlyOwn($result);
|
||||
}
|
||||
if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityName)) {
|
||||
if (!$this->user->isAdmin() && $this->acl->checkReadOnlyTeam($this->entityType)) {
|
||||
$this->accessOnlyTeam($result);
|
||||
}
|
||||
}
|
||||
@@ -659,5 +664,16 @@ class Base
|
||||
'assignedUserId' => $this->getUser()->id
|
||||
);
|
||||
}
|
||||
|
||||
protected function boolFilterFollowed(&$result)
|
||||
{
|
||||
$query = $this->getEntityManager()->getQuery();
|
||||
$result['customJoin'] .= "
|
||||
JOIN subscription ON
|
||||
subscription.entity_type = ".$query->quote($this->getEntityType())." AND
|
||||
subscription.entity_id = ".$query->toDb($this->getEntityType()).".id AND
|
||||
subscription.user_id = ".$query->toDb($this->getUser()->id)."
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -426,6 +426,11 @@ abstract class Base
|
||||
return $selectPart;
|
||||
}
|
||||
|
||||
public function quote($value)
|
||||
{
|
||||
return $this->pdo->quote($value);
|
||||
}
|
||||
|
||||
public function toDb($field)
|
||||
{
|
||||
if (array_key_exists($field, $this->fieldsMapCache)) {
|
||||
|
||||
@@ -189,7 +189,8 @@
|
||||
"streamPostInfo": "Type <strong>@username</strong> to mention users in the post.\n\nAvailable markdown syntax:\n`<code>code</code>`\n**<strong>strong text</strong>**\n*<em>emphasized text</em>*\n~<del>deleted text</del>~\n> blockquote\n(url)[link]"
|
||||
},
|
||||
"boolFilters": {
|
||||
"onlyMy": "Only My"
|
||||
"onlyMy": "Only My",
|
||||
"followed": "Followed"
|
||||
},
|
||||
"massActions": {
|
||||
"remove": "Remove",
|
||||
|
||||
@@ -71,6 +71,10 @@ Espo.define('Views.Record.Search', 'View', function (Dep) {
|
||||
|
||||
this.boolFilterList = Espo.Utils.clone(this.getMetadata().get('clientDefs.' + this.scope + '.boolFilterList') || []);
|
||||
|
||||
if (this.getMetadata().get('scopes.' + this.scope + '.stream')) {
|
||||
this.boolFilterList.push('followed');
|
||||
}
|
||||
|
||||
this._helper.layoutManager.get(this.scope, 'filters', function (list) {
|
||||
this.moreFields = list;
|
||||
this.tryReady();
|
||||
|
||||
Reference in New Issue
Block a user