
org.rapidoidx.demo.taskplanner.gui.NewTaskScreen Maven / Gradle / Ivy
The newest version!
package org.rapidoidx.demo.taskplanner.gui;
/*
* #%L
* rapidoid-x-demo
* %%
* Copyright (C) 2014 - 2015 Nikolche Mihajlovski and contributors
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
* #L%
*/
import java.util.List;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Order;
import org.rapidoid.annotation.Session;
import org.rapidoid.annotation.Since;
import org.rapidoid.app.GUI;
import org.rapidoid.gui.Form;
import org.rapidoid.gui.Grid;
import org.rapidoid.html.FieldType;
import org.rapidoid.html.Tag;
import org.rapidoid.u.U;
import org.rapidoid.var.Var;
import org.rapidoidx.db.XDB;
import org.rapidoidx.demo.taskplanner.model.Task;
@Order(1)
@Authors("Nikolche Mihajlovski")
@Since("3.0.0")
public class NewTaskScreen extends GUI {
@Session
private Task task = new Task();
@Session
private List comments = U.list();
@Session
private Var v = var("abc");
@Session
private Var> v2 = var("v2", U.list("b", "AA"));
public Object content() {
Tag caption1 = titleBox("Add new task");
Form frm = create(task).buttons(ADD, CANCEL);
frm.field("description").setType(FieldType.TEXTAREA);
frm.add(field(null, null, null, "abcd", null, FieldType.CHECKBOXES, U.list("AA", "b", "cDeF"), true, v2, null));
frm.field("description").setLabel(h3("my custom field"));
frm.field("comments").setInput(div((Object[]) radios(U.list("a", "bb", "ccc"), v)));
Tag caption2 = titleBox("Most recent tasks");
Grid grid = grid(Task.class, "-id", 7, "id", "priority", "title");
return row(col4(caption1, frm), col8(caption2, grid));
}
public void onAdd() {
task.owner.set(null);
task.description = v.get();
XDB.insert(task);
task = new Task();
}
public void onCancel() {
task = new Task();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy