2023-09-22 21:50:55 +02:00
|
|
|
## Widgets
|
|
|
|
|
|
|
|
Widgets are the building blocks of our UI.
|
2023-09-22 23:03:37 +02:00
|
|
|
We are currently making all our
|
2023-09-22 21:50:55 +02:00
|
|
|
widgets [WebComponents](https://developer.mozilla.org/en-US/docs/Web/API/Web_components)
|
2023-09-22 23:03:37 +02:00
|
|
|
based on [Lit](https://lit.dev/docs/). Many of our widgets use [Shoelace](https://shoelace.style) components as building
|
|
|
|
blocks.
|
2023-09-22 21:50:55 +02:00
|
|
|
|
2023-09-22 23:03:37 +02:00
|
|
|
If you just want to use existing widgets, you can put them in your .xet template file:
|
2023-09-22 21:50:55 +02:00
|
|
|
|
|
|
|
```xml
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2.0//EN" "https://www.egroupware.org/etemplate2.0.dtd">
|
|
|
|
<overlay>
|
|
|
|
<template id="myapp.mytemplate">
|
|
|
|
<et2-vbox>
|
|
|
|
<et2-textbox id="name" label="Your name" class="et2-label-fixed"></et2-textbox>
|
|
|
|
<et2-select-number id="quantity" label="Quantity" class="et2-label-fixed"></et2-select-number>
|
|
|
|
</et2-vbox>
|
|
|
|
</template>
|
|
|
|
</overlay>
|
|
|
|
```
|
|
|
|
|
2024-12-12 19:07:57 +01:00
|
|
|
<img src="/assets/images/widgets_rendered_example.png" alt="Rendered example template">
|
|
|
|
|
|
|
|
## Attributes
|
|
|
|
|
|
|
|
Widget behaviour is customised by setting attributes
|
|
|
|
|
|
|
|
### ID
|
|
|
|
|
|
|
|
// TODO, maybe some notes about content & namespaces.
|
|
|
|
|
|
|
|
### Disabled vs Readonly vs Hidden
|
|
|
|
|
2024-12-13 16:42:29 +01:00
|
|
|
Disabled widgets are fully shown, but in a way that indicates the value cannot be changed. Use disabled to indicate that
|
|
|
|
at some point a user may be able to change the value, but not right now. The widget may be enabled via javascript.
|
2024-12-12 19:07:57 +01:00
|
|
|
|
|
|
|
Readonly widgets are shown in a special way that displays a value, but is not interactive. Often we switch to a
|
|
|
|
different component for faster performance, such as a simple
|
2024-12-13 16:42:29 +01:00
|
|
|
label. It is impossible to change the value of a readonly widget, and it cannot be made editable via javascript - the
|
|
|
|
page must be reloaded.
|
2024-12-12 19:07:57 +01:00
|
|
|
|
2024-12-13 16:42:29 +01:00
|
|
|
Hidden widgets are not visible, but may be enabled via javascript.
|
2024-12-12 19:07:57 +01:00
|
|
|
|
|
|
|
```html:preview
|
2024-12-13 16:42:29 +01:00
|
|
|
<table>
|
|
|
|
<tr><td>Normal</td><td><et2-textbox value="Normal textbox" class="et2-label-fixed"></et2-textbox></td><td><et2-button label="Button"></et2-button></td></tr>
|
|
|
|
<tr><td>Disabled</td><td><et2-textbox disabled value="Disabled textbox" class="et2-label-fixed"></et2-textbox></td><td><et2-button label="Button" disabled></et2-button></td></tr>
|
|
|
|
<tr><td>Readonly</td><td><et2-textbox_ro value="Readonly textbox" class="et2-label-fixed"></et2-textbox_ro></td><td><et2-buttton disabled label="Button" readonly></et2-button></td></tr>
|
|
|
|
<tr><td>Hidden</td><td><et2-textbox hidden>Hidden textbox</et2-textbox></td><td><et2-button label="Hidden" hidden></et2-button></td></tr>
|
|
|
|
</table>
|
|
|
|
```
|
|
|
|
|
|
|
|
When the page is submitted normal and hidden widgets will have their values returned and validated. Widgets that are
|
|
|
|
disabled when the page is submitted will not return their value.
|
|
|
|
Readonly widgets do not return a value.
|