Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Relation Filter Type to Custom Reports #16618

Open
wants to merge 9 commits into
base: 11.x
Choose a base branch
from

Conversation

gjorgic
Copy link
Contributor

@gjorgic gjorgic commented Feb 16, 2024

Changes in this pull request

Introduce new feature to Custom Reports

Additional info

user will be able some column mark as relation (document, asset or object) and will have ability to filter on same way he can on object grid depending on relation type;
When column is marked as relation, data for that column will be resolved by id and element path will be shown

image

Future improvement can have some CustomReportShownInGrid interface for object attribute which will display formatted name

Copy link

Review Checklist

  • Target branch (11.1 for bug fixes, others 11.x)
  • Tests (if it's testable code, there should be a test for it - get help)
  • Docs (every functionality needs to be documented, see here)
  • Migration incl. install.sql (e.g. if the database schema changes, ...)
  • Upgrade notes (deprecations, important information, migration hints, ...)
  • Label
  • Milestone

@fashxp
Copy link
Member

fashxp commented Feb 19, 2024

@gjorgic thx very much. could you please have a look at phpstan?

@gjorgic
Copy link
Contributor Author

gjorgic commented Feb 22, 2024

I found one issue with opening filter when column is not visible; i will fix today

Copy link

sonarcloud bot commented Feb 22, 2024

Quality Gate Passed Quality Gate passed

Issues
38 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@gjorgic
Copy link
Contributor Author

gjorgic commented Feb 22, 2024

now is ready 🎉

}

return ['data' => $data, 'total' => $total];
}

protected function loadRelationData(array &$data): void
{
$columnsDictionary = $this->getRelationColumns();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is empty, we could skip the whole function, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gjorgic 🏓

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, can you check now

Copy link

github-actions bot commented Apr 15, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

Copy link

sonarcloud bot commented Apr 15, 2024

Quality Gate Passed Quality Gate passed

Issues
45 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@gjorgic gjorgic requested a review from fashxp April 15, 2024 10:58
@gjorgic
Copy link
Contributor Author

gjorgic commented Apr 15, 2024

I have read the CLA Document and I hereby sign the CLA

@fashxp fashxp added this to the 11.3.0 milestone Apr 19, 2024
@fashxp fashxp self-assigned this Apr 19, 2024
Copy link
Member

@fashxp fashxp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx very much for the contribution.
sadly, there are some things which do not work yet, especially with the many-to-many filters.

when setting up a many-to-many object relation filter, I get following error message while opening the report (same for many-to-many asset relation):

URL: /admin/bundle/customreports/custom-report/data?xaction=read&_dc=1713528851388
Method: POST
Message: Pimcore\Bundle\CustomReportsBundle\Tool\Adapter\Sql::loadElementById(): Argument #1 ($id) must be of type int, string given, called in /var/www/html/dev/pimcore/pimcore/bundles/CustomReportsBundle/src/Tool/Adapter/Sql.php on line 92
Trace: 
in /var/www/html/dev/pimcore/pimcore/bundles/CustomReportsBundle/src/Tool/Adapter/Sql.php:127

also I'm not sure, if the many-to-many filters work at all. at least in my tests, they didn't filter correctly.

having a look at the implementation, I'm not too sure if that can work at all?!?

when opening the many-to-many object relation modal, the field name says undefined:
image

maybe it would make sense to limit that filter feature for many-to-one fields for now?

gridColConfig["filter"] = colConfig["filter"];
this.gridfilters[colConfig["name"]] = colConfig["filter"];
} else {
var relationFilterKey = colConfig["filter"].match(this.RELATION_FILTER_REGEX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use const or let where possible for new things...

*
* @return string
*/
public function getHumanReadableElementName(): string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add some documentation about that feature and how to use it, see also https://pimcore.com/docs/platform/Pimcore/Tools_and_Features/Custom_Reports/

@fashxp fashxp removed this from the 11.3.0 milestone Apr 19, 2024
@fashxp
Copy link
Member

fashxp commented May 2, 2024

@gjorgic did you already had a chance to have a look at my comments? Thx very much!

@gjorgic
Copy link
Contributor Author

gjorgic commented May 2, 2024

Hi @fashxp yes, i go through comment, but i Will not be able make update untill end of next week.

Regarding many to many relation, is there chance that issue is related to custom sql query and casting columns to int? If that cause issue do you have any preference how it should be handeled?

Regarding JS i want keep writing style as is, but ofc, i Can change var to let

@fashxp
Copy link
Member

fashxp commented May 2, 2024

@gjorgic thx for you reply, no rush!

Regarding many-to-many: the thing is, that many-to-many is stored as csv in the query table, e.g. ,34,54,23, ... so you can't apply an IN condition to it, right? Or do I miss something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants