I’ve worked through the Library Management docs and school tutorial again to understand afresh a DocType’s Web View. It is clear that a Web View is only meant for representing existing documents (aka records) and not for creating / saving a new document nor for capturing any user interaction. However this made me question whether there are any mechanism whereby we can capture user interaction on the Web View, such as the clicking of a button.
So I amended the Article DocType
Ensured the Allow Guest to View = N
Added a docfield of type Button called Select
This should in theory allow a Login User to select an Article on the Web View. However it does not render correctly as can be seen
I then amended both article.html and article_row.html and added a custom HTML <button>Add</button> to each. in other words not a docfield of type Button.
So my question now is, how can I capture the Add button click on either of these 2 Web Views? It need not be a Button but can also be a Check box. I need to record / capture the selection of the article against the login User. How can I achieve this?
If that’s not possible, which other options do I have?
Thanks so much in advance.
I don’t have much experience with the Web Views, but I’m not surprised that button fields aren’t part of the data model available to jinja. They’re “fields” as far as the doctype is concerned, but they don’t have any underlying representation in the database. It’d be the same I imagine if you tried to render a column break or some other pseudo-field this way.
Your best bet is probably just to do this all client side, attach an event listener to the button and call an api endpoint. In any case, the portal is due for some updating, and I suspect we’ll see movement in that direction as Frappe’s vue-based architecture continues to grow.
Ah, yes, you’re right. I guess if I try and use a docfrield of type Check I might have more success. However I suspect that the Web View will only render the current value of the Check rather than giving me a Checkbox for the user to interact with.
I’m leaning more towards a custom Portal Page to achieve my use-case, even though the Web View is so close to what I need. I’ll try that and report back.
As a matter of interest, the use-case is applicable to any form of menu / item selection by a registered user. Examples are:
Library Management where the Library Member can select their article(s) on a portal rather than having to utilize Desk with a Form View to a DocType such as Article Selection.
An organisation having an in-house canteen, allowing staff to select Menu Items without giving all staff access to Desk.
If anyone has built such an interface, then please assist me with your thoughts.
I’ve built pages for the kind of use-case you’re describing, targeting web users. Jinja is definitely not designed for client-side interactivity. For that, you definitely want to be using a client-side approach, whether that’s vanilla javascript or Vue/FrappeUI. What you’re describing can definitely be done, though!
Very possibly; it certainly seems to be within the scope of the design goals. I haven’t had a chance to test at all yet, though. Perhaps others with more experience can chime in.
We recently started a pilot project with Frappe Framework. As part of the project we used Builder app to create a few pages. We were able to explore the following few aspects.
Routes - Static and dynamic
Buttons - to trigger page navigations and API calls
Client scripts - to render dynamic content on the screen or add view level validations.
Data scripts - to fetch and store the data to the database. Call methods from the doctype controllers
Components - create common components for reusability e.g. headers and footers.
There is a certain learning for sure; once learnt it can prove to be a useful tool to build simple pages on the fly.
It has a means to build screens for different screen sizes which we are yet to explore.
The screen the OP wants to create can easily be done with builder.
P.S. We started exploring builder app only from past 15 - 20 days.
Have you made progress with Frappe Builder?
Can it be used to create forms to capture input which is then scripted to populate a DocType, in other words create a document.
I presume the form (built by Frappe Builder or not) has to be part of the Portal mechanism of the Frappe Framework.
The alternative is to create a custom Web Form, but this approach does not readily provide user logon / authorisation as my understanding is that web forms are open to the public at large. But maybe (hopefully) I’m wrong?