Search in sources :

Example 1 with OneToManyLink

use of db.OneToManyLink in project common by zenlunatics.

the class Meetings method _newViewDef.

// ------------------------------------------------------------------------
@Override
public ViewDef _newViewDef(String name, Site site) {
    if (name.equals("meetings")) {
        ViewDef view_def = new ViewDef(name) {

            @Override
            public View newView(Request request) {
                View view = new View(this, request);
                if (request.getParameter("db_mode") == View.Mode.EDIT_FORM.toString())
                    if (request.db.lookupInt("_owner_", "meetings", Integer.parseInt(view.getKeyValue()), -1) != request.getUser().getId())
                        view.setColumn(new Column("title").setIsReadOnly(true));
                return view;
            }
        }.addInsertHook(this).addUpdateHook(this).setAccessPolicy(new RecordOwnerAccessPolicy() {

            @Override
            public boolean canUpdateRow(String from, int id, Request request) {
                return true;
            }

            @Override
            public boolean showEditButtonForRow(View view, Request request) {
                return true;
            }
        }.add().delete().edit()).setRecordName("Meeting").setColumnNamesForm(new String[] { "title", "days", "_owner_" }).setColumnNamesTable(new String[] { "title" }).setColumn(new Column("days").setInputRenderer(new MeetingInputRenderer()).setLabelRenderer(new AddButtonLabelRenderer("meeting.addDay()"))).setColumn(new Column("_owner_").setDefaultToUserId().setIsHidden(true)).setColumn(new Column("title").setIsRequired(true)).addRelationshipDef(new OneToManyLink("meeting_people", "people_id"));
        view_def.getViewTheme().setEditText("set times");
        return view_def;
    }
    if (name.equals("meeting_people"))
        return new ViewDef(name).setDialogModes(View.Mode.ADD_FORM).setRecordName("Person").setColumnNamesTable(new String[] { "color", "people_id" }).setColumn(new Column("color").setDisplayName("").setValueRenderer(new MeetingColorRenderer(), false)).setColumn(new Column("days").setInputRenderer(new MeetingInputRenderer()).setLabelRenderer(new AddButtonLabelRenderer("addDay()"))).setColumn(new LookupColumn("people_id", "people", "first,last").setDisplayName("Person"));
    return null;
}
Also used : OneToManyLink(db.OneToManyLink) Request(app.Request) ViewDef(db.ViewDef) View(db.View) RecordOwnerAccessPolicy(db.access.RecordOwnerAccessPolicy) LookupColumn(db.column.LookupColumn) LookupColumn(db.column.LookupColumn) Column(db.column.Column) AddButtonLabelRenderer(db.AddButtonLabelRenderer)

Aggregations

Request (app.Request)1 AddButtonLabelRenderer (db.AddButtonLabelRenderer)1 OneToManyLink (db.OneToManyLink)1 View (db.View)1 ViewDef (db.ViewDef)1 RecordOwnerAccessPolicy (db.access.RecordOwnerAccessPolicy)1 Column (db.column.Column)1 LookupColumn (db.column.LookupColumn)1