mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-24 00:29:49 +00:00
fix: rename project & task form dialog.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import * as Yup from 'yup';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||
|
||||
const Schema = Yup.object().shape({
|
||||
contact: Yup.string().label(intl.get('project.schema.label.contact')),
|
||||
projectName: Yup.string()
|
||||
.label(intl.get('project.schema.label.project_name'))
|
||||
.required(),
|
||||
projectDeadline: Yup.date()
|
||||
.label(intl.get('project.schema.label.deadline'))
|
||||
.required(),
|
||||
projectState: Yup.boolean().label(
|
||||
intl.get('project.schema.label.project_state'),
|
||||
),
|
||||
projectCost: Yup.number().label(
|
||||
intl.get('project.schema.label.project_cost'),
|
||||
),
|
||||
});
|
||||
|
||||
export const CreateProjectFormSchema = Schema;
|
||||
@@ -0,0 +1,68 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Formik } from 'formik';
|
||||
import { AppToaster } from 'components';
|
||||
import ProjectFormContent from './ProjectFormContent';
|
||||
import { CreateProjectFormSchema } from './ProjectForm.schema';
|
||||
import { useProjectFormContext } from './ProjectFormProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const defaultInitialValues = {
|
||||
contact: '',
|
||||
projectName: '',
|
||||
projectDeadline: moment(new Date()).format('YYYY-MM-DD'),
|
||||
projectState: true,
|
||||
projectCost: '',
|
||||
};
|
||||
|
||||
/**
|
||||
* Project form
|
||||
* @returns
|
||||
*/
|
||||
function ProjectForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
// project form dialog context.
|
||||
const { dialogName } = useProjectFormContext();
|
||||
|
||||
// Initial form values
|
||||
const initialValues = {
|
||||
...defaultInitialValues,
|
||||
};
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||
const form = {};
|
||||
|
||||
// Handle request response success.
|
||||
const onSuccess = (response) => {
|
||||
AppToaster.show({});
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
// Handle request response errors.
|
||||
const onError = ({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<Formik
|
||||
validationSchema={CreateProjectFormSchema}
|
||||
initialValues={initialValues}
|
||||
onSubmit={handleFormSubmit}
|
||||
component={ProjectFormContent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(ProjectForm);
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { Form } from 'formik';
|
||||
|
||||
import ProjectFormFields from './ProjectFormFields';
|
||||
import ProjectFormFloatingActions from './ProjectFormFloatingActions';
|
||||
|
||||
/**
|
||||
* Project form content.
|
||||
*/
|
||||
export default function ProjectFormContent() {
|
||||
return (
|
||||
<Form>
|
||||
<ProjectFormFields />
|
||||
<ProjectFormFloatingActions />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
|
||||
import { ProjectFormProvider } from './ProjectFormProvider';
|
||||
import ProjectForm from './ProjectForm';
|
||||
|
||||
/**
|
||||
* Project form dialog content.
|
||||
* @returns {ReactNode}
|
||||
*/
|
||||
export default function ProjectFormDialogContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
project,
|
||||
}) {
|
||||
return (
|
||||
<ProjectFormProvider projectId={project} dialogName={dialogName}>
|
||||
<ProjectForm />
|
||||
</ProjectFormProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { Classes, Position, FormGroup, ControlGroup } from '@blueprintjs/core';
|
||||
import { FastField } from 'formik';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
FFormGroup,
|
||||
FInputGroup,
|
||||
FCheckbox,
|
||||
FDateInput,
|
||||
FMoneyInputGroup,
|
||||
InputPrependText,
|
||||
FormattedMessage as T,
|
||||
CustomerSelectField,
|
||||
} from 'components';
|
||||
import {
|
||||
inputIntent,
|
||||
momentFormatter,
|
||||
tansformDateValue,
|
||||
handleDateChange,
|
||||
} from 'utils';
|
||||
import { useProjectFormContext } from './ProjectFormProvider';
|
||||
|
||||
/**
|
||||
* Project form fields.
|
||||
* @returns
|
||||
*/
|
||||
function ProjectFormFields() {
|
||||
const { customers } = useProjectFormContext();
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
{/*------------ Contact -----------*/}
|
||||
<FastField name={'contact'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={intl.get('projects.label.contact')}
|
||||
className={classNames('form-group--select-list', Classes.FILL)}
|
||||
intent={inputIntent({ error, touched })}
|
||||
>
|
||||
<CustomerSelectField
|
||||
contacts={customers}
|
||||
selectedContactId={value}
|
||||
defaultSelectText={'Select Contact Account'}
|
||||
onContactSelected={(customer) => {
|
||||
form.setFieldValue('contact', customer.id);
|
||||
}}
|
||||
allowCreate={true}
|
||||
popoverFill={true}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
{/*------------ Project Name -----------*/}
|
||||
<FFormGroup
|
||||
label={intl.get('projects.label.project_name')}
|
||||
name={'projectName'}
|
||||
>
|
||||
<FInputGroup name="projectName" />
|
||||
</FFormGroup>
|
||||
{/*------------ DeadLine -----------*/}
|
||||
<FFormGroup
|
||||
label={intl.get('projects.label.deadline')}
|
||||
name={'projectDeadline'}
|
||||
className={classNames(CLASSES.FILL, 'form-group--date')}
|
||||
>
|
||||
<FDateInput
|
||||
{...momentFormatter('YYYY/MM/DD')}
|
||||
name="projectDeadline"
|
||||
formatDate={(date) => date.toLocaleString()}
|
||||
popoverProps={{
|
||||
position: Position.BOTTOM,
|
||||
minimal: true,
|
||||
}}
|
||||
/>
|
||||
</FFormGroup>
|
||||
|
||||
{/*------------ CheckBox -----------*/}
|
||||
<FFormGroup name={'projectState'}>
|
||||
<FCheckbox
|
||||
name="projectState"
|
||||
label={intl.get('projects.label.calculator_expenses')}
|
||||
/>
|
||||
</FFormGroup>
|
||||
{/*------------ Cost Estimate -----------*/}
|
||||
<FFormGroup
|
||||
name={'projectCost'}
|
||||
label={intl.get('projects.label.cost_estimate')}
|
||||
>
|
||||
<ControlGroup>
|
||||
<InputPrependText text={'USD'} />
|
||||
<FMoneyInputGroup
|
||||
// disabled={true}
|
||||
name={'project_cost'}
|
||||
allowDecimals={true}
|
||||
allowNegativeValue={true}
|
||||
/>
|
||||
</ControlGroup>
|
||||
</FFormGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProjectFormFields;
|
||||
@@ -0,0 +1,48 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Intent, Button, Classes } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { useProjectFormContext } from './ProjectFormProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Project form floating actions.
|
||||
* @returns
|
||||
*/
|
||||
function ProjectFormFloatingActions({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
// project form dialog context.
|
||||
const { dialogName } = useProjectFormContext();
|
||||
|
||||
// Formik context.
|
||||
const { isSubmitting } = useFormikContext();
|
||||
|
||||
// Handle close button click.
|
||||
const handleCancelBtnClick = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button onClick={handleCancelBtnClick} style={{ minWidth: '75px' }}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
loading={isSubmitting}
|
||||
style={{ minWidth: '75px' }}
|
||||
type="submit"
|
||||
>
|
||||
<T id={'projects.label.create'} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(ProjectFormFloatingActions);
|
||||
@@ -0,0 +1,39 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { useCustomers } from 'hooks/query';
|
||||
import { DialogContent } from 'components';
|
||||
|
||||
const ProjectFormContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Project form provider.
|
||||
* @returns
|
||||
*/
|
||||
function ProjectFormProvider({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
projectId,
|
||||
...props
|
||||
}) {
|
||||
// Handle fetch customers data table or list
|
||||
const {
|
||||
data: { customers },
|
||||
isLoading: isCustomersLoading,
|
||||
} = useCustomers({ page_size: 10000 });
|
||||
|
||||
// State provider.
|
||||
const provider = {
|
||||
customers,
|
||||
dialogName,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent isLoading={isCustomersLoading}>
|
||||
<ProjectFormContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
const useProjectFormContext = () => React.useContext(ProjectFormContext);
|
||||
|
||||
export { ProjectFormProvider, useProjectFormContext };
|
||||
@@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Dialog, DialogSuspense, FormattedMessage as T } from 'components';
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const ProjectDialogContent = React.lazy(
|
||||
() => import('./containers/ProjectFormDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Project form dialog.
|
||||
* @returns
|
||||
*/
|
||||
function ProjectFormDialog({ dialogName, payload: { projectId = null }, isOpen }) {
|
||||
return (
|
||||
<ProjectFormDialogRoot
|
||||
name={dialogName}
|
||||
title={<T id={'projects.label.new_project'} />}
|
||||
isOpen={isOpen}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
style={{ width: '400px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<ProjectDialogContent dialogName={dialogName} project={projectId} />
|
||||
</DialogSuspense>
|
||||
</ProjectFormDialogRoot>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogRedux())(ProjectFormDialog);
|
||||
|
||||
const ProjectFormDialogRoot = styled(Dialog)`
|
||||
.bp3-dialog-body {
|
||||
.bp3-form-group {
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
|
||||
label.bp3-label {
|
||||
margin-bottom: 3px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
.bp3-dialog-footer {
|
||||
padding-top: 10px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
NavbarDivider,
|
||||
Alignment,
|
||||
} from '@blueprintjs/core';
|
||||
|
||||
import {
|
||||
Icon,
|
||||
AdvancedFilterPopover,
|
||||
@@ -20,9 +19,8 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||
|
||||
import withProjects from './withProjects';
|
||||
import withProjectsActions from './withProjectsActions';
|
||||
|
||||
import withSettings from '../../Settings/withSettings';
|
||||
import withSettingsActions from '../../Settings/withSettingsActions';
|
||||
import withSettings from '../../../Settings/withSettings';
|
||||
import withSettingsActions from '../../../Settings/withSettingsActions';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
@@ -1,18 +1,14 @@
|
||||
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 { useProjectsListColumns, ActionsMenu } from './components';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withProjectsActions from './withProjectsActions';
|
||||
import withSettings from '../../Settings/withSettings';
|
||||
import withSettings from '../../../Settings/withSettings';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
@@ -13,7 +13,7 @@ import { compose, transformTableStateToQuery } from 'utils';
|
||||
|
||||
/**
|
||||
* Projects list.
|
||||
* @returns {React.TSX}
|
||||
* @returns
|
||||
*/
|
||||
function ProjectsList({
|
||||
// #withProjects
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ts-nocheck
|
||||
import React from 'react';
|
||||
import { useResourceViews, useResourceMeta } from 'hooks/query';
|
||||
import DashboardInsider from '../../../components/Dashboard/DashboardInsider';
|
||||
import DashboardInsider from '../../../../components/Dashboard/DashboardInsider';
|
||||
|
||||
const ProjectsListContext = React.createContext();
|
||||
|
||||
@@ -12,7 +12,7 @@ import { compose, transfromViewsToTabs } from 'utils';
|
||||
|
||||
/**
|
||||
* Projects views tabs.
|
||||
* @returns {React.TSX}
|
||||
* @returns
|
||||
*/
|
||||
function ProjectsViewTabs({
|
||||
// #withProjects
|
||||
@@ -2,7 +2,7 @@ import { connect } from 'react-redux';
|
||||
import {
|
||||
getProjectsTableStateFactory,
|
||||
isProjectsTableStateChangedFactory,
|
||||
} from '../../../store/Project/projects.selectors';
|
||||
} from '../../../../store/Project/projects.selectors';
|
||||
|
||||
export default (mapState) => {
|
||||
const getProjectsTableState = getProjectsTableStateFactory();
|
||||
@@ -1,10 +1,9 @@
|
||||
import { connect } from 'react-redux';
|
||||
// import type { Dispatch } from 'redux';
|
||||
|
||||
import {
|
||||
setProjectsTableState,
|
||||
resetProjectsTableState,
|
||||
} from '../../../store/Project/projects.actions';
|
||||
} from '../../../../store/Project/projects.actions';
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setProjectsTableState: (state) => dispatch(setProjectsTableState(state)),
|
||||
@@ -0,0 +1,14 @@
|
||||
import * as Yup from 'yup';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||
|
||||
const Schema = Yup.object().shape({
|
||||
taksName: Yup.string()
|
||||
.label(intl.get('task.schema.label.task_name'))
|
||||
.required(),
|
||||
taskHouse: Yup.string().label(intl.get('task.schema.label.task_house')),
|
||||
change: Yup.string().label(intl.get('task.schema.label.charge')).required(),
|
||||
amount: Yup.number().label(intl.get('task.schema.label.amount')),
|
||||
});
|
||||
|
||||
export const CreateTaskFormSchema = Schema;
|
||||
@@ -0,0 +1,63 @@
|
||||
//@ts-nocheck
|
||||
import React from 'react';
|
||||
import { Formik } from 'formik';
|
||||
import { CreateTaskFormSchema } from './TaskForm.schema';
|
||||
import { useTaskFormContext } from './TaskFormProvider';
|
||||
import { AppToaster } from 'components';
|
||||
import TaskFormContent from './TaskFormContent';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const defaultInitialValues = {
|
||||
taksName: '',
|
||||
taskHouse: '00:00',
|
||||
change: 'Hourly Rate',
|
||||
changeAmount: '100000000',
|
||||
amount: '',
|
||||
};
|
||||
|
||||
/**
|
||||
* Task form.
|
||||
* @returns
|
||||
*/
|
||||
function TaskForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
// task form dialog context.
|
||||
const { dialogName } = useTaskFormContext();
|
||||
|
||||
// Initial form values
|
||||
const initialValues = {
|
||||
...defaultInitialValues,
|
||||
};
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||
const form = {};
|
||||
|
||||
// Handle request response success.
|
||||
const onSuccess = (response) => {};
|
||||
|
||||
// Handle request response errors.
|
||||
const onError = ({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<Formik
|
||||
validationSchema={CreateTaskFormSchema}
|
||||
initialValues={initialValues}
|
||||
onSubmit={handleFormSubmit}
|
||||
component={TaskFormContent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(TaskForm);
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { Form } from 'formik';
|
||||
import TaskFormFields from './TaskFormFields';
|
||||
import TaskFormFloatingActions from './TaskFormFloatingActions';
|
||||
|
||||
/**
|
||||
* Task form content.
|
||||
* @returns
|
||||
*/
|
||||
export default function TaskFormContent() {
|
||||
return (
|
||||
<Form>
|
||||
<TaskFormFields />
|
||||
<TaskFormFloatingActions />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { TaskFormProvider } from './TaskFormProvider';
|
||||
import TaskForm from './TaskForm';
|
||||
|
||||
/**
|
||||
* Task form dialog content.
|
||||
*/
|
||||
export default function TaskFormDialogContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
task,
|
||||
}) {
|
||||
return (
|
||||
<TaskFormProvider taskId={task} dialogName={dialogName}>
|
||||
<TaskForm />
|
||||
</TaskFormProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Classes, ControlGroup } from '@blueprintjs/core';
|
||||
import {
|
||||
FFormGroup,
|
||||
FInputGroup,
|
||||
Col,
|
||||
Row,
|
||||
FormattedMessage as T,
|
||||
} from 'components';
|
||||
|
||||
/**
|
||||
* Task form fields.
|
||||
* @returns
|
||||
*/
|
||||
function TaskFormFields() {
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
{/*------------ Task Name -----------*/}
|
||||
<FFormGroup label={<T id={'task.label.task_name'} />} name={'task_name'}>
|
||||
<FInputGroup name="taskName" />
|
||||
</FFormGroup>
|
||||
{/*------------ Estimated Hours -----------*/}
|
||||
<Row>
|
||||
<Col xs={4}>
|
||||
<FFormGroup
|
||||
label={<T id={'task.label.estimated_hours'} />}
|
||||
name={'taskHouse'}
|
||||
>
|
||||
<FInputGroup name="taskHouse" />
|
||||
</FFormGroup>
|
||||
</Col>
|
||||
{/*------------ Charge -----------*/}
|
||||
<Col xs={8}>
|
||||
<FFormGroup label={<T id={'task.label.charge'} />} name={'Charge'}>
|
||||
<ControlGroup>
|
||||
<FInputGroup name="change" />
|
||||
<FInputGroup name="changeAmount" />
|
||||
</ControlGroup>
|
||||
</FFormGroup>
|
||||
</Col>
|
||||
</Row>
|
||||
{/*------------ Estimated Amount -----------*/}
|
||||
<EstimatedAmountBase>
|
||||
<EstimatedAmountContent>
|
||||
<T id={'task.label.estimated_amount'} />
|
||||
<EstimateAmount>$100000</EstimateAmount>
|
||||
</EstimatedAmountContent>
|
||||
</EstimatedAmountBase>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default TaskFormFields;
|
||||
|
||||
const EstimatedAmountBase = styled.div`
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
font-size: 12px;
|
||||
/* opacity: 0.7; */
|
||||
`;
|
||||
|
||||
const EstimatedAmountContent = styled.span`
|
||||
background-color: #fffdf5;
|
||||
padding: 0.1rem 0;
|
||||
`;
|
||||
|
||||
const EstimateAmount = styled.span`
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
margin-left: 10px;
|
||||
`;
|
||||
@@ -0,0 +1,48 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Intent, Button, Classes } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { useTaskFormContext } from './TaskFormProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Task form floating actions.
|
||||
* @returns
|
||||
*/
|
||||
function TaskFormFloatingActions({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
// Formik context.
|
||||
const { isSubmitting } = useFormikContext();
|
||||
|
||||
// Task form dialog context.
|
||||
const { dialogName } = useTaskFormContext();
|
||||
|
||||
// Handle close button click.
|
||||
const handleCancelBtnClick = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button onClick={handleCancelBtnClick} style={{ minWidth: '75px' }}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
loading={isSubmitting}
|
||||
style={{ minWidth: '75px' }}
|
||||
type="submit"
|
||||
>
|
||||
{<T id={'save'} />}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(TaskFormFloatingActions);
|
||||
@@ -0,0 +1,31 @@
|
||||
//@ts-nocheck
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
|
||||
const TaskFormContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Task form provider.
|
||||
* @returns
|
||||
*/
|
||||
function TaskFormProvider({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
taskId,
|
||||
...props
|
||||
}) {
|
||||
// State provider.
|
||||
const provider = {
|
||||
dialogName,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent>
|
||||
<TaskFormContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
const useTaskFormContext = () => React.useContext(TaskFormContext);
|
||||
|
||||
export { TaskFormProvider, useTaskFormContext };
|
||||
34
src/containers/Projects/containers/TaskFormDialog/index.tsx
Normal file
34
src/containers/Projects/containers/TaskFormDialog/index.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Dialog, DialogSuspense, FormattedMessage as T } from 'components';
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const TaskFormDialogContent = React.lazy(
|
||||
() => import('./containers/TaskFormDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Task form dialog.
|
||||
* @returns
|
||||
*/
|
||||
function TaskFormDialog({ dialogName, payload: { taskId = null }, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={intl.get('task.label.new_task')}
|
||||
isOpen={isOpen}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
style={{ width: '500px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<TaskFormDialogContent dialogName={dialogName} task={taskId} />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
export default compose(withDialogRedux())(TaskFormDialog);
|
||||
|
||||
const TaskFormDialogRoot = styled(Dialog)``;
|
||||
Reference in New Issue
Block a user