Search in sources :

Example 16 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class EMailForm method write.

// --------------------------------------------------------------------
public void write(// TODO: can probably remove show_people_list, must always be true
boolean sender_is_user, // TODO: can probably remove show_people_list, must always be true
boolean show_people_list, // TODO: can probably remove show_people_list, must always be true
Request request) throws // TODO: can probably remove show_people_list, must always be true
IOException {
    HTMLWriter writer = request.writer;
    writer.formOpen("POST", request.getContext() + "/" + m_name);
    writer.hiddenInput("cmd", "send");
    writer.hiddenInput("list", null);
    boolean send_from_local_domain = request.site.getSettings().getString("send from local domain") != null;
    if (sender_is_user)
        if (send_from_local_domain)
            writer.hiddenInput("reply_to", request.db.lookupString("email", m_table, "user_name='" + request.getUser().getUsername() + "'"));
        else
            writer.hiddenInput("from", request.db.lookupString("email", m_table, "user_name='" + request.getUser().getUsername() + "'"));
    Table table = new Table(writer).addStyle("margin", "0 auto").borderSpacing(5).cellPadding(5);
    table.tr();
    if (show_people_list)
        writer.write("<td class=\"db_columnheads\" style=\"vertical-align:top;\">send e-mail to</td>");
    rowOpen(table, sender_is_user ? "subject" : send_from_local_domain ? "reply_to" : "from", writer);
    writer.setAttribute("style", "margin:0;width:500px;");
    writer.textInput(sender_is_user ? "subject" : send_from_local_domain ? "reply_to" : "from", null, null);
    table.tr();
    if (show_people_list) {
        writer.setAttribute("rowspan", sender_is_user ? 3 : 4);
        writer.setAttribute("style", "vertical-align:top;");
        table.td();
        ViewState.setShowCheckBoxes("emailform:" + m_table, "email", "email", request);
        request.site.newView("emailform:" + m_table, request).writeComponent();
    }
    if (!sender_is_user) {
        rowOpen(table, "subject", writer);
        writer.setAttribute("style", "margin:0;width:500px;");
        writer.textInput("subject", null, null);
        table.tr();
    }
    writer.setAttribute("class", "db_columnheads");
    writer.setAttribute("style", "vertical-align:top;");
    table.td("message");
    writer.setAttribute("class", "db_row");
    writer.setAttribute("style", "vertical-align:top;height:300px;");
    table.td();
    writer.setAttribute("style", "height:300px;width:500px;");
    writer.textAreaOpen("message", null, null);
    writer.tagClose();
    writer.js("rich_text('message');");
    if (show_people_list && send_from_local_domain) {
        table.tr();
        rowOpen(table, "individually or group", writer);
        writer.radioButton("individually", "send a single email to selected people (allows \"reply all\")", "0", true, null);
        writer.radioButton("individually", "send separate email to each person (recipients don't see each other)", "1", false, null);
    } else
        writer.hiddenInput("individually", "1");
    table.tr().td("&nbsp;");
    writer.setAttribute("style", "text-align:center;vertical-align:top");
    table.td();
    writer.aButtonOnClick("send", "send_form(this,function(t){eval(t)})");
    table.close();
    writer.tagClose();
}
Also used : HTMLWriter(web.HTMLWriter) Table(web.Table)

Example 17 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class SortDropDown method write.

// --------------------------------------------------------------------------
@Override
public String write(View view, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("<div class=\"btn-group\">");
    OrderBy order_by = view.getState().order_by;
    for (int i = 0; i < order_by.size(); i++) {
        writeSortButton(order_by.columnName(i), order_by.descending(i), view, writer);
        writer.setAttribute("class", "dropdown-menu");
        writer.tagOpen("ul");
        writeSortListItem(order_by.columnName(i), view.getColumn(order_by.columnName(i)), !order_by.descending(i), view, writer);
        for (String column : view.getColumnNamesTable()) {
            if (column.equals(order_by.columnName(i)))
                continue;
            ColumnBase<?> c = view.getColumn(column);
            if (c != null)
                if (!c.isSortable() || c.isHidden(request) || !c.userCanView(view.getMode(), request))
                    continue;
            writeSortListItem(column, c, false, view, writer);
            writeSortListItem(column, c, true, view, writer);
        }
    }
    writer.write("</div>");
    return null;
}
Also used : HTMLWriter(web.HTMLWriter)

