feat: projects actions bar.

This commit is contained in:
elforjani13
2022-06-11 15:30:11 +02:00
parent 327916da4b
commit a44f548ff9
10 changed files with 54 additions and 7 deletions

View File

@@ -16,7 +16,8 @@ export const TABLES = {
CASHFLOW_Transactions: 'cashflow_transactions', CASHFLOW_Transactions: 'cashflow_transactions',
CREDIT_NOTES: 'credit_notes', CREDIT_NOTES: 'credit_notes',
VENDOR_CREDITS: 'vendor_credits', VENDOR_CREDITS: 'vendor_credits',
WAREHOUSE_TRANSFERS:'warehouse_transfers' WAREHOUSE_TRANSFERS:'warehouse_transfers',
PROJECTS:'projects'
}; };
export const TABLE_SIZE = { export const TABLE_SIZE = {

View File

@@ -17,8 +17,7 @@ import { compose } from 'utils';
const defaultInitialValues = { const defaultInitialValues = {
contact: '', contact: '',
project_name: '', project_name: '',
project_deadline: '', project_deadline: moment(new Date()).format('YYYY-MM-DD'),
// project_deadline: moment(new Date()).format('YYYY-MM-DD'),
project_state: false, project_state: false,
project_cost: '', project_cost: '',
}; };

View File

@@ -38,7 +38,7 @@ function ProjectFormFloatingActions({
style={{ minWidth: '75px' }} style={{ minWidth: '75px' }}
type="submit" type="submit"
> >
Create <T id={'projects.label.create'} />
</Button> </Button>
</div> </div>
</div> </div>

View File

@@ -26,6 +26,7 @@ function ProjectFormProvider({
// State provider. // State provider.
const provider = { const provider = {
customers, customers,
dialogName,
}; };
return ( return (

View File

@@ -16,7 +16,10 @@ function TaskFormProvider({
...props ...props
}) { }) {
// State provider. // State provider.
const provider = {}; const provider = {
dialogName,
};
return ( return (
<DialogContent> <DialogContent>
<TaskFormContext.Provider value={provider} {...props} /> <TaskFormContext.Provider value={provider} {...props} />

View File

@@ -41,6 +41,9 @@ function ProjectsActionsBar({
// #withProjectsActions // #withProjectsActions
setProjectsTableState, setProjectsTableState,
// #withSettings
projectsTableSize,
// #withSettingsActions // #withSettingsActions
addSetting, addSetting,
}) { }) {
@@ -100,7 +103,7 @@ function ProjectsActionsBar({
/> />
<NavbarDivider /> <NavbarDivider />
<DashboardRowsHeightButton <DashboardRowsHeightButton
initialValue={'medium'} initialValue={projectsTableSize}
onChange={handleTableRowSizeChange} onChange={handleTableRowSizeChange}
/> />
<NavbarDivider /> <NavbarDivider />
@@ -123,4 +126,7 @@ export default compose(
withProjects(({ projectsTableState }) => ({ withProjects(({ projectsTableState }) => ({
projectsFilterRoles: projectsTableState?.filterRoles, projectsFilterRoles: projectsTableState?.filterRoles,
})), })),
withSettings(({ projectSettings }) => ({
projectsTableSize: projectSettings?.tableSize,
})),
)(ProjectsActionsBar); )(ProjectsActionsBar);

View File

@@ -1,14 +1,18 @@
import React from 'react'; import React from 'react';
import { DataTable } from 'components'; import { DataTable } from 'components';
import { TABLES } from 'common/tables';
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows'; import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton'; import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import { useProjectsListContext } from './ProjectsListProvider'; import { useProjectsListContext } from './ProjectsListProvider';
import { useMemorizedColumnsWidths } from 'hooks';
import { useProjectsListColumns, ActionsMenu } from '../components'; import { useProjectsListColumns, ActionsMenu } from '../components';
import withDialogActions from 'containers/Dialog/withDialogActions'; import withDialogActions from 'containers/Dialog/withDialogActions';
import withProjectsActions from './withProjectsActions';
import withSettings from '../../Settings/withSettings';
import { compose } from 'utils'; import { compose } from 'utils';
@@ -19,6 +23,18 @@ const projects = [
description: 'Project 1 description', description: 'Project 1 description',
status: 'Active', status: 'Active',
}, },
{
id: 2,
name: 'Project 2',
description: 'Project 2 description',
status: 'Active',
},
{
id: 3,
name: 'Project 3',
description: 'Project 3 description',
status: 'Active',
},
]; ];
/** /**
@@ -28,6 +44,9 @@ const projects = [
function ProjectsDataTable({ function ProjectsDataTable({
// #withDial // #withDial
openDialog, openDialog,
// #withSettings
projectsTableSize,
}) { }) {
// Retrieve projects table columns. // Retrieve projects table columns.
const columns = useProjectsListColumns(); const columns = useProjectsListColumns();
@@ -40,6 +59,10 @@ function ProjectsDataTable({
openDialog('task-form'); openDialog('task-form');
}; };
// Local storage memorizing columns widths.
const [initialColumnsWidths, , handleColumnResizing] =
useMemorizedColumnsWidths(TABLES.PROJECTS);
return ( return (
<DataTable <DataTable
columns={columns} columns={columns}
@@ -55,6 +78,9 @@ function ProjectsDataTable({
TableHeaderSkeletonRenderer={TableSkeletonHeader} TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu} ContextMenu={ActionsMenu}
onCellClick={handleCellClick} onCellClick={handleCellClick}
initialColumnsWidths={initialColumnsWidths}
onColumnResizing={handleColumnResizing}
size={projectsTableSize}
payload={{ payload={{
onNewTask: handleNewTaskButtonClick, onNewTask: handleNewTaskButtonClick,
}} }}
@@ -62,4 +88,10 @@ function ProjectsDataTable({
); );
} }
export default compose(withDialogActions)(ProjectsDataTable); export default compose(
withDialogActions,
withProjectsActions,
withSettings(({ projectSettings }) => ({
projectsTableSize: projectSettings?.tableSize,
})),
)(ProjectsDataTable);

View File

@@ -22,6 +22,7 @@ export default (mapState) => {
creditNoteSettings: state.settings.data.creditNote, creditNoteSettings: state.settings.data.creditNote,
vendorsCreditNoteSetting: state.settings.data.vendorCredit, vendorsCreditNoteSetting: state.settings.data.vendorCredit,
warehouseTransferSettings: state.settings.data.warehouseTransfers, warehouseTransferSettings: state.settings.data.warehouseTransfers,
projectSettings:state.settings.data.projects
}; };
return mapState ? mapState(mapped, state, props) : mapped; return mapState ? mapState(mapped, state, props) : mapped;
}; };

View File

@@ -2055,6 +2055,7 @@
"projects.label.deadline": "Deadline", "projects.label.deadline": "Deadline",
"projects.label.calculator_expenses": "Calculator from tasks & estimated expenses", "projects.label.calculator_expenses": "Calculator from tasks & estimated expenses",
"projects.label.cost_estimate": "Cost Estimate", "projects.label.cost_estimate": "Cost Estimate",
"projects.label.create": "Create",
"task.label.new_task": "New Task", "task.label.new_task": "New Task",
"task.label.task_name": "Task Name", "task.label.task_name": "Task Name",
"task.label.estimated_hours": "Task Name", "task.label.estimated_hours": "Task Name",

View File

@@ -61,6 +61,9 @@ const initialState = {
warehouseTransfer: { warehouseTransfer: {
tableSize: 'medium', tableSize: 'medium',
}, },
projects: {
tableSize: 'medium',
},
}, },
}; };