use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class TreeNodeFlexiCellRenderer method renderIndented.
private void renderIndented(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
FlexiTableElementImpl ftE = source.getFlexiTableElement();
FlexiTreeTableDataModel<?> treeTableModel = ftE.getTreeTableDataModel();
String id = source.getFormDispatchId();
Form rootForm = ftE.getRootForm();
// indentation
int indentation = treeTableModel.getIndentation(row);
boolean hasChildren = treeTableModel.hasChildren(row);
target.append("<div class='o_table_flexi_l").append(indentation).append(" o_table_flexi_leaf", !hasChildren).append("'>");
if (hasChildren) {
NameValuePair pair;
boolean open = treeTableModel.isOpen(row);
if (open) {
pair = new NameValuePair("tt-close", Integer.toString(row));
} else {
pair = new NameValuePair("tt-open", Integer.toString(row));
}
String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, true, true, pair);
target.append("<a href=\"javascript:").append(jsCode).append(";\"><i class='o_icon o_icon-fw ");
if (open) {
target.append("o_icon_close_tree");
} else {
target.append("o_icon_open_tree");
}
target.append("'> </i></a> ");
}
NameValuePair pair = new NameValuePair("tt-focus", Integer.toString(row));
String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, false, false, pair);
target.append("<a href=\"javascript:").append(jsCode).append(";\">");
labelDelegate.render(renderer, target, cellValue, row, source, ubu, translator);
target.append("</a></div>");
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class TableRenderer method appendSelectDeselectAllButtons.
private void appendSelectDeselectAllButtons(StringOutput target, Translator translator, Table table, String formName, int rows, int resultsPerPage, boolean ajaxEnabled, URLBuilder ubu) {
if (table.isMultiSelect() && !table.isMultiSelectAsDisabled()) {
target.append("<div class='o_table_checkall input-sm'>").append("<label class='checkbox-inline'>").append("<a href='#' onclick=\"javascript:o_table_toggleCheck('").append(formName).append("', true)\">").append("<i class='o_icon o_icon-lg o_icon_check_on'> </i> ").append(translator.translate("checkall")).append("</a></label>");
target.append("<label class='checkbox-inline'><a href=\"#\" onclick=\"javascript:o_table_toggleCheck('").append(formName).append("', false)\">").append("<i class='o_icon o_icon-lg o_icon_check_off'> </i> ").append(translator.translate("uncheckall")).append("</a></label>").append("</div>");
}
if (table.isShowAllSelected() && (rows > resultsPerPage)) {
target.append("<div class='o_table_pagination'><ul class='pagination'><li>").append("<a class=\"").append("btn btn-sm btn-default").append("\" ");
ubu.buildHrefAndOnclick(target, ajaxEnabled, new NameValuePair(Table.FORM_CMD, Table.COMMAND_PAGEACTION), new NameValuePair(Table.FORM_PARAM, Table.COMMAND_SHOW_PAGES)).append(">").append(translator.translate("table.showpages")).append("</a>").append("</li><ul></div>");
}
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class AutoCompleterRenderer method render.
@Override
public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) {
AutoCompleterComponent cmp = (AutoCompleterComponent) source;
AutoCompleter autoCompleter = cmp.getAutoCompleter();
final int inputSize = 72;
String id = autoCompleter.getFormDispatchId();
if (autoCompleter.isEnabled()) {
boolean showDisplayKey = false;
String mapperUri = autoCompleter.getMapperUri();
int minLength = autoCompleter.getMinLength();
StringOutput command = new StringOutput(64);
ubu.createCopyFor(cmp).openXHREvent(command, null, false, false, new NameValuePair(VelocityContainer.COMMAND_ID, "select"));
sb.append("<input type='text' class='form-control' size='").append(inputSize).append("' id='").append(id).append("' name='").append(id).append("' value=\"");
if (StringHelper.containsNonWhitespace(autoCompleter.getValue())) {
sb.append(StringHelper.escapeHtml(autoCompleter.getValue()));
}
sb.append("\" />");
sb.append("<script type='text/javascript'>\n").append("/* <![CDATA[ */\n").append("jQuery(function(){\n").append(" var fullNameTypeahead = new Bloodhound({\n").append(" datumTokenizer: function (d) {\n").append(" return Bloodhound.tokenizers.whitespace(d.value);\n").append(" },\n").append(" queryTokenizer: Bloodhound.tokenizers.whitespace,\n").append(" remote: {\n").append(" url: '").append(mapperUri).append(// place holder is useless but for tomcat, sometimes it said that the term parameter is corrupted and will not be part of the request send to OpenOLAT
"/?place=holder&term=%QUERY',\n").append(" wildcard: '%QUERY',\n").append(" filter: function ( response ) {\n").append(" return jQuery.map(response, function (object) {\n").append(" return {\n").append(" value: '' + object.key,\n");
if (showDisplayKey) {
sb.append(" fullName: object.displayKey + ': ' + object.value\n");
} else {
sb.append(" fullName: object.value\n");
}
sb.append(" };\n").append(" });\n").append(" }\n").append(" }\n").append(" });\n").append(" fullNameTypeahead.initialize();\n").append(" jQuery('#").append(id).append("').typeahead({\n").append(" hint: false,\n").append(" highlight: false,\n").append(" minLength: ").append(minLength).append("\n").append(" },{\n").append(" minLength: ").append(minLength).append(",\n").append(" displayKey: 'fullName',\n").append(" source: fullNameTypeahead.ttAdapter()\n").append(" }).on('typeahead:selected', function (e, object) {\n").append(" ").append(command).append(",'key',object.value,'value',object.fullName);\n").append(" });\n").append("});\n").append("/* ]]> */\n").append("</script>");
} else {
String value = "";
if (StringHelper.containsNonWhitespace(autoCompleter.getValue())) {
value = autoCompleter.getValue();
}
sb.append("<input id=\"").append(id).append("\" type=\"test\" disabled=\"disabled\" class=\"form-control o_disabled\" size=\"").append(inputSize).append("\" value=\"").append(value).append("\" />").append("</span>");
}
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair 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);
}
}
use of org.olat.core.gui.components.form.flexible.impl.NameValuePair in project OpenOLAT by OpenOLAT.
the class AbstractFlexiTableRenderer method renderFooterButtons.
protected void renderFooterButtons(StringOutput sb, FlexiTableComponent ftC, Translator translator) {
FlexiTableElementImpl ftE = ftC.getFlexiTableElement();
if (ftE.isSelectAllEnable()) {
String formName = ftE.getRootForm().getFormName();
String dispatchId = ftE.getFormDispatchId();
sb.append("<div class='o_table_footer'><div class='o_table_checkall input-sm'>");
sb.append("<label class='checkbox-inline'><a id='").append(dispatchId).append("_sa' href=\"javascript:o_table_toggleCheck('").append(formName).append("', true);").append(FormJSHelper.getXHRFnCallFor(ftE.getRootForm(), dispatchId, 1, true, true, true, new NameValuePair("select", "checkall"))).append("\"><i class='o_icon o_icon-lg o_icon_check_on'> </i> <span>").append(translator.translate("form.checkall")).append("</span></a></label>");
sb.append("<label class='checkbox-inline'><a id='").append(dispatchId).append("_dsa' href=\"javascript:o_table_toggleCheck('").append(formName).append("', false);").append(FormJSHelper.getXHRFnCallFor(ftE.getRootForm(), dispatchId, 1, true, true, true, new NameValuePair("select", "uncheckall"))).append("\"><i class='o_icon o_icon-lg o_icon_check_off'> </i> <span>").append(translator.translate("form.uncheckall")).append("</span></a></label>");
sb.append("</div></div>");
}
if (ftE.getDefaultPageSize() > 0) {
renderPagesLinks(sb, ftC, translator);
}
}
Aggregations