Search in sources :

Example 1 with OrderBy

use of db.OrderBy in project common by zenlunatics.

the class ToDos method _newViewDef.

// --------------------------------------------------------------------------
@Override
public ViewDef _newViewDef(String name, Site site) {
    if (name.equals("todos")) {
        ViewDef view_def = new ViewDef(name);
        view_def.setDefaultOrderBy("task");
        view_def.setRecordName("Task");
        ArrayList<String> column_names_form = new ArrayList<String>();
        column_names_form.add("task");
        column_names_form.add("notes");
        if (m_group_by_project) {
            column_names_form.add("project");
            view_def.setColumn(new Column("project").setPostText("(optional)"));
            view_def.setSectionDef(new SectionDef("project", Type.SEPARATOR_ROWS, new OrderBy("project")));
        }
        if (m_prioritize) {
            view_def.setDefaultOrderBy("priority");
            column_names_form.add("priority");
            view_def.setColumn(new Column("priority").setInputRenderer(new SelectRenderer(new String[] { "1 - high", "2 - medium", "3 - low" })));
        }
        if (m_assign_tasks) {
            column_names_form.add("assigned_to");
            view_def.setColumn(new LookupColumn("assigned_to", "people", "first,last").setFilter(this).setDefaultToUserId());
        }
        if (m_one_table != null) {
            column_names_form.add(m_one_table + "_id");
            view_def.setColumn(new Column(m_one_table + "_id").setDefaultToSessionAttribute().setIsHidden(true));
        }
        view_def.setColumnNamesForm(column_names_form.toArray(new String[column_names_form.size()]));
        view_def.setColumnNamesTable(new String[] { "task" });
        view_def.setColumn(new Column("task") {

            @Override
            public boolean writeValue(View view, Map<String, Object> data, Request p) throws IOException {
                String notes = view.data().getString("notes");
                if (notes.length() > 0)
                    p.writer.write("<div onmouseover=\"if(!this.f){var e=$(this.lastChild);this.f=new Fx.Slide(e,{link:'cancel'});this.f.hide();e.setStyle('display','');$(this).addEvent('mouseout',function(e){if(!this.isAncestor(e.relatedTarget))this.f.slideOut()}.bind(this))}this.f.slideIn()\">");
                p.writer.write(view.data().getString("task"));
                if (notes.length() > 0) {
                    p.writer.write("<div style=\"background-color:white;padding:5px;font-size:smaller;display:none\">");
                    view.writeColumnHTML("notes");
                    p.writer.write("</div></div>");
                }
                return true;
            }
        });
        return view_def;
    }
    return null;
}
Also used : OrderBy(db.OrderBy) ArrayList(java.util.ArrayList) Request(app.Request) ViewDef(db.ViewDef) IOException(java.io.IOException) View(db.View) LookupColumn(db.column.LookupColumn) SectionDef(db.SectionDef) LookupColumn(db.column.LookupColumn) Column(db.column.Column) SelectRenderer(db.SelectRenderer)

Aggregations

Request (app.Request)1 OrderBy (db.OrderBy)1 SectionDef (db.SectionDef)1 SelectRenderer (db.SelectRenderer)1 View (db.View)1 ViewDef (db.ViewDef)1 Column (db.column.Column)1 LookupColumn (db.column.LookupColumn)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1