Skip to content

Commit aafb564

Browse files
authored
Merge pull request #3 from eea/develop
Develop
2 parents 5fea8b8 + 7b5a8ef commit aafb564

File tree

11 files changed

+498
-206
lines changed

11 files changed

+498
-206
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d
44

55
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66

7+
#### [0.1.2](https://github.com/eea/volto-react-table-widget/compare/0.1.1...0.1.2)
8+
9+
- add locales [`2f58aae`](https://github.com/eea/volto-react-table-widget/commit/2f58aaea28c038c4d48d54d1700e7539cc7d42f8)
10+
- add undomodifications parameter to get the Undo Modifications button optional [`b2ebb03`](https://github.com/eea/volto-react-table-widget/commit/b2ebb034827f8605ad37f51b215e2a9bada58c5a)
11+
- add schemas title and description to editor [`2250b88`](https://github.com/eea/volto-react-table-widget/commit/2250b888eb060c10c2ff1ab577810532c8476fb8)
12+
- refactoring code [`99a3dc7`](https://github.com/eea/volto-react-table-widget/commit/99a3dc715d4cdacec9cbf5187fb2238d396ae708)
13+
- prettier [`a424381`](https://github.com/eea/volto-react-table-widget/commit/a424381fbb1899bd5a561f7ce3d16820d5af00db)
14+
- date type widget [`7ee1486`](https://github.com/eea/volto-react-table-widget/commit/7ee1486d3f647a57fa05576538b035b98926b821)
15+
716
#### [0.1.1](https://github.com/eea/volto-react-table-widget/compare/0.1.0...0.1.1)
817

18+
> 16 March 2022
19+
920
- fix tag [`1477105`](https://github.com/eea/volto-react-table-widget/commit/1477105ee567c1daed09bb3ce1819a20a1da024e)
1021

1122
#### 0.1.0

Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ pipeline {
184184
unstash "xunit-reports"
185185
unstash "cypress-coverage"
186186
def scannerHome = tool 'SonarQubeScanner';
187-
def nodeJS = tool 'NodeJS11';
187+
def nodeJS = tool 'NodeJS';
188188
withSonarQubeEnv('Sonarqube') {
189189
sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
190-
sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
190+
sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
191191
sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
192192
}
193193
}

locales/en/LC_MESSAGES/volto.po

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
msgid ""
2+
msgstr ""
3+
"Project-Id-Version: \n"
4+
"Report-Msgid-Bugs-To: \n"
5+
"POT-Creation-Date: \n"
6+
"PO-Revision-Date: \n"
7+
"Last-Translator: \n"
8+
"Language: \n"
9+
"Language-Team: \n"
10+
"Content-Type: \n"
11+
"Content-Transfer-Encoding: \n"
12+
"Plural-Forms: \n"
13+
14+
#: components/Widgets/ReactTableWidget
15+
# defaultMessage: CSV file imported correctly
16+
msgid "CSV file imported correctly"
17+
msgstr ""
18+
19+
#: components/Widgets/ReactTableWidget
20+
# defaultMessage: Export CSV file
21+
msgid "Export CSV file"
22+
msgstr ""
23+
24+
#: components/Widgets/ReactTableWidget
25+
# defaultMessage: Import CSV file
26+
msgid "Import CSV file"
27+
msgstr ""
28+
29+
#: components/Widgets/ReactTableWidget
30+
# defaultMessage: {count} new items imported
31+
msgid "Imported item count"
32+
msgstr ""
33+
34+
#: components/Widgets/ReactTableWidget
35+
# defaultMessage: {count} items modified
36+
msgid "Modified item count"
37+
msgstr ""
38+
39+
#: components/Widgets/ReactTableWidget
40+
# defaultMessage: Undo
41+
msgid "Undo"
42+
msgstr ""
43+
44+
#: components/Widgets/ReactTableWidget
45+
# defaultMessage: Undo all modifications
46+
msgid "Undo all modifications"
47+
msgstr ""
48+
49+
#: components/Widgets/ReactTableWidget
50+
# defaultMessage: Undo message
51+
msgid "Undo message"
52+
msgstr "All modifications has been undone"

locales/es/LC_MESSAGES/volto.po

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
msgid ""
2+
msgstr ""
3+
"Project-Id-Version: \n"
4+
"Report-Msgid-Bugs-To: \n"
5+
"POT-Creation-Date: \n"
6+
"PO-Revision-Date: \n"
7+
"Last-Translator: \n"
8+
"Language: \n"
9+
"Language-Team: \n"
10+
"Content-Type: \n"
11+
"Content-Transfer-Encoding: \n"
12+
"Plural-Forms: \n"
13+
14+
#: components/Widgets/ReactTableWidget
15+
# defaultMessage: CSV file imported correctly
16+
msgid "CSV file imported correctly"
17+
msgstr "Fichero CSV importado correctamente"
18+
19+
#: components/Widgets/ReactTableWidget
20+
# defaultMessage: Export CSV file
21+
msgid "Export CSV file"
22+
msgstr "Exportar fichero CSV"
23+
24+
#: components/Widgets/ReactTableWidget
25+
# defaultMessage: Import CSV file
26+
msgid "Import CSV file"
27+
msgstr "Importar fichero CSV"
28+
29+
#: components/Widgets/ReactTableWidget
30+
# defaultMessage: {count} new items imported
31+
msgid "Imported item count"
32+
msgstr "{count} nuevos items importados"
33+
34+
#: components/Widgets/ReactTableWidget
35+
# defaultMessage: {count} items modified
36+
msgid "Modified item count"
37+
msgstr "{count} items modificados"
38+
39+
#: components/Widgets/ReactTableWidget
40+
# defaultMessage: Undo
41+
msgid "Undo"
42+
msgstr "Deshacer"
43+
44+
#: components/Widgets/ReactTableWidget
45+
# defaultMessage: Undo all modifications
46+
msgid "Undo all modifications"
47+
msgstr "Deshacer todas las modificaciones"
48+
49+
#: components/Widgets/ReactTableWidget
50+
# defaultMessage: Undo message
51+
msgid "Undo message"
52+
msgstr "Se han deshecho todas las modificaciones realizadas"

locales/eu/LC_MESSAGES/volto.po

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
msgid ""
2+
msgstr ""
3+
"Project-Id-Version: \n"
4+
"Report-Msgid-Bugs-To: \n"
5+
"POT-Creation-Date: \n"
6+
"PO-Revision-Date: \n"
7+
"Last-Translator: \n"
8+
"Language: \n"
9+
"Language-Team: \n"
10+
"Content-Type: \n"
11+
"Content-Transfer-Encoding: \n"
12+
"Plural-Forms: \n"
13+
14+
#: components/Widgets/ReactTableWidget
15+
# defaultMessage: CSV file imported correctly
16+
msgid "CSV file imported correctly"
17+
msgstr "CSV fitxategia ongi inportatu da"
18+
19+
#: components/Widgets/ReactTableWidget
20+
# defaultMessage: Export CSV file
21+
msgid "Export CSV file"
22+
msgstr "Exportatu CSV fitxategia"
23+
24+
#: components/Widgets/ReactTableWidget
25+
# defaultMessage: Import CSV file
26+
msgid "Import CSV file"
27+
msgstr "Inportatu CSV fitxategia"
28+
29+
#: components/Widgets/ReactTableWidget
30+
# defaultMessage: {count} new items imported
31+
msgid "Imported item count"
32+
msgstr "{count} elementu berri inportatu dira"
33+
34+
#: components/Widgets/ReactTableWidget
35+
# defaultMessage: {count} items modified
36+
msgid "Modified item count"
37+
msgstr "{count} elementu aldatu dira"
38+
39+
#: components/Widgets/ReactTableWidget
40+
# defaultMessage: Undo
41+
msgid "Undo"
42+
msgstr "Desegin"
43+
44+
#: components/Widgets/ReactTableWidget
45+
# defaultMessage: Undo all modifications
46+
msgid "Undo all modifications"
47+
msgstr "Desegin aldaketa guztiak"
48+
49+
#: components/Widgets/ReactTableWidget
50+
# defaultMessage: Undo message
51+
msgid "Undo message"
52+
msgstr "Aldaketa guztiak desegin dira"

locales/volto.pot

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
msgid ""
2+
msgstr ""
3+
"Project-Id-Version: Plone\n"
4+
"POT-Creation-Date: 2022-05-19T09:08:53.014Z\n"
5+
"Last-Translator: Plone i18n <[email protected]>\n"
6+
"Language-Team: Plone i18n <[email protected]>\n"
7+
"MIME-Version: 1.0\n"
8+
"Content-Type: text/plain; charset=utf-8\n"
9+
"Content-Transfer-Encoding: 8bit\n"
10+
"Plural-Forms: nplurals=1; plural=0;\n"
11+
"Language-Code: en\n"
12+
"Language-Name: English\n"
13+
"Preferred-Encodings: utf-8\n"
14+
"Domain: volto\n"
15+
16+
#: components/Widgets/ReactTableWidget
17+
# defaultMessage: CSV file imported correctly
18+
msgid "CSV file imported correctly"
19+
msgstr ""
20+
21+
#: components/Widgets/ReactTableWidget
22+
# defaultMessage: Export CSV file
23+
msgid "Export CSV file"
24+
msgstr ""
25+
26+
#: components/Widgets/ReactTableWidget
27+
# defaultMessage: Import CSV file
28+
msgid "Import CSV file"
29+
msgstr ""
30+
31+
#: components/Widgets/ReactTableWidget
32+
# defaultMessage: {count} new items imported
33+
msgid "Imported item count"
34+
msgstr ""
35+
36+
#: components/Widgets/ReactTableWidget
37+
# defaultMessage: {count} items modified
38+
msgid "Modified item count"
39+
msgstr ""
40+
41+
#: components/Widgets/ReactTableWidget
42+
# defaultMessage: Undo
43+
msgid "Undo"
44+
msgstr ""
45+
46+
#: components/Widgets/ReactTableWidget
47+
# defaultMessage: Undo all modifications
48+
msgid "Undo all modifications"
49+
msgstr ""
50+
51+
#: components/Widgets/ReactTableWidget
52+
# defaultMessage: Undo message
53+
msgid "Undo message"
54+
msgstr ""

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eeacms/volto-react-table-widget",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "@eeacms/volto-react-table-widget: Volto add-on",
55
"main": "src/index.js",
66
"author": "European Environment Agency: CLMS Team",
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { useSelector } from 'react-redux';
2+
import React from 'react';
3+
import { normalizeValue } from '@plone/volto/components/manage/Widgets/SelectUtils';
4+
import { useIntl } from 'react-intl';
5+
import moment from 'moment';
6+
import { getFieldType, getOnChange, getValue, getValueToRender } from './utils';
7+
8+
export const EditableCell = ({
9+
value: initialValue,
10+
row: { index },
11+
column: { id },
12+
updateCell, // This is a custom function that we supplied to our table instance
13+
selectedRow,
14+
setSelectedRow,
15+
schema,
16+
reactSelect,
17+
state: { pageIndex, pageSize },
18+
}) => {
19+
const fieldSchema = { ...schema?.properties?.[id], id: id };
20+
const locale = useSelector((state) => state.intl.locale);
21+
moment.locale(locale);
22+
23+
const [value, setValue] = React.useState(initialValue);
24+
25+
const onBlur = () => {
26+
updateCell(index, id, value);
27+
};
28+
29+
React.useEffect(() => {
30+
setValue(initialValue);
31+
}, [initialValue]);
32+
const { choices, defaultValue, isMulti } = fieldSchema;
33+
const intl = useIntl();
34+
const fieldType = getFieldType(fieldSchema, reactSelect);
35+
const Field = fieldType.Field;
36+
const normalizedValue = normalizeValue(choices, value, intl);
37+
const onChangeFunction = getOnChange(fieldType.type, setValue);
38+
return selectedRow === index ? (
39+
<Field
40+
{...fieldType.properties}
41+
value={getValue(fieldType.type, value, defaultValue, normalizedValue)}
42+
onChange={(...args) => onChangeFunction({ ...args, isMulti: isMulti })}
43+
onBlur={onBlur}
44+
/>
45+
) : (
46+
<span
47+
role="button"
48+
className="editable-cell"
49+
tabIndex={0}
50+
onClick={() => {
51+
setSelectedRow(index);
52+
}}
53+
onKeyDown={() => {
54+
setSelectedRow(index);
55+
}}
56+
onFocus={() => {
57+
setSelectedRow(index);
58+
}}
59+
>
60+
{getValueToRender(fieldType, value, moment)}
61+
</span>
62+
);
63+
};

0 commit comments

Comments
 (0)