Example 18 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Relationship method writeManyTableRowLabel.

// --------------------------------------------------------------------------
private int writeManyTableRowLabel(String label_class, boolean show_add_link, int depth, Request request) throws IOException {
    int rwc_id = 0;
    HTMLWriter writer = request.writer;
    writer.setAttribute("valign", "top");
    if (m_show_label && !m_shares_data) {
        writer.tagOpen("td");
        if (label_class != null)
            writer.setAttribute("class", label_class);
        writer.setAttribute("style", "margin-right:5px;");
        writer.tagOpen("span");
        rwc_id = m_many.writeRowWindowControlsSpan();
        writer.tagClose();
    } else {
        if (label_class != null)
            writer.setAttribute("class", label_class);
        writer.setAttribute("style", "padding-left:" + depth * 10 + "px");
        writer.tagOpen("td");
    }
    if (!show_add_link && !m_shares_data && !m_many.isPrinterFriendly() && request.userIsAdministrator()) {
        show_add_link = true;
        writer.setAttribute("class", "btn btn-xs btn-success");
    }
    if (show_add_link && !m_shares_data && !m_many.isPrinterFriendly()) {
        writer.write("<hr style=\"margin:2px 0\">");
        writer.setAttribute("style", "margin-right:5px;");
        String add_button_text = m_many.getViewDef().getAddButtonText();
        // if ((def instanceof ManyToMany || def instanceof OneToManyLink) && "add".equals(add_button_text))
        // add_button_text = "add link";
        writer.aButtonOnClick(add_button_text, getAddJavascript(request));
    }
    return rwc_id;
}
Also used : HTMLWriter(web.HTMLWriter)

Example 19 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class MonthFilter method write.

// --------------------------------------------------------------------------
@Override
public String write(View view, Request request) throws IOException {
    int this_month = request.site.newCalendar().get(Calendar.MONTH);
    int month = this_month;
    String filter = view.getState().filter;
    if (filter != null) {
        int start = filter.indexOf("extract(month from date)='");
        if (start != -1) {
            start += 26;
            int end = filter.indexOf("'", start);
            month = Integer.parseInt(filter.substring(start, end)) - 1;
        }
    }
    HTMLWriter writer = request.writer;
    String id = UUID.randomUUID().toString();
    writer.setAttribute("id", id);
    writer.setAttribute("class", "form-control");
    writer.setAttribute("style", "display:inline;font-size:inherit;height:inherit;width:inherit;");
    writer.tagOpen("select");
    for (int i = 0; i < 12; i++) {
        writer.write("<option");
        if (i == month)
            writer.write(" selected=\"selected\"");
        writer.write(" value=\"").write(i + 1).write("\">").write(s_months[i]).write("</option>");
    }
    writer.tagClose();
    return id;
}
Also used : HTMLWriter(web.HTMLWriter)

Example 20 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class BooleanColumn method writeInput.

// ---------------------------------------------------------------------- ----
@Override
public boolean writeInput(View view, Form form, ColumnBase<?> column, View.Mode mode, String default_value, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    if (m_checkbox)
        writer.checkbox(m_name, m_label_with_input ? column.getDisplayName(true) : null, null, mode == View.Mode.EDIT_FORM && view.data().getBoolean(m_name), false);
    else {
        if (m_label_with_input) {
            writer.write(column.getDisplayName(true));
            writer.space();
        }
        writer.radioButtons(m_name, m_values, m_values, mode == View.Mode.EDIT_FORM ? view.data().getString(m_name) : null);
    }
    return true;
}
Also used : HTMLWriter(web.HTMLWriter)

Aggregations

HTMLWriter (web.HTMLWriter)109 Select (db.Select)18 SQLException (java.sql.SQLException)16 ResultSet (java.sql.ResultSet)14 Table (web.Table)12 JDBCTable (db.JDBCTable)10 Person (app.Person)7 Calendar (java.util.Calendar)7 ArrayList (java.util.ArrayList)6 JDBCColumn (db.JDBCColumn)5 View (db.View)5 DBObject (db.DBObject)4 Form (db.Form)4 File (java.io.File)4 AdminTask (web.AdminTask)4 FilePathStringBuilder (web.FilePathStringBuilder)4 Select (web.Select)4 Mode (db.View.Mode)3 IOException (java.io.IOException)3 NumberFormat (java.text.NumberFormat)3