@@ -20,9 +20,137 @@ The widget can be used like Volto's [ObjectListWidget](https://docs.voltocms.com
2020
2121It also provides a CSV import and export functionality using the powerwful [ react-papaparse] ( https://www.npmjs.com/package/react-papaparse ) library.
2222
23+ ## How to use it
24+
25+ This widget have to be configured like Volto's ObjectListWidget:
26+
27+ - You need to define a schema which will be used to create the table headings. Example:
28+
29+ ``` jsx
30+
31+ const ItemSchema = () => ({
32+ title: ' Downloadable File' ,
33+ properties: {
34+ title: {
35+ title: ' Title' ,
36+ description: ' Enter the title of this file.' ,
37+ type: ' string' ,
38+ },
39+ file: {
40+ title: ' File name' ,
41+ description: ' Enter the file name.' ,
42+ type: ' string' ,
43+ },
44+ area: {
45+ title: ' Area of interest' ,
46+ description: ' Enter the area of this file.' ,
47+ type: ' string' ,
48+ },
49+ year: {
50+ title: ' Year' ,
51+ description: ' Enter the year of this file.' ,
52+ type: ' number' ,
53+ minimum: 1900 ,
54+ },
55+ version: {
56+ title: ' Version' ,
57+ description: ' Enter the version of this file.' ,
58+ type: ' string' ,
59+ },
60+ resolution: {
61+ title: ' Resolution' ,
62+ description: ' Enter the resolution of this file. Ex.: 100m' ,
63+ type: ' string' ,
64+ },
65+ type: {
66+ title: ' Type' ,
67+ description: ' Enter the file type of this file. Ex.: Raster or Vector' ,
68+ choices: [
69+ [' Raster' , ' Raster' ],
70+ [' Vector' , ' Vector' ],
71+ ],
72+ },
73+ format: {
74+ title: ' Format' ,
75+ description: ' Enter the format of this file.' ,
76+ type: ' string' ,
77+ },
78+ size: {
79+ title: ' Size' ,
80+ description: ' Enter the size of this file. Ex.: 3.5 GB' ,
81+ type: ' string' ,
82+ },
83+ path: {
84+ title: ' Path' ,
85+ description: ' Enter the absolute path of this file in the storage' ,
86+ type: ' string' ,
87+ },
88+ source: {
89+ title: ' Source' ,
90+ description: ' Enter the source of this file (this is an internal).' ,
91+ choices: [
92+ [' EEA' , ' EEA' ],
93+ [' HOTSPOTS' , ' HOTSPOTS' ],
94+ ],
95+ },
96+ },
97+ fieldsets: [
98+ {
99+ id: ' default' ,
100+ title: ' File' ,
101+ fields: [
102+ ' title' ,
103+ ' file' ,
104+ ' area' ,
105+ ' year' ,
106+ ' version' ,
107+ ' resolution' ,
108+ ' type' ,
109+ ' format' ,
110+ ' size' ,
111+ ' path' ,
112+ ' source' ,
113+ ],
114+ },
115+ ],
116+ required: [],
117+ });
118+ ```
119+
120+ - You need to configure your content type's schema to use it.
121+
122+ ``` jsx
123+ import React from ' react' ;
124+ import { ReactTableWidget } from ' @eeacms/volto-react-table-widget' ;
125+
126+ const DownloadableFilesTableWidget = (props ) => {
127+ return (
128+ < ReactTableWidget
129+ schema= {ItemSchema ()}
130+ {... props}
131+ csvexport= {true }
132+ csvimport= {true }
133+ value= {props .value ? .items || props .default ? .items || []}
134+ onChange= {(id , value ) => props .onChange (id, { items: value })}
135+ / >
136+ );
137+ };
138+
139+ export default DownloadableFilesTableWidget ;
140+ ` ` `
141+
142+ You can enable/disable the CSV import and export passing the relevant parameter to the widget.
143+
23144## Features
24145
25- Demo GIF
146+ 
147+
148+ [Video2](https://github.com/erral/volto-react-table-widget-talk/blob/main/public/2-fast.mp4)
149+
150+ [Video3](https://github.com/erral/volto-react-table-widget-talk/blob/main/public/3-fast.mp4)
151+
152+ [Video4](https://github.com/erral/volto-react-table-widget-talk/blob/main/public/4-fast.mp4)
153+
26154
27155## Getting started
28156
0 commit comments