Search in sources :

Example 41 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class MultipleSelectionElementImpl method evalFormRequest.

@Override
public void evalFormRequest(UserRequest ureq) {
    Form form = getRootForm();
    if (isAjaxOnly()) {
        String dispatchuri = form.getRequestParameter("dispatchuri");
        if (dispatchuri != null && dispatchuri.equals(component.getFormDispatchId())) {
            String key = form.getRequestParameter("achkbox");
            String checked = form.getRequestParameter("checked");
            if ("true".equals(checked)) {
                selected.add(key);
            } else if ("false".equals(checked)) {
                selected.remove(key);
            }
        }
    } else if (isEnabled()) {
        // which one was selected?
        // selection change?
        // mark corresponding comps as dirty
        String[] reqVals = form.getRequestParameterValues(getName());
        if (reqVals == null) {
            // selection box?
            reqVals = form.getRequestParameterValues(getName() + "_SELBOX");
        }
        // 
        selected = new HashSet<>();
        if (reqVals != null) {
            for (int i = 0; i < reqVals.length; i++) {
                selected.add(reqVals[i]);
            }
        }
    }
    String dispatchuri = form.getRequestParameter("dispatchuri");
    if (dispatchuri != null && dispatchuri.equals(component.getFormDispatchId())) {
        formRequestEval = new ConsumableBoolean(true);
    }
}
Also used : ConsumableBoolean(org.olat.core.util.ConsumableBoolean) Form(org.olat.core.gui.components.form.flexible.impl.Form) HashSet(java.util.HashSet)

Example 42 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class AbstractFlexiTableRenderer method renderHeaderSearch.

protected void renderHeaderSearch(Renderer renderer, StringOutput sb, FlexiTableElementImpl ftE, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
    if (ftE.isSearchEnabled()) {
        Form theForm = ftE.getRootForm();
        String dispatchId = ftE.getFormDispatchId();
        sb.append("<div class='o_table_search input-group o_noprint'>");
        renderFormItem(renderer, sb, ftE.getSearchElement(), ubu, translator, renderResult, args);
        sb.append("<div class='input-group-btn'>");
        // reset quick search
        String id = ftE.getSearchElement().getFormDispatchId();
        sb.append("<a href=\"javascript:jQuery('#").append(id).append("').val('');").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("reset-search", "true"))).append("\" class='btn o_reset_quick_search'><i class='o_icon o_icon_remove_filters'> </i></a>");
        renderFormItem(renderer, sb, ftE.getSearchButton(), ubu, translator, renderResult, args);
        if (ftE.getExtendedSearchButton() != null) {
            renderFormItem(renderer, sb, ftE.getExtendedSearchButton(), ubu, translator, renderResult, args);
        }
        StringBuilder filterIndication = new StringBuilder();
        if (ftE.getExtendedFilterButton() != null) {
            ftE.getSelectedExtendedFilters().forEach(filter -> {
                if (filterIndication.length() > 0)
                    filterIndication.append(", ");
                filterIndication.append(filter.getLabel());
            });
            renderFormItem(renderer, sb, ftE.getExtendedFilterButton(), ubu, translator, renderResult, args);
        }
        sb.append("</div>");
        sb.append("</div>");
        if (filterIndication.length() > 0) {
            sb.append("<div class='o_table_tools_indications'>").append(filterIndication).append("<a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("rm-extended-filter", "true"))).append("\" title=\"").append(translator.translate("remove.filters")).append("\">").append("<i class='o_icon o_icon_remove o_icon-fw'> </i></a></div>");
        }
    } else if (ftE.getExtendedSearchButton() != null) {
        renderFormItem(renderer, sb, ftE.getExtendedSearchButton(), ubu, translator, renderResult, args);
    }
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 43 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class AbstractFlexiTableRenderer method renderPageBackLink.

private void renderPageBackLink(StringOutput sb, FlexiTableComponent ftC, int page) {
    boolean disabled = (page <= 0);
    FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
    Form theForm = ftE.getRootForm();
    sb.append("<li").append(" class='disabled'", disabled).append("><a href=\"");
    if (disabled) {
        sb.append("#");
    } else {
        sb.append("javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, ftC.getFormDispatchId(), 1, true, true, true, new NameValuePair("page", Integer.toString(page - 1))));
    }
    sb.append("\">").append("&laquo;").append("</a></li>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 44 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class AbstractFlexiTableRenderer method renderFilterDropdown.

protected String renderFilterDropdown(StringOutput sb, FlexiTableElementImpl ftE, List<FlexiTableFilter> filters) {
    Form theForm = ftE.getRootForm();
    String dispatchId = ftE.getFormDispatchId();
    StringBuilder selected = new StringBuilder(256);
    sb.append("<div class='btn-group'>").append("<button id='table-button-filters-").append(dispatchId).append("' type='button' class='btn btn-default dropdown-toggle' data-toggle='dropdown'>").append("<i class='o_icon o_icon_filter o_icon-lg'> </i> <b class='caret'></b></button>").append("<div id='table-filters-").append(dispatchId).append("' class='hide'><ul class='o_dropdown list-unstyled' role='menu'>");
    for (FlexiTableFilter filter : filters) {
        if (FlexiTableFilter.SPACER.equals(filter)) {
            sb.append("<li class='divider'></li>");
        } else {
            sb.append("<li><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("filter", filter.getFilter()))).append("\">").append("<i class='o_icon o_icon_check o_icon-fw'> </i> ", filter.isSelected());
            if (filter.getIconLeftCSS() != null) {
                sb.append("<i class='o_icon ").append(filter.getIconLeftCSS()).append("'> </i> ");
            }
            if (filter.getIconRenderer() != null) {
                filter.getIconRenderer().render(sb, filter, ftE.getComponent(), ftE.getTranslator());
            }
            sb.append(filter.getLabel()).append("</a></li>");
            if (filter.isSelected() && !filter.isShowAll()) {
                if (selected.length() > 0)
                    selected.append(", ");
                selected.append(filter.getLabel());
            }
        }
    }
    sb.append("</ul></div></div> ").append("<script type='text/javascript'>\n").append("/* <![CDATA[ */\n").append("jQuery(function() { o_popover('table-button-filters-").append(dispatchId).append("','table-filters-").append(dispatchId).append("'); });\n").append("/* ]]> */\n").append("</script>");
    return selected.toString();
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)

Example 45 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class AbstractFlexiTableRenderer method renderBreadcrumbs.

protected void renderBreadcrumbs(StringOutput sb, FlexiTableElementImpl ftE, FlexiTreeTableNode crumb, String index) {
    Form theForm = ftE.getRootForm();
    String dispatchId = ftE.getFormItemComponent().getDispatchID();
    sb.append("<li><a href=\"javascript:").append(FormJSHelper.getXHRFnCallFor(theForm, dispatchId, 1, true, true, true, new NameValuePair("tt-crumb", index))).append("\">").append(crumb.getCrump()).append("</a></li>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form)

Aggregations

Form (org.olat.core.gui.components.form.flexible.impl.Form)64 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)42 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)10 Component (org.olat.core.gui.components.Component)4 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)4 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)4 StringOutput (org.olat.core.gui.render.StringOutput)4 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2 SortKey (org.olat.core.commons.persistence.SortKey)2 TextBoxListElementComponent (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementComponent)2 TextBoxListElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl)2 TextModeState (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl.TextModeState)2 FlexiTableElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableElementImpl)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 AJAXFlags (org.olat.core.gui.control.winmgr.AJAXFlags)2