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',
CREDIT_NOTES: 'credit_notes',
VENDOR_CREDITS: 'vendor_credits',
WAREHOUSE_TRANSFERS:'warehouse_transfers'
WAREHOUSE_TRANSFERS:'warehouse_transfers',
PROJECTS:'projects'
};
export const TABLE_SIZE = {

View File

@@ -17,8 +17,7 @@ import { compose } from 'utils';
const defaultInitialValues = {
contact: '',
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_cost: '',
};

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,18 @@
import React from 'react';
import { DataTable } from 'components';
import { TABLES } from 'common/tables';
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import { useProjectsListContext } from './ProjectsListProvider';
import { useMemorizedColumnsWidths } from 'hooks';
import { useProjectsListColumns, ActionsMenu } from '../components';
import withDialogActions from 'containers/Dialog/withDialogActions';
import withProjectsActions from './withProjectsActions';
import withSettings from '../../Settings/withSettings';
import { compose } from 'utils';
@@ -19,6 +23,18 @@ const projects = [
description: 'Project 1 description',
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({
// #withDial
openDialog,
// #withSettings
projectsTableSize,
}) {
// Retrieve projects table columns.
const columns = useProjectsListColumns();
@@ -40,6 +59,10 @@ function ProjectsDataTable({
openDialog('task-form');
};
// Local storage memorizing columns widths.
const [initialColumnsWidths, , handleColumnResizing] =
useMemorizedColumnsWidths(TABLES.PROJECTS);
return (
<DataTable
columns={columns}
@@ -55,6 +78,9 @@ function ProjectsDataTable({
TableHeaderSkeletonRenderer={TableSkeletonHeader}
ContextMenu={ActionsMenu}
onCellClick={handleCellClick}
initialColumnsWidths={initialColumnsWidths}
onColumnResizing={handleColumnResizing}
size={projectsTableSize}
payload={{
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,
vendorsCreditNoteSetting: state.settings.data.vendorCredit,
warehouseTransferSettings: state.settings.data.warehouseTransfers,
projectSettings:state.settings.data.projects
};
return mapState ? mapState(mapped, state, props) : mapped;
};

View File

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

View File

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