mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix: task form dialog.
This commit is contained in:
7
src/common/modalChargeOptions.tsx
Normal file
7
src/common/modalChargeOptions.tsx
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
|
export const modalChargeOptions = [
|
||||||
|
{ name: 'Hourly rate', value: 'Hourly rate' },
|
||||||
|
{ name: 'Fixed price', value: 'Fixed price' },
|
||||||
|
{ name: 'Non-chargeable', value: 'Non-chargeable' },
|
||||||
|
];
|
||||||
@@ -3,12 +3,12 @@ import intl from 'react-intl-universal';
|
|||||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||||
|
|
||||||
const Schema = Yup.object().shape({
|
const Schema = Yup.object().shape({
|
||||||
taksName: Yup.string()
|
taskName: Yup.string()
|
||||||
.label(intl.get('task.schema.label.task_name'))
|
.label(intl.get('task.schema.label.task_name'))
|
||||||
.required(),
|
.required(),
|
||||||
taskHouse: Yup.string().label(intl.get('task.schema.label.task_house')),
|
taskHouse: Yup.string().label(intl.get('task.schema.label.task_house')),
|
||||||
change: Yup.string().label(intl.get('task.schema.label.charge')).required(),
|
taskCharge: Yup.string().label(intl.get('task.schema.label.charge')).required(),
|
||||||
amount: Yup.number().label(intl.get('task.schema.label.amount')),
|
taskamount: Yup.number().label(intl.get('task.schema.label.amount')),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const CreateTaskFormSchema = Schema;
|
export const CreateTaskFormSchema = Schema;
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
|
|||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
const defaultInitialValues = {
|
const defaultInitialValues = {
|
||||||
taksName: '',
|
taskName: '',
|
||||||
taskHouse: '00:00',
|
taskHouse: '00:00',
|
||||||
change: 'Hourly Rate',
|
taskCharge: 'Hourly rate',
|
||||||
changeAmount: '100000000',
|
taskamount: '100000000',
|
||||||
amount: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
import { Classes, ControlGroup } from '@blueprintjs/core';
|
import { Classes, ControlGroup } from '@blueprintjs/core';
|
||||||
import {
|
import {
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
@@ -8,23 +9,29 @@ import {
|
|||||||
Row,
|
Row,
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
} from 'components';
|
} from 'components';
|
||||||
|
import { modalChargeOptions } from '../../../../common/modalChargeOptions';
|
||||||
|
|
||||||
|
import { TaskModalChargeSelect } from './components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task form fields.
|
* Task form fields.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function TaskFormFields() {
|
function TaskFormFields() {
|
||||||
|
// Formik context.
|
||||||
|
const { values } = useFormikContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={Classes.DIALOG_BODY}>
|
<div className={Classes.DIALOG_BODY}>
|
||||||
{/*------------ Task Name -----------*/}
|
{/*------------ Task Name -----------*/}
|
||||||
<FFormGroup label={<T id={'task.label.task_name'} />} name={'task_name'}>
|
<FFormGroup label={<T id={'task.dialog.task_name'} />} name={'taskName'}>
|
||||||
<FInputGroup name="taskName" />
|
<FInputGroup name="taskName" />
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
{/*------------ Estimated Hours -----------*/}
|
{/*------------ Estimated Hours -----------*/}
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs={4}>
|
<Col xs={4}>
|
||||||
<FFormGroup
|
<FFormGroup
|
||||||
label={<T id={'task.label.estimated_hours'} />}
|
label={<T id={'task.dialog.estimated_hours'} />}
|
||||||
name={'taskHouse'}
|
name={'taskHouse'}
|
||||||
>
|
>
|
||||||
<FInputGroup name="taskHouse" />
|
<FInputGroup name="taskHouse" />
|
||||||
@@ -32,10 +39,19 @@ function TaskFormFields() {
|
|||||||
</Col>
|
</Col>
|
||||||
{/*------------ Charge -----------*/}
|
{/*------------ Charge -----------*/}
|
||||||
<Col xs={8}>
|
<Col xs={8}>
|
||||||
<FFormGroup label={<T id={'task.label.charge'} />} name={'Charge'}>
|
<FFormGroup
|
||||||
|
name={'taskCharge'}
|
||||||
|
className={'form-group--select-list'}
|
||||||
|
label={<T id={'task.dialog.charge'} />}
|
||||||
|
>
|
||||||
<ControlGroup>
|
<ControlGroup>
|
||||||
<FInputGroup name="change" />
|
<TaskModalChargeSelect
|
||||||
<FInputGroup name="changeAmount" />
|
name="taskCharge"
|
||||||
|
items={modalChargeOptions}
|
||||||
|
popoverProps={{ minimal: true }}
|
||||||
|
filterable={false}
|
||||||
|
/>
|
||||||
|
<FInputGroup name="taskamount" />
|
||||||
</ControlGroup>
|
</ControlGroup>
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
</Col>
|
</Col>
|
||||||
@@ -43,7 +59,7 @@ function TaskFormFields() {
|
|||||||
{/*------------ Estimated Amount -----------*/}
|
{/*------------ Estimated Amount -----------*/}
|
||||||
<EstimatedAmountBase>
|
<EstimatedAmountBase>
|
||||||
<EstimatedAmountContent>
|
<EstimatedAmountContent>
|
||||||
<T id={'task.label.estimated_amount'} />
|
<T id={'task.dialog.estimated_amount'} />
|
||||||
<EstimateAmount>$100000</EstimateAmount>
|
<EstimateAmount>$100000</EstimateAmount>
|
||||||
</EstimatedAmountContent>
|
</EstimatedAmountContent>
|
||||||
</EstimatedAmountBase>
|
</EstimatedAmountBase>
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { MenuItem, Button } from '@blueprintjs/core';
|
||||||
|
import { FSelect } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {*}
|
||||||
|
* @param {*} param1
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const taskModalChargeRenderer = (item, { handleClick, modifiers, query }) => {
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
label={item.label}
|
||||||
|
key={item.name}
|
||||||
|
onClick={handleClick}
|
||||||
|
text={item.name}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const taskModalChargeSelectProps = {
|
||||||
|
itemRenderer: taskModalChargeRenderer,
|
||||||
|
valueAccessor: 'value',
|
||||||
|
labelAccessor: 'name',
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param param0
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function TaskModalChargeSelect({ items, ...rest }) {
|
||||||
|
return (
|
||||||
|
<FSelect
|
||||||
|
{...taskModalChargeSelectProps}
|
||||||
|
{...rest}
|
||||||
|
items={items}
|
||||||
|
input={TaskModalChargeSelectButton}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param param0
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function TaskModalChargeSelectButton({ label }) {
|
||||||
|
return <Button text={label} />;
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ function TaskFormDialog({ dialogName, payload: { taskId = null }, isOpen }) {
|
|||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
name={dialogName}
|
name={dialogName}
|
||||||
title={intl.get('task.label.new_task')}
|
title={intl.get('task.dialog.new_task')}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
canEscapeKeyClose={true}
|
canEscapeKeyClose={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user