Implementing a Create Feature
Adding New Products to Firestore
Displaying Product List Information in a Table
- Click [Create] in [Dataflows] and change the dataflow name to
listProducts
. - Select
Onboarding Firebase
as the data source. - Choose
List documents
in [Action] and enterproducts
in [Collection]. - Click [Run].
- Place a [Table] and enter
{{ listProducts.data }}
in the editor's [Data].
Placing Components for Adding Products
- Place a [Column].
- On the left side of the [Column], place the previously positioned [Table], and on the right side, place two **[Input]**s, one [Select], one [Text Area], and one [Button].
- In the editor of the components on the right side of the column, enter
id
,title
,category
,description
, andAdd Product
respectively for [input1], [input2], [select1], [textarea1], and [button1]. - Adjust the width of the [Column].
Fetching Product Category List with a Dataflow and Displaying it in Select
- Click [Create] in [Dataflows] and change the dataflow name to
listCategories
. - Select
Onboarding Firebase
as the data source. - Choose
List documents
in [Action] and entercategories
in [Collection]. - Click [Run].
- Place a [Select].
- Open the editor for the [Select] and enter
{{ listCategories.data.map(d => d.id) }}
in [Values]. - Enter
{{ listCategories.data.map(d => d.name) }}
in [Labels].
Creating a Dataflow to Add Products and Linking it to the Button
- Click [Create] in [Dataflows] and change the dataflow name to
createProduct
. - Select
Onboarding Firebase
as the data source. - Choose
Set document
in [Action] and enterproducts
in [Collection]. - Enter the following in [Data]:
{
"id": {{ input1.value }},
"title": {{ input2.value }},
"category": {{ select1.value }},
"description": {{ textarea1.value }}
}
- Select [button1], click [Add], and select
createProduct
in [Dataflow].
Disabling the Button if There Are Empty Fields
- Select [button1] and enter
{{ !input1.value || input2.value === '' || select1.value === '' || textarea1.value === '' }}
in [Disabled].