2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00
This commit is contained in:
Rushabh Mehta 2018-01-10 16:20:57 +05:30
parent 60832b1d96
commit 8bcdb91c9f
3 changed files with 558 additions and 402 deletions

View File

@ -6,7 +6,23 @@ const ListView = require('frappe-core/frappe/client/view/list').ListView;
const Page = require('frappe-core/frappe/client/view/page').Page;
const Form = require('frappe-core/frappe/client/view/form').Form;
window.todo_app = {};
window.app = {
setup_form() {
this.edit_page = new Page('Edit To Do');
this.edit_page.form = new Form({
doctype: 'ToDo',
parent: this.edit_page.body
});
this.edit_page.form.make();
},
setup_list() {
this.todo_list = new Page('ToDo List');
this.todo_list.list = new ListView({
doctype: 'ToDo',
parent: this.todo_list.body
});
}
};
// start server
client.start({
@ -16,34 +32,37 @@ client.start({
const todo = require('frappe-core/frappe/models/doctype/todo/todo.js');
frappe.init_controller('todo', todo);
app.home = frappe.ui.add('a', '', frappe.ui.add('p', null, frappe.sidebar));
app.home.textContent = 'Home';
app.home.href = '#';
app.make_new = frappe.ui.add('a', '', frappe.ui.add('p', null, frappe.sidebar));
app.make_new.textContent = 'New ToDo';
app.make_new.href = '#new/todo';
// make pages
todo_app.edit_page = new Page('Edit To Do');
todo_app.todo_list = new Page('ToDo List');
app.setup_list();
app.setup_form();
// to do list
frappe.router.add('default', () => {
todo_app.todo_list.show();
if (!todo_app.todo_list.list) {
todo_app.todo_list.list = new ListView({
doctype: 'ToDo',
parent: todo_app.todo_list.body
});
}
todo_app.todo_list.list.run();
app.todo_list.show();
app.todo_list.list.run();
});
// setup todo form
frappe.router.add('todo/:name', async (params) => {
todo_app.edit_page.show();
if (!todo_app.edit_page.form) {
todo_app.edit_page.form = new Form({
doctype: 'ToDo',
parent: todo_app.edit_page.body
});
todo_app.edit_page.form.make();
}
todo_app.doc = await frappe.get_doc('ToDo', params.name);
todo_app.edit_page.form.use(todo_app.doc);
frappe.router.add('edit/todo/:name', async (params) => {
app.doc = await frappe.get_doc('ToDo', params.name);
app.edit_page.show();
app.edit_page.form.use(app.doc);
});
// setup todo new
frappe.router.add('new/todo', async (params) => {
app.doc = await frappe.get_doc({doctype: 'ToDo'});
app.doc.set_name();
app.edit_page.show();
app.edit_page.form.use(app.doc, true);
});
frappe.router.show(window.location.hash);

File diff suppressed because one or more lines are too long

View File

@ -18,13 +18,26 @@ html {
.wrapper {
display: grid;
grid-template-columns: 1fr 4fr;
grid-auto-rows: minmax(500px, auto);
grid-auto-rows: minmax(100%, auto);
height: 100vh;
}
.sidebar {
background-color: $gray-100;
}
.main, .sidebar {
padding: 2rem;
}
.hide {
display: none !important;
}
form .alert {
margin-top: 1rem;
}
textarea.form-control {
line-height: 1.5;
}