Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add column functionality to EditDashboard component #2097

Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
441e881
feat: Add column functionality to EditDashboard component
Terdious Jun 3, 2024
13230cc
fix: i18n, prettier and eslint
Terdious Jun 3, 2024
d977bc6
chore: Update EditDashboard component state handling and fix boxNotEm…
Terdious Jun 4, 2024
bdda5f7
fix: prettier
Terdious Jun 4, 2024
fc8bc79
fix: Fix bug in EditBoxColumns component
Terdious Jun 4, 2024
c8cf074
fix: Remove delete column button from translation files
Terdious Jun 4, 2024
31ade93
fix: Update German translation file
Terdious Jun 4, 2024
df8c3ad
Merge branch 'master' into add-choice-number-columns-dashboard
Terdious Jun 4, 2024
e240059
fix: Improve accessibility and styling of EditBoxColumns component
Terdious Jun 7, 2024
161e4c4
fix: Improve German translation for "Add a column on dashboard"
Terdious Jun 7, 2024
f59e389
fix: Improve column layout in EditBoxColumns component
Terdious Jun 7, 2024
146dd19
fix: Improve column layout and accessibility in EditBoxColumns component
Terdious Jun 9, 2024
9df1bff
fix: prettier+eslint
Terdious Jun 10, 2024
b2e5663
fix: prettier
Terdious Jun 10, 2024
c6b55c9
refactor: reordered styles
Terdious Jun 10, 2024
7cda77a
fix: review non-useful code
Terdious Jun 10, 2024
ec5fd5a
Improve column layout and accessibility in EditBoxColumns component
Terdious Jun 12, 2024
a0bf86d
Merge branch 'master' into add-choice-number-columns-dashboard
Terdious Jun 12, 2024
89d1200
Merge branch 'master' into add-choice-number-columns-dashboard
Terdious Jun 13, 2024
513a316
Merge branch 'master' into add-choice-number-columns-dashboard
Terdious Jun 13, 2024
68a7eec
fix: review
Terdious Jun 13, 2024
e170399
fix: review
Terdious Jun 13, 2024
0809b3b
fix: review delete mutationObserver and resizeObserver
Terdious Jun 13, 2024
57ca61d
refactor: review - EditBoxColumns component - delete position sticky
Terdious Jun 13, 2024
678ee43
refactor: remove position sticky from EditBoxColumns component and an…
Terdious Jun 17, 2024
786a4a9
fix: prettier
Terdious Jun 17, 2024
4bf2dea
update columns
Terdious Aug 29, 2024
c12f95a
Merge branch 'GladysAssistant:master' into add-choice-number-columns-…
Terdious Aug 29, 2024
2d61715
style: Remove unnecessary CSS properties in edit-dashboard style.css
Terdious Aug 30, 2024
925614c
style: Update EditBoxColumns class to include 'align-items-start'
Terdious Aug 30, 2024
815af8f
style: Update media query breakpoints in edit-dashboard style.css
Terdious Aug 30, 2024
9e30e4c
style: Add min-width to columnBoxHeader in edit-dashboard style.css
Terdious Aug 30, 2024
710f469
Merge branch 'master' into add-choice-number-columns-dashboard
Terdious Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions front/src/config/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
"private": "privat",
"public": "öffentlich"
},
"editDashboardAddColumnButton": "Eine Spalte zum Dashboard hinzufügen",
"editDashboardBoxNotEmpty": "Sie können diese Spalte nicht löschen, da sie Widgets enthält.",
"editDashboardMyDashboards": "Meine Dashboards",
"editDashboardExplanation": "Jedes Dashboard hat 3 Spalten, die du nach Belieben füllen kannst. Klicke auf \"+\", um ein neues Widget hinzuzufügen. Du kannst dieses Widget bewegen, indem du es greifst und verschiebst.",
"reorderDashboardButton": "Dashboards neu anordnen",
Expand Down
2 changes: 2 additions & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
"private": "private",
"public": "public"
},
"editDashboardAddColumnButton": "Add a column on dashboard",
"editDashboardBoxNotEmpty": "You cannot delete this column as it contains widgets.",
"editDashboardMyDashboards": "My dashboards",
"editDashboardExplanation": "Each dashboard has 3 columns, which you can fill in according to your preferences. Click on the + button to add a new widget. You can move this widget by grabbing it and moving it around.",
"reorderDashboardButton": "Re-order dashboards",
Expand Down
2 changes: 2 additions & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
"private": "privé",
"public": "public"
},
"editDashboardAddColumnButton": "Ajouter une colonne au tableau de bord",
"editDashboardBoxNotEmpty": "Vous ne pouvez pas supprimer cette colonne car elle contient des widgets.",
"editDashboardMyDashboards": "Mes tableaux de bords",
"editDashboardExplanation": "Chaque tableau de bord comporte 3 colonnes, que vous pouvez remplir selon vos préférences. Cliquez sur le bouton + pour ajouter un nouveau widget. Vous pouvez déplacer ce widget en l'attrapant et en le déplaçant.",
"reorderDashboardButton": "Re-ordonner",
Expand Down
40 changes: 22 additions & 18 deletions front/src/routes/dashboard/BoxColumns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ import Box from './Box';
import cx from 'classnames';
import style from './style.css';

