Search in sources :

Example 6 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.

the class ConfirmMoveBinderToTrashController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    StringBuilder names = new StringBuilder();
    int numOfPages = 0;
    int numOfSections = 0;
    int numOfComments = 0;
    for (BinderStatistics stat : stats) {
        if (names.length() > 0)
            names.append(", ");
        names.append(StringHelper.escapeHtml(stat.getTitle()));
        numOfPages += stat.getNumOfPages();
        numOfSections += stat.getNumOfSections();
        numOfComments += stat.getNumOfComments();
    }
    String[] args = new String[] { names.toString(), Integer.toString(numOfSections), Integer.toString(numOfPages), Integer.toString(numOfComments) };
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("msg", translate("delete.binder.warning", args));
        layoutCont.contextPut("dangerCssClass", "o_warning");
    }
    String[] onValues = new String[] { translate("trash.binder.acknowledge") };
    acknowledgeEl = uifactory.addCheckboxesHorizontal("acknowledge", "delete.binder.acknowledge", formLayout, onKeys, onValues);
    uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("delete", "delete.binder", formLayout);
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics)

Example 7 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.

the class DeletedBinderController method loadModel.

@Override
protected void loadModel() {
    List<BinderStatistics> binderRows = portfolioService.searchOwnedDeletedBinders(getIdentity());
    List<BinderRow> rows = new ArrayList<>(binderRows.size());
    for (BinderStatistics binderRow : binderRows) {
        rows.add(forgePortfolioRow(binderRow));
    }
    model.setObjects(rows);
    tableEl.reset();
    tableEl.reloadData();
}
Also used : BinderRow(org.olat.modules.portfolio.ui.model.BinderRow) ArrayList(java.util.ArrayList) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics)

Example 8 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.

the class TableOfContentController method doConfirmMoveToTrashBinder.

private void doConfirmMoveToTrashBinder(UserRequest ureq) {
    if (moveBinderToTrashCtrl != null)
        return;
    BinderStatistics stats = portfolioService.getBinderStatistics(binder);
    moveBinderToTrashCtrl = new ConfirmMoveBinderToTrashController(ureq, getWindowControl(), stats);
    listenTo(moveBinderToTrashCtrl);
    String title = translate("delete.binder");
    cmc = new CloseableModalController(getWindowControl(), null, moveBinderToTrashCtrl.getInitialComponent(), true, title, true);
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics)

Example 9 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project openolat by klemens.

the class TableOfContentController method doConfirmDeleteBinder.

private void doConfirmDeleteBinder(UserRequest ureq) {
    if (moveBinderToTrashCtrl != null)
        return;
    BinderStatistics stats = portfolioService.getBinderStatistics(binder);
    deleteBinderCtrl = new ConfirmDeleteBinderController(ureq, getWindowControl(), stats);
    listenTo(deleteBinderCtrl);
    String title = translate("delete.binder");
    cmc = new CloseableModalController(getWindowControl(), null, deleteBinderCtrl.getInitialComponent(), true, title, true);
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics)

Example 10 with BinderStatistics

use of org.olat.modules.portfolio.model.BinderStatistics in project OpenOLAT by OpenOLAT.

the class PortfolioServiceTest method searchOwnedBinders.

@Test
public void searchOwnedBinders() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("binder-owner-");
    Binder binder = portfolioService.createNewBinder("Binder 2", "Binder with one section.", null, owner);
    dbInstance.commitAndCloseSession();
    portfolioService.appendNewSection("First section", "My first section.", null, null, binder);
    dbInstance.commitAndCloseSession();
    portfolioService.appendNewSection("Second section", "My second section.", null, null, binder);
    dbInstance.commitAndCloseSession();
    List<Section> sections = portfolioService.getSections(binder);
    for (int i = 0; i < 2; i++) {
        Section section = sections.get(1);
        portfolioService.appendNewPage(owner, "Page-1-" + i, "", null, null, section);
        portfolioService.appendNewPage(owner, "Page-2-" + i, "", null, null, section);
    }
    List<BinderStatistics> rows = portfolioService.searchOwnedBinders(owner);
    Assert.assertNotNull(rows);
    Assert.assertEquals(1, rows.size());
    BinderStatistics myBinder = rows.get(0);
    Assert.assertEquals(2, myBinder.getNumOfSections());
    Assert.assertEquals(4, myBinder.getNumOfPages());
}
Also used : SynchedBinder(org.olat.modules.portfolio.model.SynchedBinder) Binder(org.olat.modules.portfolio.Binder) Identity(org.olat.core.id.Identity) BinderStatistics(org.olat.modules.portfolio.model.BinderStatistics) Section(org.olat.modules.portfolio.Section) Test(org.junit.Test)

Aggregations

BinderStatistics (org.olat.modules.portfolio.model.BinderStatistics)20 ArrayList (java.util.ArrayList)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 BinderRow (org.olat.modules.portfolio.ui.model.BinderRow)6 Date (java.util.Date)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 Test (org.junit.Test)2 Identity (org.olat.core.id.Identity)2 Binder (org.olat.modules.portfolio.Binder)2 Section (org.olat.modules.portfolio.Section)2 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)2