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

related objects should be included in the Columns fields #736

Closed
sennierer opened this issue Mar 20, 2024 · 6 comments
Closed

related objects should be included in the Columns fields #736

sennierer opened this issue Mar 20, 2024 · 6 comments
Assignees

Comments

@sennierer
Copy link
Collaborator

currently we only include attributes of the classes in the tables, but we should include FK and M2M fields. These shouldnt be selected by default (because of the additional queries), but should be selectable via the columns field.

related to #735

@vronk
Copy link

vronk commented May 29, 2024

+1 (for Frischmuth)

@b1rger
Copy link
Contributor

b1rger commented May 29, 2024

APIS is very customizable by now, so a column with related objects (with "related" referring to objects connected by the TempTriples) this could be solved using a custom queryset together with a custom table:
Example for the Person entity:

# in `your_ontology.querysets`
# this adds the ids of related objects to the persons listed in a list view
def PersonListViewQueryset(queryset):
    ro_subquery = RootObject.objects.filter(triple_set_from_obj__subj_id=OuterRef("pk")).values("id")
    return queryset.annotate(related=ArraySubquery(ro_subquery))
# in `your_ontology.tables`
# this adds a `related` column that prints the string representation of the related objects
class PersonTable(AbstractEntityTable):
    related = tables.Column(empty_values=[])
    
    def render_related(self, record):
        rel_objs = map(str, RootObject.objects_inheritance.filter(id__in=record.related).select_subclasses())
        return ", ".join(rel_objs)

(this is only a POC, which shows related entities that are triple objects, not the other way around)

@gythaogg gythaogg assigned gythaogg and sennierer and unassigned gythaogg Jun 19, 2024
@gythaogg
Copy link
Contributor

@b1rger Yes, this is fantastic - and I use it.

@sennierer talks about making these custom columns "optional" via the columns field

These shouldnt be selected by default (because of the additional queries), but should be selectable via the columns field.

At the moment only "fields" of the model are available in the columns dropdown; and the columns we define in tables appear in the view but they cannot be turned off or optionally added by selecting ín the columns field

@b1rger b1rger added the needs-attention This issue or pull request is in need of discussion, information, assessment by team members label Aug 29, 2024
@b1rger
Copy link
Contributor

b1rger commented Aug 29, 2024

Adding to the agenda, because we might close this. It is possible to implement this in projects

@sennierer
Copy link
Collaborator Author

we make this the default behaviour with the new class based relations.
we experiment with having two dropdowns, one for attributes, one for related objects

@sennierer sennierer removed the needs-attention This issue or pull request is in need of discussion, information, assessment by team members label Sep 5, 2024
@sennierer
Copy link
Collaborator Author

idea was to easily allow for using annotated fields in tables. there is an issue on custom table fields (#1030)

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

No branches or pull requests

4 participants