data-display/README.md

79 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2021-09-24 22:56:34 +02:00
# Data display
2021-08-13 12:07:00 +02:00
2021-09-24 22:56:34 +02:00
Data display for LiberaForms developed with https://vue-loader.vuejs.org/
2021-08-13 14:17:51 +02:00
2021-09-24 22:56:34 +02:00
## Why
2021-09-24 23:51:07 +02:00
LiberaForms collects data solicited via forms. It is not easy or practical to display such data with **tables** because the number of columns and the text length of the column headers and fields are unknown. This Vue component displays data in various ways (modes). It is used to display:
2021-09-24 22:56:34 +02:00
* The list of a user's forms (My forms)
* The answers to each individual form
* The list of all forms (admin)
* The list of all users (admin)
* A user's forms (admin)
## The Panel
2021-09-24 23:51:07 +02:00
Data display begins with a `control panel` that includes functions according to the data being displayed.
2021-09-24 22:56:34 +02:00
* Export and links to other visualizations
2021-10-02 16:29:33 +02:00
* Filters. Search, Order by, Ascending.
2021-09-24 23:51:07 +02:00
* Column order. Move any column to the first column position.
* Modes. Grid, Expanded, Cards, Edit mode
2021-09-24 22:56:34 +02:00
* Pagination
## Modes
2021-09-24 23:51:07 +02:00
Modes provide different ways to visualize the same data
2021-09-24 22:56:34 +02:00
2021-09-24 23:51:07 +02:00
### Grid (table)
2021-10-02 16:29:33 +02:00
* Each row begins with 'control column' that includes a `mark` button, and an `edit` button (if fields are editable).
* Column widths are evenly spaced if they all fit within the table width, and if not...
2021-09-24 23:51:07 +02:00
* Column widths are evenly spaced and the first column becomes `sticky`. Cell content is ellipsed, and table overflow is hidden.
2021-09-24 22:56:34 +02:00
### Expanded (cards)
2021-09-24 23:51:07 +02:00
The Expanded mode displays each row as a card. The title of the card is the Grid's control column and first data column, but also include an expand/collapse button.
2021-09-24 22:56:34 +02:00
### Small Cards
2021-10-02 16:29:33 +02:00
Rendered when small screens are detected. This mode is the same as the Expanded mode except that cards are initially collapsed, and the panel can be toggled.
2021-08-13 14:17:51 +02:00
2021-09-24 23:51:07 +02:00
## Data inspection
Every field is clickable. A modal is displayed containing the entire field value. If the field is editable it can be edited via a form element. The form is built using the same element (select, textarea, etc) as initially defined with the LiberaForms' Form builder.
## User preferences
2021-10-02 16:29:33 +02:00
Defining filters, data order and column order makes consulting the data easier. These preferences are saved to the database and recovered when the user returns to read that same data.
2021-09-24 23:51:07 +02:00
## Exports
* **PDF**: Exports filtered items with various options. Font size, page size, etc.
* **JSON**: Exports filtered items in JSON
2021-09-24 23:51:07 +02:00
2021-08-13 14:17:51 +02:00
## Usage
```
2021-09-24 22:56:34 +02:00
<link rel="stylesheet" href="/static/data-display/data-display.css">
2021-08-14 14:02:26 +02:00
2021-09-24 22:56:34 +02:00
<div data-vue-component="data-display"
data-endpoint="/data-display/my-forms/{{g.current_user.id}}"
data-language="{{ g.current_user.language }}"
2021-08-13 20:18:01 +02:00
data-csrf_token="{{ csrf_token() }}">
2021-08-13 14:17:51 +02:00
</div>
<script src="/static/data-display/data-display.js"></script>
2021-09-24 22:56:34 +02:00
```
# Development
2021-08-13 14:17:51 +02:00
```
2021-09-24 22:56:34 +02:00
npm run build
```
We then copy the generated `data-display.js` file to the `/static/data-display/` directory of LiberaForms server project.
2021-09-24 23:51:07 +02:00
You may also wish to read the backend code at `/liberaforms/views/data_display.py`