Add popup button in generated Column which displays list of multiple attributes of an entity

Hi,
I have 2 Entities, Auditor and AuditAssignment. AuditAssignment has Many to One association with Auditor.

I have a table created for assigning Auditors(First & Last Name). 

I would like to generate a column with the list of AuditAssignments for each Auditor. The AuditAssignments needs to be a list which contains (Audit, Start and End Date) property from AuditAssignment Entity.

So the generated column will have a popupbutton for each row (Auditor). When the Popup button is clicked, AuditAssignment(Audit, Start - End date " For Example: Id 7, 18.09.2017 - 19.09.2017) list for each auditor should be displayed. An auditor can have multiple assignments. By clicking on each assignment, current audit edit screen for that particular Auditor will open as a new window.

Your inputs will be helpful. Thanks.

Regards,
Lokesh

P.S : I am attaching screenshot for better understanding.

Task_ Setup Team

Hello,

You can use the PopupView component.

To generate the desired column you should do something like this:

auditorsTable.addGeneratedColumn("assignments", auditor -> {
    // show a simple label if auditor has no assignments
    if (auditor.getAssignments().isEmpty()) {
        Label label = componentsFactory.createComponent(Label.class);
        label.setValue("No assignments");
        return label;
    }

    // create PopupView otherwise
    PopupView popupView = componentsFactory.createComponent(PopupView.class);

    VBoxLayout assignmentsContainer = componentsFactory.createComponent(VBoxLayout.class);
    
    // generate a content for the popup view
    for (Assignment assignment : auditor.getAssignments()) {
        
    }

    popupView.setPopupContent(assignmentsContainer);
    popupView.setMinimizedValue("Show assignments");

    return popupView;
});

The LinkButton component can be used to show info about a single assignment and handle user clicking to open the entity editor.

Best regards,
Daniil.