use of web.URLStringBuilder in project common by zenlunatics.
the class View method getOnClickForRow.
// --------------------------------------------------------------------------
protected String getOnClickForRow(Mode mode) {
URLStringBuilder url = getRowURL(mode);
url.set("db_mode", mode);
if (mode == View.Mode.ADD_FORM && m_view_def.getSectionDef() != null && m_view_def.getSectionDef().type() == SectionDef.Type.TABS && m_data.getRow() != 0)
url.set("db_tab_" + m_view_def.getSectionDef().columnName(), HTMLWriter.escapeJSString(m_data.getString(m_view_def.getSectionDef().columnName())));
if (m_view_def.useDialogFor(mode)) {
url.append("/component");
if (mode == View.Mode.ADD_FORM) {
String add_button_text = m_view_def.getAddButtonText();
return "new Dialog({cancel:true,ok:{text:'add'},title:'" + add_button_text.substring(0, 1).toUpperCase() + add_button_text.substring(1) + " " + m_view_def.getRecordName() + "',url:'" + url.toString() + "',owner:c_(this),width:'auto'})";
}
if (mode == View.Mode.EDIT_FORM)
return "new Dialog({cancel:true,ok:{text:'save'},title:'Edit " + m_view_def.getRecordName() + "',url:'" + url.toString() + "',owner:c_(this),width:'auto'})";
if (mode == View.Mode.FILTER_FORM)
return "new Dialog({cancel:true,ok:{text:'search'},title:'Search " + m_view_def.getRecordNamePlural() + "',url:'" + url.toString() + "',owner:c_(this),width:'auto'})";
if (mode == View.Mode.READ_ONLY_FORM)
return "new Dialog({cancel:false,ok:{text:'done',click:function(){Dialog.top().close()}},title:'View " + m_view_def.getRecordName() + "',url:'" + url.toString() + "',owner:c_(this),width:'auto'})";
}
return "c_(this).push('" + url.toString() + "','" + HTMLWriter.escapeJSString(getCrumb()) + "')";
}
use of web.URLStringBuilder in project common by zenlunatics.
the class View method writeListHead.
// --------------------------------------------------------------------------
protected void writeListHead() throws IOException {
if (m_view_def.getListHeadTemplate() != null) {
writeListHeadTemplate();
return;
}
boolean show_add_link = showAddButton();
if (m_mode == Mode.READ_ONLY_LIST || m_view_def.showDoneLink() || m_view_def.showNumRecords() || m_view_def.showTableColumnEditor() || m_relationship == null && m_view_def.showFilterLink() || show_add_link || m_request.userIsAdministrator()) {
m_writer.setAttribute("style", "margin:5px auto;width:100%;clear:both;");
m_writer.tagOpen("table");
m_writer.write("<tr class=\"" + m_style_base + "listhead\"><td>");
if (m_mode == Mode.READ_ONLY_LIST) {
m_writer.setAttribute("style", "font-size:15.6px;font-weight:bold");
m_writer.tag("span", m_view_def.getRecordNamePlural());
AccessPolicy access_policy = m_view_def.getAccessPolicy();
if (m_request.userIsAdministrator() || access_policy == null || !access_policy.isReadOnly(this, m_request) || access_policy.showAddButton(this, m_request) || access_policy.showEditButtons(this, m_request) || access_policy.showDeleteButtons(this, m_request)) {
m_writer.space();
URLStringBuilder url = new URLStringBuilder(m_request.getContext());
url.append("/Views/");
url.append(getRoot().m_view_def.getName());
if (m_relationship != null)
url.set("db_relationship", m_relationship.def.many_view_def_name);
m_writer.setAttribute("style", "float:right;margin-left:5px;vertical-align:baseline;");
url.set("db_mode", Mode.LIST);
m_writer.buttonIconOnClick("pencil", "c_(this).push('" + url.toString() + "','" + getCrumb() + "')");
}
} else if (m_view_def.showDoneLink()) {
m_writer.space();
m_writer.aButtonOnClick("done", "if(Dialog.top())Dialog.top().close();else c_(this).pop(1)");
} else if (m_view_def.showNumRecords())
m_rwc_id = writeRowWindowControlsSpan();
m_writer.write(" </td>");
if (m_mode != Mode.READ_ONLY_LIST) {
m_writer.write("<td align=\"right\" style=\"white-space:nowrap;padding:2px 6px 2px 0;\"> ");
if (m_view_def.showPrintLinkTable() && !m_printer_friendly && m_relationship == null) {
m_writer.setAttribute("title", "view list for printing");
m_writer.buttonIconOnClick("print", "open_print_window(this)");
m_writer.nbsp();
}
if (m_view_def.showTableColumnEditor()) {
writeColumnsPopup();
m_writer.nbsp();
}
if (!m_printer_friendly) {
if (m_relationship == null && m_view_def.showFilterLink())
writeButtonFilter();
if (show_add_link || m_request.userIsAdministrator()) {
if (m_relationship == null && m_view_def.showFilterLink())
m_writer.write(" | ");
if (!show_add_link)
m_writer.setAttribute("class", "btn btn-xs btn-success");
writeButtonAdd();
}
}
m_writer.write("</td>");
}
m_writer.write("</tr>");
m_writer.tagClose();
}
}
use of web.URLStringBuilder in project common by zenlunatics.
the class AButtonValueRenderer method writeValue.
// --------------------------------------------------------------------------
@Override
public void writeValue(View view, ColumnBase<?> column, Request request) throws IOException {
URLStringBuilder url = new URLStringBuilder(m_url_base);
for (int i = 0; i < m_names.length; i++) url.set(m_names[i], view.data().getString(m_value_columns[i]));
request.writer.aButtonOnClick(m_button_text, m_on_click_before + url.toString() + m_on_click_after);
}
Aggregations