const BoxColumns = ({ children, ...props }) => (
<div class="d-flex flex-row flex-wrap justify-content-center">
{props.homeDashboard &&
props.homeDashboard.boxes.map((column, x) => (
<div
class={cx('d-flex flex-column col-lg-4', {
[style.removePaddingFirstCol]: x === 0,
[style.removePaddingLastCol]: x === 2,
[style.removePadding]: true // it will remove padding when in mobile view
})}
>
{column.map((box, y) => (
<Box key={`${props.homeDashboard.id}-${x}-${y}`} box={box} x={x} y={y} />
))}
</div>
))}
</div>
);
const BoxColumns = ({ children, ...props }) => {
const columnClass = `col-lg-${12 / props.homeDashboard.boxes.length}`;

return (
<div class="d-flex flex-row flex-wrap justify-content-center">
{props.homeDashboard &&
props.homeDashboard.boxes.map((column, x) => (
<div
class={cx('d-flex flex-column', columnClass, style.removePadding, {
[style.removePaddingFirstCol]: x === 0,
[style.removePaddingLastCol]: x === 2,
[style.removePadding]: true // it will remove padding when in mobile view
})}
>
{column.map((box, y) => (
<Box key={`${props.homeDashboard.id}-${x}-${y}`} box={box} x={x} y={y} />
))}
</div>
))}
</div>
);
};

export default BoxColumns;
291 changes: 166 additions & 125 deletions front/src/routes/dashboard/edit-dashboard/EditBoxColumns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,145 +8,186 @@ import EditBox from './EditBox';
import EmptyColumnDropZone from './EmptyColumnDropZone';
import BottomDropZone from './BottomDropZone';
import AutoScrollMobile from '../../../components/drag-and-drop/AutoScrollMobile';
import style from '../style.css';
import style from './style.css';
import stylePrimary from '../style.css';
import { DASHBOARD_VISIBILITY_LIST } from '../../../../../server/utils/constants';

const DASHBOARD_EDIT_BOX_TYPE = 'DASHBOARD_EDIT_BOX';

