In the previous section on data models, we saw how to create tables consisting of fields and rows.
In this section, we will see how to build user interfaces which take data from these models to display to the user.
For example, we might have a table of club members. Each row in the table will contain the information in the fields
Saltcorn uses two distinct concepts which work together to create the whole user interface:
Views are specific ways to display your the data from your table.
On a member's account page you might want to let users see all the infomation you have about them, but only edit their username and avatar.
On the meeting page you might want to display all the members that attended on that date.
On an admin page you might want to edit the fees paid.
View templates include
Menu > Views > Create View
See Creating Views for more details.
If this all seems a little abstract, here are some examples of what we mean by view templates capturing interaction patterns:
View templates can also be provided by plug-ins. View templates are completely independent from field views, in that a view template should be able to incorporate a field shown as any field value, even if it comes from a different plug-in developed without any considerations for compatibility between different field views and different view templates.
Every field in a table is assigned a specific type. For instance, a name will be of type String, date of birth will be of type date, and age will be of type Integer.
Field views control how individual values of particular types are shown to the user. This can be to either Show or Edit the value. The field view is the way the value of a particular type will be displayed. It is at the user level that we decide if the user can edit or just see the value of the field.
When a field is a date, there are many possible field views. A date can be
When you need to choose a field view, Saltcorn gives you only choices that are applicable.
Some field views also have options, for example:
Field views can be provided by plugins. Plugins can also provide new field views for types that are defined in Saltcorn core or in other plug-ins.
Some view templates are based on underlying views. This gives an enormous flexibility in how user interfaces can be constructed. A simple example is the Feed view template, which displays a number of rows from a database table, one after another or in columns. The feed view template handles how the numerous rows are joined together in the display, but delegates the display of the individuals rose to an underlying view, typically a view of the show view template. Therefore, to build a user interface based on feeds (such as you might see on a social network, with one post after another). You first build the view of each individual row using the Show view template, and then you build the Feed view, choosing the previously built Show view as the underlying view. When you finally have a working Feed view of multiple rows, you typically want to go back and adjust the Show view to get the overall user interface right.