Search in sources :

Example 31 with BusinessGroupMembership

use of org.olat.group.BusinessGroupMembership in project openolat by klemens.

the class OpenBusinessGroupListController method addAccessLink.

protected void addAccessLink(BGTableItem item) {
    String action;
    BusinessGroupMembership membership = item.getMembership();
    if (membership != null && membership.isOwner()) {
        return;
    } else if (membership != null && (membership.isParticipant() || membership.isWaiting())) {
        action = TABLE_ACTION_LEAVE;
    } else if (item.isFull() && !item.isWaitingListEnabled()) {
        action = null;
    } else {
        action = TABLE_ACTION_ACCESS;
    }
    String i18nKey;
    if (membership != null && membership.isParticipant()) {
        i18nKey = "table.header.leave";
    } else if (membership != null && membership.isWaiting()) {
        i18nKey = "table.header.leave.waiting";
    } else if (item.isFull()) {
        if (item.isWaitingListEnabled()) {
            i18nKey = "table.access.waitingList";
        } else {
            i18nKey = "table.header.group.full";
        }
    } else if (item.isWaitingListEnabled()) {
        if (item.isFull()) {
            i18nKey = "table.access.waitingList";
        } else {
            i18nKey = "table.access";
        }
    } else {
        i18nKey = "table.access";
    }
    FormLink accessLink = uifactory.addFormLink("open_" + item.getBusinessGroupKey(), action, i18nKey, null, null, Link.LINK);
    if (action == null) {
        accessLink.setEnabled(false);
    }
    accessLink.setUserObject(item);
    item.setAccessLink(accessLink);
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 32 with BusinessGroupMembership

use of org.olat.group.BusinessGroupMembership in project openolat by klemens.

the class OpenBusinessGroupListController method searchTableItems.

@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
    List<OpenBusinessGroupRow> rows = businessGroupService.findPublishedBusinessGroups(params, getIdentity());
    List<BGTableItem> items = new ArrayList<>(rows.size());
    for (OpenBusinessGroupRow row : rows) {
        BusinessGroupMembership membership = row.getMember();
        Boolean allowLeave = membership != null;
        BGTableItem item = new BGTableItem(row, null, allowLeave, Boolean.FALSE);
        addAccessLink(item);
        items.add(item);
    }
    return items;
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) ArrayList(java.util.ArrayList)

Example 33 with BusinessGroupMembership

use of org.olat.group.BusinessGroupMembership in project openolat by klemens.

the class SearchBusinessGroupListController method searchTableItems.

@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
    List<BusinessGroupRow> rows = businessGroupService.findBusinessGroupsWithMemberships(params, getIdentity());
    List<BGTableItem> items = new ArrayList<>(rows.size());
    for (BusinessGroupRow row : rows) {
        BusinessGroupMembership membership = row.getMember();
        Boolean allowLeave = membership != null;
        Boolean allowDelete = isAdmin() ? Boolean.TRUE : (membership == null ? null : new Boolean(membership.isOwner()));
        FormLink markLink = uifactory.addFormLink("mark_" + row.getKey(), "mark", "", null, null, Link.NONTRANSLATED);
        markLink.setIconLeftCSS(row.isMarked() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
        BGTableItem item = new BGTableItem(row, markLink, allowLeave, allowDelete);
        items.add(item);
    }
    return items;
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) BusinessGroupRow(org.olat.group.model.BusinessGroupRow)

Example 34 with BusinessGroupMembership

use of org.olat.group.BusinessGroupMembership in project openolat by klemens.

the class BusinessGroupListController method searchTableItems.

@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
    List<BusinessGroupRow> rows = businessGroupService.findBusinessGroupsWithMemberships(params, getIdentity());
    List<BGTableItem> items = new ArrayList<>(rows.size());
    for (BusinessGroupRow row : rows) {
        BusinessGroupMembership membership = row.getMember();
        Boolean allowLeave = membership != null;
        Boolean allowDelete = isAdmin() ? Boolean.TRUE : (membership == null ? null : new Boolean(membership.isOwner()));
        FormLink markLink = uifactory.addFormLink("mark_" + row.getKey(), "mark", "", null, null, Link.NONTRANSLATED);
        markLink.setIconLeftCSS(row.isMarked() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
        BGTableItem item = new BGTableItem(row, markLink, allowLeave, allowDelete);
        items.add(item);
    }
    return items;
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) BusinessGroupRow(org.olat.group.model.BusinessGroupRow)

Aggregations

BusinessGroupMembership (org.olat.group.BusinessGroupMembership)34 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)10 Identity (org.olat.core.id.Identity)10 BusinessGroup (org.olat.group.BusinessGroup)10 RepositoryEntryMembership (org.olat.repository.model.RepositoryEntryMembership)8 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 HashSet (java.util.HashSet)4 List (java.util.List)4 BusinessGroupShort (org.olat.group.BusinessGroupShort)4 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)4 OLATResource (org.olat.resource.OLATResource)4 Date (java.util.Date)2 Locale (java.util.Locale)2 Test (org.junit.Test)2 Component (org.olat.core.gui.components.Component)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)2