Skip to content

Commit

Permalink
Merge pull request #3 from eea/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
libargutxi authored Jun 3, 2022
2 parents 5fea8b8 + 7b5a8ef commit aafb564
Show file tree
Hide file tree
Showing 11 changed files with 498 additions and 206 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d

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

#### [0.1.2](https://github.com/eea/volto-react-table-widget/compare/0.1.1...0.1.2)

- add locales [`2f58aae`](https://github.com/eea/volto-react-table-widget/commit/2f58aaea28c038c4d48d54d1700e7539cc7d42f8)
- add undomodifications parameter to get the Undo Modifications button optional [`b2ebb03`](https://github.com/eea/volto-react-table-widget/commit/b2ebb034827f8605ad37f51b215e2a9bada58c5a)
- add schemas title and description to editor [`2250b88`](https://github.com/eea/volto-react-table-widget/commit/2250b888eb060c10c2ff1ab577810532c8476fb8)
- refactoring code [`99a3dc7`](https://github.com/eea/volto-react-table-widget/commit/99a3dc715d4cdacec9cbf5187fb2238d396ae708)
- prettier [`a424381`](https://github.com/eea/volto-react-table-widget/commit/a424381fbb1899bd5a561f7ce3d16820d5af00db)
- date type widget [`7ee1486`](https://github.com/eea/volto-react-table-widget/commit/7ee1486d3f647a57fa05576538b035b98926b821)

#### [0.1.1](https://github.com/eea/volto-react-table-widget/compare/0.1.0...0.1.1)

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

#### 0.1.0
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ pipeline {
unstash "xunit-reports"
unstash "cypress-coverage"
def scannerHome = tool 'SonarQubeScanner';
def nodeJS = tool 'NodeJS11';
def nodeJS = tool 'NodeJS';
withSonarQubeEnv('Sonarqube') {
sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
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"
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"
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'''
}
}
Expand Down
52 changes: 52 additions & 0 deletions locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language: \n"
"Language-Team: \n"
"Content-Type: \n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#: components/Widgets/ReactTableWidget
# defaultMessage: CSV file imported correctly
msgid "CSV file imported correctly"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Export CSV file
msgid "Export CSV file"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Import CSV file
msgid "Import CSV file"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} new items imported
msgid "Imported item count"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} items modified
msgid "Modified item count"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo
msgid "Undo"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo all modifications
msgid "Undo all modifications"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo message
msgid "Undo message"
msgstr "All modifications has been undone"
52 changes: 52 additions & 0 deletions locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language: \n"
"Language-Team: \n"
"Content-Type: \n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#: components/Widgets/ReactTableWidget
# defaultMessage: CSV file imported correctly
msgid "CSV file imported correctly"
msgstr "Fichero CSV importado correctamente"

#: components/Widgets/ReactTableWidget
# defaultMessage: Export CSV file
msgid "Export CSV file"
msgstr "Exportar fichero CSV"

#: components/Widgets/ReactTableWidget
# defaultMessage: Import CSV file
msgid "Import CSV file"
msgstr "Importar fichero CSV"

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} new items imported
msgid "Imported item count"
msgstr "{count} nuevos items importados"

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} items modified
msgid "Modified item count"
msgstr "{count} items modificados"

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo
msgid "Undo"
msgstr "Deshacer"

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo all modifications
msgid "Undo all modifications"
msgstr "Deshacer todas las modificaciones"

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo message
msgid "Undo message"
msgstr "Se han deshecho todas las modificaciones realizadas"
52 changes: 52 additions & 0 deletions locales/eu/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language: \n"
"Language-Team: \n"
"Content-Type: \n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#: components/Widgets/ReactTableWidget
# defaultMessage: CSV file imported correctly
msgid "CSV file imported correctly"
msgstr "CSV fitxategia ongi inportatu da"

#: components/Widgets/ReactTableWidget
# defaultMessage: Export CSV file
msgid "Export CSV file"
msgstr "Exportatu CSV fitxategia"

#: components/Widgets/ReactTableWidget
# defaultMessage: Import CSV file
msgid "Import CSV file"
msgstr "Inportatu CSV fitxategia"

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} new items imported
msgid "Imported item count"
msgstr "{count} elementu berri inportatu dira"

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} items modified
msgid "Modified item count"
msgstr "{count} elementu aldatu dira"

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo
msgid "Undo"
msgstr "Desegin"

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo all modifications
msgid "Undo all modifications"
msgstr "Desegin aldaketa guztiak"

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo message
msgid "Undo message"
msgstr "Aldaketa guztiak desegin dira"
54 changes: 54 additions & 0 deletions locales/volto.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
msgid ""
msgstr ""
"Project-Id-Version: Plone\n"
"POT-Creation-Date: 2022-05-19T09:08:53.014Z\n"
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"Language-Code: en\n"
"Language-Name: English\n"
"Preferred-Encodings: utf-8\n"
"Domain: volto\n"

#: components/Widgets/ReactTableWidget
# defaultMessage: CSV file imported correctly
msgid "CSV file imported correctly"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Export CSV file
msgid "Export CSV file"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Import CSV file
msgid "Import CSV file"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} new items imported
msgid "Imported item count"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: {count} items modified
msgid "Modified item count"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo
msgid "Undo"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo all modifications
msgid "Undo all modifications"
msgstr ""

#: components/Widgets/ReactTableWidget
# defaultMessage: Undo message
msgid "Undo message"
msgstr ""
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-react-table-widget",
"version": "0.1.1",
"version": "0.1.2",
"description": "@eeacms/volto-react-table-widget: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: CLMS Team",
Expand Down
63 changes: 63 additions & 0 deletions src/components/Widgets/EditableCell.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useSelector } from 'react-redux';
import React from 'react';
import { normalizeValue } from '@plone/volto/components/manage/Widgets/SelectUtils';
import { useIntl } from 'react-intl';
import moment from 'moment';
import { getFieldType, getOnChange, getValue, getValueToRender } from './utils';

export const EditableCell = ({
value: initialValue,
row: { index },
column: { id },
updateCell, // This is a custom function that we supplied to our table instance
selectedRow,
setSelectedRow,
schema,
reactSelect,
state: { pageIndex, pageSize },
}) => {
const fieldSchema = { ...schema?.properties?.[id], id: id };
const locale = useSelector((state) => state.intl.locale);
moment.locale(locale);

const [value, setValue] = React.useState(initialValue);

const onBlur = () => {
updateCell(index, id, value);
};

React.useEffect(() => {
setValue(initialValue);
}, [initialValue]);
const { choices, defaultValue, isMulti } = fieldSchema;
const intl = useIntl();
const fieldType = getFieldType(fieldSchema, reactSelect);
const Field = fieldType.Field;
const normalizedValue = normalizeValue(choices, value, intl);
const onChangeFunction = getOnChange(fieldType.type, setValue);
return selectedRow === index ? (
<Field
{...fieldType.properties}
value={getValue(fieldType.type, value, defaultValue, normalizedValue)}
onChange={(...args) => onChangeFunction({ ...args, isMulti: isMulti })}
onBlur={onBlur}
/>
) : (
<span
role="button"
className="editable-cell"
tabIndex={0}
onClick={() => {
setSelectedRow(index);
}}
onKeyDown={() => {
setSelectedRow(index);
}}
onFocus={() => {
setSelectedRow(index);
}}
>
{getValueToRender(fieldType, value, moment)}
</span>
);
};
Loading

0 comments on commit aafb564

Please sign in to comment.