diff --git a/client/src/components/FilterDropdown.js b/client/src/components/FilterDropdown.js index f37dc4d58..0c4a8903c 100644 --- a/client/src/components/FilterDropdown.js +++ b/client/src/components/FilterDropdown.js @@ -42,212 +42,221 @@ export default function FilterDropdown({ refetchDebounceWait = 10, initialCondition, }) { - const { formatMessage } = useIntl(); - const fieldsKeyMapped = new Map(fields.map((field) => [field.key, field])); - - const conditionalsItems = useMemo( - () => [ - { value: 'and', label: formatMessage({ id: 'and' }) }, - { value: 'or', label: formatMessage({ id: 'or' }) }, - ], - [formatMessage], - ); - - const resourceFields = useMemo( - () => [ - ...fields.map((field) => ({ - value: field.key, - label: field.label_name, - })), - ], - [fields], - ); - - const defaultFilterCondition = useMemo( - () => ({ - condition: 'and', - field_key: initialCondition.fieldKey, - comparator: initialCondition.comparator, - value: initialCondition.value, - }), - [fields], - ); - - const { setFieldValue, getFieldProps, values } = useFormik({ - enableReinitialize: true, - initialValues: { - conditions: [defaultFilterCondition], - }, - }); - - const onClickNewFilter = useCallback(() => { - if (values.conditions.length >= 12) { - limitToast = Toaster.show( - { - message: formatMessage({ id: 'you_reached_conditions_limit' }), - intent: Intent.WARNING, - }, - limitToast, - ); - } else { - setFieldValue('conditions', [ - ...values.conditions, - last(values.conditions), - ]); - } - }, [values, defaultFilterCondition, setFieldValue]); - - const filteredFilterConditions = useMemo(() => { - const requiredProps = ['field_key', 'condition', 'comparator', 'value']; - const conditions = values.conditions.filter( - (condition) => !checkRequiredProperties(condition, requiredProps), - ); - return uniqueMultiProps(conditions, requiredProps); - }, [values.conditions]); - - const prevConditions = usePrevious(filteredFilterConditions); - - const onFilterChangeThrottled = useRef( - debounce((conditions) => { - onFilterChange && onFilterChange(conditions); - }, refetchDebounceWait), - ); - - useEffect(() => { - if (!isEqual(prevConditions, filteredFilterConditions) && prevConditions) { - onFilterChange && onFilterChange(filteredFilterConditions); - } - }, [filteredFilterConditions, prevConditions]); - - // Handle click remove condition. - const onClickRemoveCondition = (index) => () => { - if (values.conditions.length === 1) { - setFieldValue('conditions', [defaultFilterCondition]); - return; - } - const conditions = [...values.conditions]; - conditions.splice(index, 1); - setFieldValue('conditions', [...conditions]); - }; - - // Transform dynamic value field. - const transformValueField = (value) => { - if (value instanceof Date) { - return moment(value).format('YYYY-MM-DD'); - } else if (typeof value === 'object') { - return value.id; - } - return value; - }; - // Override getFieldProps for conditions fields. - const fieldProps = (name, index) => { - const override = { - ...getFieldProps(`conditions[${index}].${name}`), - }; - return { - ...override, - onChange: (e) => { - if (name === 'field_key') { - const currentField = fieldsKeyMapped.get( - values.conditions[index].field_key, - ); - const nextField = fieldsKeyMapped.get(e.currentTarget.value); - - if (currentField.data_type !== nextField.data_type) { - setFieldValue(`conditions[${index}].value`, ''); - } - const comparatorsObs = getConditionTypeCompatators(nextField.data_type); - const currentCompatator = values.conditions[index].comparator; - - if (!currentCompatator || comparatorsObs.map(c => c.value).indexOf(currentCompatator) === -1) { - const defaultCompatator = getConditionDefaultCompatator(nextField.data_type); - setFieldValue(`conditions[${index}].comparator`, defaultCompatator.value); - } - } - override.onChange(e); - }, - }; - }; - - // Compatator field props. - const comparatorFieldProps = (name, index) => { - const condition = values.conditions[index]; - const field = fieldsKeyMapped.get(condition.field_key); - - return { - ...fieldProps(name, index), - dataType: field.data_type, - }; - }; - - // Value field props. - const valueFieldProps = (name, index) => { - const condition = values.conditions[index]; - const field = fieldsKeyMapped.get(condition.field_key); - - return { - ...fieldProps(name, index), - dataType: field.data_type, - resourceKey: field.resource_key, - options: field.options, - dataResource: field.data_resource, - onChange: (value) => { - const transformedValue = transformValueField(value); - setFieldValue(`conditions[${index}].${name}`, transformedValue); - }, - }; - }; return (
- {values.conditions.map((condition, index) => ( -
- - 1} - {...fieldProps('condition', index)} - /> - - - - - - - - - - - -
- ))} -
- -
); + + // const { formatMessage } = useIntl(); + // const fieldsKeyMapped = new Map(fields.map((field) => [field.key, field])); + + // const conditionalsItems = useMemo( + // () => [ + // { value: 'and', label: formatMessage({ id: 'and' }) }, + // { value: 'or', label: formatMessage({ id: 'or' }) }, + // ], + // [formatMessage], + // ); + + // const resourceFields = useMemo( + // () => [ + // ...fields.map((field) => ({ + // value: field.key, + // label: field.label_name, + // })), + // ], + // [fields], + // ); + + // const defaultFilterCondition = useMemo( + // () => ({ + // condition: 'and', + // field_key: initialCondition.fieldKey, + // comparator: initialCondition.comparator, + // value: initialCondition.value, + // }), + // [fields], + // ); + + // const { setFieldValue, getFieldProps, values } = useFormik({ + // enableReinitialize: true, + // initialValues: { + // conditions: [defaultFilterCondition], + // }, + // }); + + // const onClickNewFilter = useCallback(() => { + // if (values.conditions.length >= 12) { + // limitToast = Toaster.show( + // { + // message: formatMessage({ id: 'you_reached_conditions_limit' }), + // intent: Intent.WARNING, + // }, + // limitToast, + // ); + // } else { + // setFieldValue('conditions', [ + // ...values.conditions, + // last(values.conditions), + // ]); + // } + // }, [values, defaultFilterCondition, setFieldValue]); + + // const filteredFilterConditions = useMemo(() => { + // const requiredProps = ['field_key', 'condition', 'comparator', 'value']; + // const conditions = values.conditions.filter( + // (condition) => !checkRequiredProperties(condition, requiredProps), + // ); + // return uniqueMultiProps(conditions, requiredProps); + // }, [values.conditions]); + + // const prevConditions = usePrevious(filteredFilterConditions); + + // const onFilterChangeThrottled = useRef( + // debounce((conditions) => { + // onFilterChange && onFilterChange(conditions); + // }, refetchDebounceWait), + // ); + + // useEffect(() => { + // if (!isEqual(prevConditions, filteredFilterConditions) && prevConditions) { + // onFilterChange && onFilterChange(filteredFilterConditions); + // } + // }, [filteredFilterConditions, prevConditions]); + + // // Handle click remove condition. + // const onClickRemoveCondition = (index) => () => { + // if (values.conditions.length === 1) { + // setFieldValue('conditions', [defaultFilterCondition]); + // return; + // } + // const conditions = [...values.conditions]; + // conditions.splice(index, 1); + // setFieldValue('conditions', [...conditions]); + // }; + + // // Transform dynamic value field. + // const transformValueField = (value) => { + // if (value instanceof Date) { + // return moment(value).format('YYYY-MM-DD'); + // } else if (typeof value === 'object') { + // return value.id; + // } + // return value; + // }; + // // Override getFieldProps for conditions fields. + // const fieldProps = (name, index) => { + // const override = { + // ...getFieldProps(`conditions[${index}].${name}`), + // }; + // return { + // ...override, + // onChange: (e) => { + // if (name === 'field_key') { + // const currentField = fieldsKeyMapped.get( + // values.conditions[index].field_key, + // ); + // const nextField = fieldsKeyMapped.get(e.currentTarget.value); + + // if (currentField.data_type !== nextField.data_type) { + // setFieldValue(`conditions[${index}].value`, ''); + // } + // const comparatorsObs = getConditionTypeCompatators(nextField.data_type); + // const currentCompatator = values.conditions[index].comparator; + + // if (!currentCompatator || comparatorsObs.map(c => c.value).indexOf(currentCompatator) === -1) { + // const defaultCompatator = getConditionDefaultCompatator(nextField.data_type); + // setFieldValue(`conditions[${index}].comparator`, defaultCompatator.value); + // } + // } + // override.onChange(e); + // }, + // }; + // }; + + // // Compatator field props. + // const comparatorFieldProps = (name, index) => { + // const condition = values.conditions[index]; + // const field = fieldsKeyMapped.get(condition.field_key); + + // return { + // ...fieldProps(name, index), + // dataType: field.data_type, + // }; + // }; + + // // Value field props. + // const valueFieldProps = (name, index) => { + // const condition = values.conditions[index]; + // const field = fieldsKeyMapped.get(condition.field_key); + + // return { + // ...fieldProps(name, index), + // dataType: field.data_type, + // resourceKey: field.resource_key, + // options: field.options, + // dataResource: field.data_resource, + // onChange: (value) => { + // const transformedValue = transformValueField(value); + // setFieldValue(`conditions[${index}].${name}`, transformedValue); + // }, + // }; + // }; + + // return ( + //
+ //
+ // {values.conditions.map((condition, index) => ( + //
+ // + // 1} + // {...fieldProps('condition', index)} + // /> + // + + // + // + // + + // + // + // + + // + + //
+ // ))} + //
+ + // + //
+ // ); } diff --git a/client/src/containers/Accounts/AccountsDataTable.js b/client/src/containers/Accounts/AccountsDataTable.js index 39493f877..c1f73689f 100644 --- a/client/src/containers/Accounts/AccountsDataTable.js +++ b/client/src/containers/Accounts/AccountsDataTable.js @@ -224,7 +224,7 @@ function AccountsDataTable({ { id: 'type', Header: formatMessage({ id: 'type' }), - accessor: 'type.name', + accessor: 'type.label', className: 'type', width: 140, }, diff --git a/client/src/containers/Settings/withSettings.js b/client/src/containers/Settings/withSettings.js index e0f9a70f9..54f8b355b 100644 --- a/client/src/containers/Settings/withSettings.js +++ b/client/src/containers/Settings/withSettings.js @@ -2,6 +2,7 @@ import { connect } from 'react-redux'; export const mapStateToProps = (state, props) => ({ organizationSettings: state.settings.data.organization, + manualJournalsSettings: state.settings.data.manual_journals, }); export default connect(mapStateToProps); diff --git a/client/src/store/accounts/accounts.actions.js b/client/src/store/accounts/accounts.actions.js index b4e470207..082c5d23a 100644 --- a/client/src/store/accounts/accounts.actions.js +++ b/client/src/store/accounts/accounts.actions.js @@ -35,9 +35,6 @@ export const fetchAccountsList = () => { payload: { accounts: response.data.accounts, } - }) - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, }); resolve(response); }) @@ -71,7 +68,7 @@ export const fetchAccountsTable = ({ query } = {}) => { dispatch({ type: t.ACCOUNTS_PAGE_SET, accounts: response.data.accounts, - customViewId: response.data.customViewId, + customViewId: response.data?.filter_meta?.view?.custom_view_id, }); dispatch({ type: t.ACCOUNTS_ITEMS_SET, @@ -81,15 +78,9 @@ export const fetchAccountsTable = ({ query } = {}) => { type: t.ACCOUNTS_TABLE_LOADING, loading: false, }); - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); resolve(response); }) .catch((error) => { - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); reject(error); }); }); @@ -122,9 +113,6 @@ export const submitAccount = ({ form }) => { dispatch({ type: t.ACCOUNT_ERRORS_CLEAR, }); - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); resolve(response); }) .catch((error) => { @@ -140,9 +128,6 @@ export const submitAccount = ({ form }) => { payload: { error }, }); } - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); reject(data?.errors); }); }); @@ -157,9 +142,6 @@ export const editAccount = (id, form) => { ApiService.post(`accounts/${id}`, form) .then((response) => { dispatch({ type: t.CLEAR_ACCOUNT_FORM_ERRORS }); - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); resolve(response); }) .catch((error) => { @@ -170,9 +152,6 @@ export const editAccount = (id, form) => { if (error) { dispatch({ type: t.ACCOUNT_FORM_ERRORS, error }); } - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); reject(data?.errors); }); }); diff --git a/client/src/store/resources/resources.actions.js b/client/src/store/resources/resources.actions.js index 28411456d..fbd30e19c 100644 --- a/client/src/store/resources/resources.actions.js +++ b/client/src/store/resources/resources.actions.js @@ -4,14 +4,14 @@ import t from 'store/types'; export const fetchResourceColumns = ({ resourceSlug }) => { return (dispatch) => new Promise((resolve, reject) => { ApiService.get(`resources/${resourceSlug}/columns`).then((response) => { - dispatch({ - type: t.RESOURCE_COLUMNS_SET, - columns: response.data.resource_columns, - resource_slug: resourceSlug, - }); - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); + // dispatch({ + // type: t.RESOURCE_COLUMNS_SET, + // columns: response.data.resource_columns, + // resource_slug: resourceSlug, + // }); + // dispatch({ + // type: t.SET_DASHBOARD_REQUEST_COMPLETED, + // }); resolve(response); }).catch((error) => { reject(error); }); }); @@ -20,14 +20,14 @@ export const fetchResourceColumns = ({ resourceSlug }) => { export const fetchResourceFields = ({ resourceSlug }) => { return (dispatch) => new Promise((resolve, reject) => { ApiService.get(`resources/${resourceSlug}/fields`).then((response) => { - dispatch({ - type: t.RESOURCE_FIELDS_SET, - fields: response.data.resource_fields, - resource_slug: resourceSlug, - }); - dispatch({ - type: t.SET_DASHBOARD_REQUEST_COMPLETED, - }); + // dispatch({ + // type: t.RESOURCE_FIELDS_SET, + // fields: response.data.resource_fields, + // resource_slug: resourceSlug, + // }); + // dispatch({ + // type: t.SET_DASHBOARD_REQUEST_COMPLETED, + // }); resolve(response); }).catch((error) => { reject(error); }); }); @@ -36,13 +36,13 @@ export const fetchResourceFields = ({ resourceSlug }) => { export const fetchResourceData = ({ resourceSlug }) => { return (dispatch) => new Promise((resolve, reject) => { ApiService.get(`/resources/${resourceSlug}/data`).then((response) => { - dispatch({ - type: t.RESOURCE_DATA_SET, - payload: { - data: response.data.data, - resource_key: resourceSlug, - }, - }); + // dispatch({ + // type: t.RESOURCE_DATA_SET, + // payload: { + // data: response.data.data, + // resource_key: resourceSlug, + // }, + // }); resolve(response); }).catch(error => { reject(error); }); }); diff --git a/client/src/style/pages/dashboard.scss b/client/src/style/pages/dashboard.scss index d69d831c1..a2ec8ccb0 100644 --- a/client/src/style/pages/dashboard.scss +++ b/client/src/style/pages/dashboard.scss @@ -4,18 +4,10 @@ display: flex; height: 100vh; - &:before{ - content: ""; - height: 1px; - background: #01194e; - position: fixed; - top: 0; - width: 100%; - } &__topbar{ width: 100%; - min-height: 62px; + min-height: 60px; display: flex; justify-content: space-between; border-bottom: 1px solid #F2EFEF; @@ -210,9 +202,9 @@ margin-left: 2px; h1{ - font-size: 26px; - font-weight: 300; - color: #2c2c39; + font-size: 22px; + color: #333363; + font-weight: 400; margin: 0; } h3{ @@ -220,7 +212,7 @@ padding-left: 10px; font-size: 16px; font-weight: 300; - color: #777; + color: #101052; margin: 0 0 0 12px; padding-top: 4px; padding-bottom: 4px; @@ -268,6 +260,15 @@ flex-direction: column; height: 100%; + &:before{ + content: ""; + height: 1px; + background: #01194e; + position: fixed; + top: 0; + width: 100%; + } + .sidebar--mini-sidebar + &{ margin-left: 50px; width: calc(100% - 50px); diff --git a/client/src/style/pages/make-journal-entries.scss b/client/src/style/pages/make-journal-entries.scss index d6571270c..89fa81c58 100644 --- a/client/src/style/pages/make-journal-entries.scss +++ b/client/src/style/pages/make-journal-entries.scss @@ -103,11 +103,15 @@ .td.actions{ .bp3-button{ background-color: transparent; - color: #E68F8E; + color: #e66d6d; &:hover{ color: #c23030; } + + svg{ + color: inherit; + } } } diff --git a/server/src/database/seeds/core/20200810121808_seed_views_roles.js b/server/src/database/seeds/core/20200810121808_seed_views_roles.js index 3f2e0acde..5a9adaa6c 100644 --- a/server/src/database/seeds/core/20200810121808_seed_views_roles.js +++ b/server/src/database/seeds/core/20200810121808_seed_views_roles.js @@ -14,14 +14,14 @@ exports.up = (knex) => { { id: 12, field_key: 'active', index: 1, comparator: 'is', value: 1, view_id: 15 }, // Items. - { id: 6, field_id: 12, index: 1, comparator: 'equals', value: 'service', view_id: 6 }, - { id: 7, field_id: 12, index: 1, comparator: 'equals', value: 'inventory', view_id: 7 }, - { id: 8, field_id: 12, index: 1, comparator: 'equals', value: 'non-inventory', view_id: 8 }, + { id: 6, field_key: 'type', index: 1, comparator: 'equals', value: 'service', view_id: 6 }, + { id: 7, field_key: 'type', index: 1, comparator: 'equals', value: 'inventory', view_id: 7 }, + { id: 8, field_key: 'type', index: 1, comparator: 'equals', value: 'non-inventory', view_id: 8 }, // Manual Journals. - { id: 9, field_id: 26, index: 1, comparator: 'equals', value: 'Journal', view_id: 9 }, - { id: 10, field_id: 26, index: 1, comparator: 'equals', value: 'CreditNote', view_id: 10 }, - { id: 11, field_id: 26, index: 1, comparator: 'equals', value: 'Reconciliation', view_id: 11 }, + { id: 9, field_key: 'journal_type', index: 1, comparator: 'equals', value: 'Journal', view_id: 9 }, + { id: 10, field_key: 'journal_type', index: 1, comparator: 'equals', value: 'CreditNote', view_id: 10 }, + { id: 11, field_key: 'journal_type', index: 1, comparator: 'equals', value: 'Reconciliation', view_id: 11 }, ]); }); };