const EditBoxColumns = ({ children, ...props }) => (
<div class="pb-6">
<h3>
<Text id="dashboard.editDashboardTitle" />
</h3>
{props.dashboardAlreadyExistError && (
<div class="alert alert-danger">
<Text id="newDashboard.dashboardAlreadyExist" />
</div>
)}{' '}
{props.dashboardValidationError && (
<div class="alert alert-danger">
<Text id="newDashboard.validationError" />
</div>
)}
{props.unknownError && (
<div class="alert alert-danger">
<Text id="newDashboard.unknownError" />
</div>
)}
<div class="row align-items-end">
<div class="col-md-4">
<div class="form-group">
<label class="form-label">
<Text id="dashboard.editDashboardNameLabel" />
</label>
<Localizer>
<input
type="text"
class="form-control"
placeholder={<Text id="dashboard.editDashboardNameLabel" />}
value={props.homeDashboard.name}
onInput={props.updateCurrentDashboardName}
/>
</Localizer>
const EditBoxColumns = ({ children, ...props }) => {
const lengthBoxes = props.homeDashboard.boxes.length;
const columnClass = `col-lg-${lengthBoxes <= 2 ? 10 / lengthBoxes : 4}`;

return (
<div class="pb-6">
<h3>
<Text id="dashboard.editDashboardTitle" />
</h3>
{props.dashboardAlreadyExistError && (
<div class="alert alert-danger">
<Text id="newDashboard.dashboardAlreadyExist" />
</div>
)}{' '}
{props.dashboardValidationError && (
<div class="alert alert-danger">
<Text id="newDashboard.validationError" />
</div>
)}
{props.unknownError && (
<div class="alert alert-danger">
<Text id="newDashboard.unknownError" />
</div>
)}
<div class="row align-items-end">
<div class="col-md-4">
<div class="form-group">
<label class="form-label">
<Text id="dashboard.editDashboardNameLabel" />
</label>
<Localizer>
<input
type="text"
class="form-control"
placeholder={<Text id="dashboard.editDashboardNameLabel" />}
value={props.homeDashboard.name}
onInput={props.updateCurrentDashboardName}
/>
</Localizer>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label class="form-label">
<Text id="dashboard.editDashboardVisibility" />
</label>
<small>
<Text id="dashboard.editDashboardVisibilityDescription" />
</small>
{props.user.id !== props.homeDashboard.user_id && (
<div>
<small>
<Text id="dashboard.editDashboardVisibilityNotEditableNotCreator" />
</small>
</div>
)}
<Localizer>
<select
value={props.homeDashboard.visibility}
onChange={props.updateCurrentDashboardVisibility}
disabled={props.user.id !== props.homeDashboard.user_id}
class="form-control"
>
{DASHBOARD_VISIBILITY_LIST.map(dashboardVisibility => (
<option value={dashboardVisibility}>
<Text id={`dashboard.visibilities.${dashboardVisibility}`} />
</option>
))}
</select>
</Localizer>
<div class="row">
<div class="col-md-8">
<div class="form-group">
<label class="form-label">
<Text id="dashboard.editDashboardVisibility" />
</label>
<small>
<Text id="dashboard.editDashboardVisibilityDescription" />
</small>
{props.user.id !== props.homeDashboard.user_id && (
<div>
<small>
<Text id="dashboard.editDashboardVisibilityNotEditableNotCreator" />
</small>
</div>
)}
<Localizer>
<select
value={props.homeDashboard.visibility}
onChange={props.updateCurrentDashboardVisibility}
disabled={props.user.id !== props.homeDashboard.user_id}
class="form-control"
>
{DASHBOARD_VISIBILITY_LIST.map(dashboardVisibility => (
<option value={dashboardVisibility}>
<Text id={`dashboard.visibilities.${dashboardVisibility}`} />
</option>
))}
</select>
</Localizer>
</div>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-md-12">
<Text id="dashboard.editDashboardExplanation" />
<div class="row mb-4">
<div class="col-md-12">
<Text id="dashboard.editDashboardExplanation" />
</div>
</div>
</div>
<div class="row mb-6">
<div class="col-md-4 d-lg-none d-xl-none">
<button
class={cx('btn', {
'btn-secondary': !props.isMobileReordering,
'btn-warning': props.isMobileReordering
})}
onClick={props.toggleMobileReorder}
>
<i class="fe fe-list mr-2" />
{!props.isMobileReordering && <Text id="dashboard.reorderDashboardButton" />}
{props.isMobileReordering && <Text id="dashboard.stopReorderingDashboardButton" />}
</button>
<div class="row mb-4">
<div class="col-md-4 d-lg-none d-xl-none">
<button
class={cx('btn', {
'btn-secondary': !props.isMobileReordering,
'btn-warning': props.isMobileReordering
})}
onClick={props.toggleMobileReorder}
>
<i class="fe fe-list mr-2" />
{!props.isMobileReordering && <Text id="dashboard.reorderDashboardButton" />}
{props.isMobileReordering && <Text id="dashboard.stopReorderingDashboardButton" />}
</button>
</div>
</div>
</div>
<DndProvider backend={props.isTouchDevice ? TouchBackend : HTML5Backend}>
{props.isMobileReordering && <AutoScrollMobile position="top" box_type={DASHBOARD_EDIT_BOX_TYPE} />}
<div class="d-flex flex-row flex-wrap justify-content-center">
{props.homeDashboard &&
props.homeDashboard.boxes &&
props.homeDashboard.boxes.map((column, x) => (
<div
class={cx('d-flex flex-column col-lg-4', style.removePadding, {
[style.removePaddingFirstCol]: x === 0,
[style.removePaddingLastCol]: x === 2
})}
>
<h3 class="text-center">
<Text id="dashboard.boxes.column" fields={{ index: x + 1 }} />
</h3>

{column.length > 0 && (
<div>
{column.map((box, y) => (
<EditBox {...props} box={box} x={x} y={y} isMobileReordering={props.isMobileReordering} />
))}
<BottomDropZone
moveCard={props.moveCard}
x={x}
y={column.length}
isMobileReordering={props.isMobileReordering}
/>
<DndProvider backend={props.isTouchDevice ? TouchBackend : HTML5Backend}>
{props.isMobileReordering && <AutoScrollMobile position="top" box_type={DASHBOARD_EDIT_BOX_TYPE} />}
<div class={cx('d-flex flex-row align-items-start', style.columnCard)}>
{props.homeDashboard &&
props.homeDashboard.boxes &&
props.homeDashboard.boxes.map((column, x) => (
<div
class={cx('d-flex flex-column', columnClass, stylePrimary.removePadding, {
[stylePrimary.removePaddingFirstCol]: x === 0,
[stylePrimary.removePaddingLastCol]: x === 2
})}
>
<div class={cx('d-flex', 'justify-content-center', style.columnBoxesHeader)}>
<h3 class="d-flex justify-content-center text-center">
<Text id="dashboard.boxes.column" fields={{ index: x + 1 }} />
{lengthBoxes > 1 && (
<button
class={cx('btn p-0 ml-2', style.btnLink, style.btnLinkDelete)}
onClick={() => props.deleteCurrentColumn(x)}
>
Terdious marked this conversation as resolved.
Show resolved Hide resolved
<i class="fe fe-trash" />
</button>
)}
</h3>
</div>
)}
{props.boxNotEmptyError && props.columnBoxNotEmptyError === x && (
<div class="alert alert-danger d-flex justify-content-center mb-4">
<Text id="dashboard.editDashboardBoxNotEmpty" />
</div>
)}
<div class="d-flex flex-column m-0">
{column.length > 0 && (
<div>
{column.map((box, y) => (
<EditBox {...props} box={box} x={x} y={y} isMobileReordering={props.isMobileReordering} />
))}
<BottomDropZone
moveCard={props.moveCard}
x={x}
y={column.length}
isMobileReordering={props.isMobileReordering}
/>
</div>
)}

{column.length === 0 && <EmptyColumnDropZone moveCard={props.moveCard} x={x} />}
{column.length === 0 && <EmptyColumnDropZone moveCard={props.moveCard} x={x} />}

{props.isMobileReordering && <AutoScrollMobile position="bottom" box_type={DASHBOARD_EDIT_BOX_TYPE} />}
<div class="d-flex justify-content-center mb-4">
<button class="btn btn-primary" onClick={() => props.addBox(x)}>
<Text id="dashboard.addBoxButton" /> <i class="fe fe-plus" />
</button>
{props.isMobileReordering && (
<AutoScrollMobile position="bottom" box_type={DASHBOARD_EDIT_BOX_TYPE} />
)}
<div class="d-flex justify-content-center mb-4">
<button class="btn btn-primary" onClick={() => props.addBox(x)}>
<Text id="dashboard.addBoxButton" /> <i class="fe fe-plus" />
</button>
</div>
</div>
</div>
))}
{lengthBoxes < 3 && (
<div class={cx('d-flex flex-column col-lg-2 justify-content-center pr-0')}>
<div class={cx(style.columnBoxesHeader, 'd-flex', 'justify-content-center', 'align-items-center')} />
<Localizer>
<button
class={cx('btn btn-outline-primary', style.btnAddColumn)}
onClick={() => props.addColumn(lengthBoxes)}
data-title={<Text id="dashboard.editDashboardAddColumnButton" />}
>
<i class="fe fe-plus" />
<div class={cx('d-none', style.displayTextMobile)}>
<Text id="dashboard.editDashboardAddColumnButton" />
</div>
</button>
</Localizer>
</div>
))}
</div>
</DndProvider>
</div>
);
)}
</div>
</DndProvider>
</div>
);
};

export default EditBoxColumns;
4 changes: 4 additions & 0 deletions front/src/routes/dashboard/edit-dashboard/EditDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ const EditDashboard = ({ children, ...props }) => (
savingNewDashboardList={props.savingNewDashboardList}
isMobileReordering={props.isMobileReordering}
toggleMobileReorder={props.toggleMobileReorder}
deleteCurrentColumn={props.deleteCurrentColumn}
addColumn={props.addColumn}
boxNotEmptyError={props.boxNotEmptyError}
columnBoxNotEmptyError={props.columnBoxNotEmptyError}
/>
)}
</div>
Expand Down
Loading
Loading