Working with the screens
In this step we already have enough artifacts to see some results being rendered, let's see how to work with them now
Last updated
Was this helpful?
In this step we already have enough artifacts to see some results being rendered, let's see how to work with them now
Last updated
Was this helpful?
If we access http://localhost:8080/#/dashboard/general/category
it will be possible to see the screen that displays theCategory
entitytable
that we created (assuming that no changes were made to what comes by default in the project). Below is an image of the result that can be seen after opening the link above.
As we can see, the screen was empty and an error was generated on the console.
The screen is empty because our field is still visible in thetable
(in addition to not having a definedlabel
) and we don't have anAPI
to be consumed. We will see how to improve this in the following topics.
It is possible to notice that several resources are already created by default, buttons, search field and an advanced side search comes by default when we create atable
using the component that is built into the project. Below we will see details about them. If you still have questions, go to the Concepts section.
schema
Theschemes
are structures that have several resources to be configured, we will configure some below. To see all theschema
settings go to the Schema page.
To load the texts from the fields, isolated files are used with the messages to be written. Create a file namedpt-br.js
in the domain folder (src/domains/General/Category/pt-br.js
) with the necessary basic messages. Note that we are using a property calledSCOPES
to define some properties, see more about it here.
We are using this name because of the configuration that is in.env
.
After creating the file we need to register it in the message file in thelang/
directory. For that we can accesssrc/lang/pt-br/domains.js
and add it there. The result will look something like the excerpt below.
table
As seen above, the table listing Category records is available at the URL http://localhost:8080/#/dashboard/general/category
.
To display a field in thetable
, we can call thefieldTableShow
method.
With the internationalization defined and the field configured to be visible, we can see that the application screen now shows the "Name" field.
The table has an area for advanced search, to put the field to appear in this area we can use thefieldTableWhere
method.
The result will be something like the image below.
To simulate a data set in thetable
, we can modify theCategoryService
to generatefake
data. Below is an example of what an override of thepaginate
method would look like to generate data to show false data and popularize the list of records. In a real environment, thefetch records
system is adapted to deal with the responses of the API that is consumed.
So now we can see the data being displayed on the screen.
Visit the Project Settings page to learn more about how to configure the communication part
form
The sameschema
that we saw that you can configure thetable
will also be responsible for the definitions of theforms
. We can view the form that creates a record inhttp://localhost:8080/#/dashboard/general/category/add
.
The Name field is being displayed because every time we useaddField
, unlike thetable
, theform
by default will display the field. To hide the field we need to use thefieldFormHidden
method. The text field is displayed because it is the standard component for a field that is added. ThefieldIsInput
method is a method that is called implicitly when no component is defined.
It is possible to pass aboolean
argument to thefieldFormHidden
method to determine whether it will behidden
or not, the default is true. Following with the possibilities we can define that the field should receive the focus on the loading, its width or if it is mandatory or not.
The above changes will make the form look like this.
Among the details we have that thewidth
parameter of thefieldFormWidth
method corresponds to the width of the field on the screen and can receive values between 1 and 100 that correspond to the percentage of the line that will be occupied by the field. The default for this property is 100, which is why the first time the form was opened, the field was occupying the entire line and in the image above it occupies only half of it. ThevalidationRequired
method, in turn, makes the field mandatory. If we click on the SAVE button, the result will be the following image.
The base validation lib that is used is Vuelidate, so all validation definitions available in the lib are available in the schema.
With the excerpt above we achieved something like what can be seen below.
Following this same dynamic, we can add more fields and configure them using the methods available in theSchema
class or simply creating our own methods.