Also, Yuri's comment is still a great way to apply existing filters, but there is a slight change that needs to be made for it to work:
Code:
{ "relationshipPanels": { "tenancy": { "selectPrimaryFilterName": "active" } } }
{ "relationshipPanels": { "tenancy": { "selectPrimaryFilterName": "active" } } }
{ "relationshipPanels": { "tenancy": { "selectPrimaryFilter": "active" } } }
namespace Espo\Modules\PropertyManagement\Classes\Select\Tenancy\PrimaryFilters;
use Espo\ORM\Query\SelectBuilder;
use Espo\ORM\Query\Part\Condition as Cond;
use Espo\Core\Select\Primary\Filter;
class Active implements Filter
{
public function apply(SelectBuilder $queryBuilder): void
{
$queryBuilder->where(
Cond::equal(
Cond::column('status'),
'Active'
)
);
}
}
{ "primaryFilterClassNameMap": { "active": "Espo\\Modules\\PropertyManagement\\Classes\\Select\\Tenancy\\PrimaryFilters\\Active" } }
{ "defaultFilterData": { "primary": "active" }, }
define('custom:views/fields/primary-filtered-link', ['views/fields/link'], function (Dep) { return Dep.extend({ setup: function() { Dep.prototype.setup.call(this); this.selectPrimaryFilterName = this.getMetadata().get(['clientDefs', this.foreignScope, 'defaultFilterData', 'primary']) || this.selectPrimaryFilterName; } }); });
{ "fields": { "tenancy": { "type": "link", "tooltip": true, "view": "custom:views/fields/primary-filtered-link" } } }
Leave a comment: