From 8721e36db0c657c3d07599e3669e22e35d27f6aa Mon Sep 17 00:00:00 2001 From: Jonathan ARNAULT Date: Thu, 9 Jan 2025 10:56:35 +0100 Subject: [PATCH] Feat(fields): Improve UX and deletion modal text --- .prettierrc | 3 +- jsconfig.json | 3 +- src/app/custom/translations.tsv | 3 +- src/app/js/admin/field/DeleteFieldsButton.js | 23 ++++-- src/app/js/fields/FieldGrid.js | 72 ++++++++++-------- src/app/js/fields/FieldRepresentation.js | 80 ++++++++++---------- 6 files changed, 99 insertions(+), 85 deletions(-) diff --git a/.prettierrc b/.prettierrc index 90063671ea..baa36dd94e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,6 @@ "singleQuote": true, "trailingComma": "all", "semi": true, - "htmlWhitespaceSensitivity": "ignore" + "htmlWhitespaceSensitivity": "ignore", + "organizeImportsSkipDestructiveCodeActions": true } diff --git a/jsconfig.json b/jsconfig.json index d6898eddaf..9a71a76f49 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -3,7 +3,8 @@ "target": "ES6", "module": "commonjs", "allowSyntheticDefaultImports": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "jsx": "react" }, "exclude": ["src/build", "node_modules"] } diff --git a/src/app/custom/translations.tsv b/src/app/custom/translations.tsv index d3f95e3f24..8d96f86b82 100644 --- a/src/app/custom/translations.tsv +++ b/src/app/custom/translations.tsv @@ -1173,6 +1173,7 @@ "label_format_size" "Size" "Taille" "export_csv" "Save as CSV" "Sauvegarder en CSV" "delete_selected_fields" "Delete selected fields" "Supprimer les champs sélectionnés" -"delete_selected_fields_title" "The following fields will be deleted" "Les champs suivants seront supprimés" +"delete_selected_fields_title" "Delete selected fields" "Supprimer la sélection" +"delete_selected_fields_helptext" "Are you sure you want to delete the selected field ? |||| Are you sure you want to delete the %{smart_count} selected fields ?" "Êtes-vous sûr de vouloir supprimer le champs sélectionné ? |||| Êtes-vous sûr de vouloir supprimer les %{smart_count} champs sélectionné ?" "cancel" "Cancel" "Annuler" "select_field" "Select field" "Sélectionner le champ" diff --git a/src/app/js/admin/field/DeleteFieldsButton.js b/src/app/js/admin/field/DeleteFieldsButton.js index bf6fe5c5f5..ea2f7798a9 100644 --- a/src/app/js/admin/field/DeleteFieldsButton.js +++ b/src/app/js/admin/field/DeleteFieldsButton.js @@ -1,22 +1,23 @@ -import React, { useCallback, useMemo, useState } from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import compose from 'recompose/compose'; -import translate from 'redux-polyglot/translate'; -import { polyglot as polyglotPropTypes } from '../../propTypes'; -import { fromFields } from '../../sharedSelectors'; +import { Delete as DeleteIcon } from '@mui/icons-material'; import { Button, Dialog, DialogActions, DialogContent, + DialogContentText, DialogTitle, List, ListItem, } from '@mui/material'; -import { Delete as DeleteIcon } from '@mui/icons-material'; +import PropTypes from 'prop-types'; +import React, { useCallback, useMemo, useState } from 'react'; +import { connect } from 'react-redux'; +import compose from 'recompose/compose'; +import translate from 'redux-polyglot/translate'; import { removeFieldList } from '../../fields'; import FieldRepresentation from '../../fields/FieldRepresentation'; +import { polyglot as polyglotPropTypes } from '../../propTypes'; +import { fromFields } from '../../sharedSelectors'; const DeleteFieldsButtonComponent = ({ fields, @@ -72,6 +73,11 @@ const DeleteFieldsButtonComponent = ({ {polyglot.t('delete_selected_fields_title')} + + {polyglot.t('delete_selected_fields_helptext', { + smart_count: fieldsToDelete.length, + })} + {fieldsToDelete.map((field) => ( ({ }, [field, completedField]); const handleCopyToClipboard = (event, text) => { + // Only copy to clipboard if the user clicks on the field name + if (event.target.firstChild.nodeName !== '#text') { + return; + } + event.stopPropagation(); event.preventDefault(); + copy(text); toast(polyglot.t('fieldidentifier_copied_clipboard'), { type: toast.TYPE.SUCCESS, @@ -187,29 +193,31 @@ const FieldGridItem = connect((state, { field }) => ({ {completedField && ( - - - {polyglot.t('completes_field_X', { + - + > + + {polyglot.t('completes_field_X', { + field: completedField.label, + })} + + + )} - - {field.label} - - + {field.label} + + )} {(field.internalScopes || field.internalName) && !shortMode && ( - - {field.internalName} - - + {field.internalName} + + )} )}