-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf203b2
commit ec61211
Showing
9 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2024, BWH and contributors | ||
// For license information, please see license.txt | ||
|
||
// frappe.ui.form.on("Book", { | ||
// refresh(frm) { | ||
|
||
// }, | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"actions": [], | ||
"allow_rename": 1, | ||
"autoname": "prompt", | ||
"creation": "2024-02-15 15:59:11.763852", | ||
"doctype": "DocType", | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"author" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "author", | ||
"fieldtype": "Data", | ||
"in_list_view": 1, | ||
"label": "Author", | ||
"reqd": 1 | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"links": [], | ||
"modified": "2024-02-15 15:59:37.277501", | ||
"modified_by": "Administrator", | ||
"module": "Htmx Portal", | ||
"name": "Book", | ||
"naming_rule": "Set by user", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
} | ||
], | ||
"sort_field": "modified", | ||
"sort_order": "DESC", | ||
"states": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2024, BWH and contributors | ||
# For license information, please see license.txt | ||
|
||
import frappe | ||
from frappe.model.document import Document | ||
from werkzeug.wrappers import Response | ||
|
||
|
||
class Book(Document): | ||
pass | ||
|
||
@frappe.whitelist() | ||
def new_book(): | ||
data = frappe.form_dict | ||
book = frappe.new_doc("Book") | ||
book.name = data.get("name") | ||
book.author = data.get("author") | ||
book.insert() | ||
|
||
return books_list() | ||
|
||
@frappe.whitelist() | ||
def books_list(): | ||
books_list_html = frappe.render_template("templates/includes/book_list.html") | ||
return Response(books_list_html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024, BWH and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
from frappe.tests.utils import FrappeTestCase | ||
|
||
|
||
class TestBook(FrappeTestCase): | ||
pass |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% set books = frappe.db.get_all("Book", fields=["name", "author"], order_by="creation desc") %} | ||
<ol> | ||
{% for book in books %} | ||
<li>{{ book.name }} | {{ book.author }}</li> | ||
{% endfor %} | ||
</ol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>My Book Shelf</title> | ||
<script src="/assets/htmx_portal/js/htmx.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.lime.min.css" /> | ||
</head> | ||
|
||
<body class="container"> | ||
<nav> | ||
<ul> | ||
<li><strong>My Book Shelf</strong></li> | ||
</ul> | ||
<ul> | ||
<li><a href="#">About</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<main class="grid"> | ||
<form hx-post="/api/v2/method/Book/new_book" hx-target="#book-list"> | ||
<fieldset> | ||
<label> | ||
Book Title | ||
<input name="name" placeholder="Harry Potter..." required /> | ||
</label> | ||
<label> | ||
Author | ||
<input name="author" placeholder="J.K. Rowling" required /> | ||
</label> | ||
</fieldset> | ||
|
||
<input type="submit" value="Create" /> | ||
</form> | ||
|
||
<div> | ||
<article id="book-list"> | ||
{% include "templates/includes/book_list.html" %} | ||
</article> | ||
|
||
<button | ||
class="secondary" | ||
hx-get="/api/v2/method/Book/books_list" | ||
hx-target="#book-list">Refresh | ||
</button> | ||
</div> | ||
</main> | ||
</body> | ||
|
||
</html> |