diff --git a/client/src/containers/Drawers/ItemDetailDrawer/ItemContentDetails.js b/client/src/containers/Drawers/ItemDetailDrawer/ItemContentDetails.js
new file mode 100644
index 000000000..140e72543
--- /dev/null
+++ b/client/src/containers/Drawers/ItemDetailDrawer/ItemContentDetails.js
@@ -0,0 +1,21 @@
+import React from 'react';
+
+import ItemDetailActionsBar from './ItemDetailActionsBar';
+import ItemDetailHeader from './ItemDetailHeader';
+
+import { Card } from 'components';
+
+/**
+ * Item detail.
+ */
+export default function ItemDetail() {
+ return (
+
+
+
+
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetail.js b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetail.js
deleted file mode 100644
index b30f45100..000000000
--- a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetail.js
+++ /dev/null
@@ -1,21 +0,0 @@
-import React from 'react';
-import { useItemDetailDrawerContext } from './ItemDetailDrawerProvider';
-import ItemDetailActionsBar from './ItemDetailActionsBar';
-import ItemDetailList from './ItemDetailList';
-import { Card } from 'components';
-
-/**
- * Item detail.
- */
-export default function ItemDetail() {
- const { itemId, item } = useItemDetailDrawerContext();
-
- return (
-
-
-
-
-
-
- );
-}
diff --git a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.js b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.js
index 2aa23f2b4..8db499898 100644
--- a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.js
+++ b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailActionsBar.js
@@ -9,38 +9,39 @@ import {
} from '@blueprintjs/core';
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
+import { useItemDetailDrawerContext } from './ItemDetailDrawerProvider';
+
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { Icon, FormattedMessage as T } from 'components';
-import { safeCallback, compose } from 'utils';
+import { compose } from 'utils';
+/**
+ * Item action-bar of readonly details drawer.
+ */
function ItemDetailActionsBar({
- itemId,
-
// #withAlertsActions
openAlert,
// #withDrawerActions
closeDrawer,
}) {
+ // Item readonly drawer context.
+ const { itemId } = useItemDetailDrawerContext();
+
const history = useHistory();
// Handle edit item.
- const onEditItem = () => {
- return itemId
- ? (history.push(`/items/${itemId}/edit`),
- closeDrawer('item-detail-drawer'))
- : null;
+ const handleEditItem = () => {
+ history.push(`/items/${itemId}/edit`);
+ closeDrawer('item-detail-drawer');
};
// Handle delete item.
- const onDeleteItem = () => {
- return itemId
- ? (openAlert('item-delete', { itemId }),
- closeDrawer('item-detail-drawer'))
- : null;
+ const handleDeleteItem = () => {
+ openAlert('item-delete', { itemId });
};
return (
@@ -50,7 +51,7 @@ function ItemDetailActionsBar({
className={Classes.MINIMAL}
icon={}
text={}
- onClick={safeCallback(onEditItem)}
+ onClick={handleEditItem}
/>
}
text={}
intent={Intent.DANGER}
- onClick={safeCallback(onDeleteItem)}
+ onClick={handleDeleteItem}
/>
diff --git a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerContent.js b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerContent.js
index 91531126b..46ade648f 100644
--- a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerContent.js
+++ b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerContent.js
@@ -1,8 +1,8 @@
import React from 'react';
-import 'style/components/Drawers/ViewDetail/ViewDetail.scss';
+import 'style/components/Drawers/ItemDrawer.scss';
-import ItemDetail from './ItemDetail';
+import ItemContentDetails from './ItemContentDetails';
import { ItemDetailDrawerProvider } from './ItemDetailDrawerProvider';
/**
@@ -10,11 +10,11 @@ import { ItemDetailDrawerProvider } from './ItemDetailDrawerProvider';
*/
export default function ItemDetailDrawerContent({
// #ownProp
- item,
+ itemId,
}) {
return (
-
-
+
+
);
}
diff --git a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerProvider.js b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerProvider.js
index e05796f04..095f19962 100644
--- a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerProvider.js
+++ b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailDrawerProvider.js
@@ -17,6 +17,7 @@ function ItemDetailDrawerProvider({ itemId, ...props }) {
const provider = {
item,
itemId,
+ isItemLoading,
};
return (
diff --git a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailHeader.js b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailHeader.js
new file mode 100644
index 000000000..72fca7758
--- /dev/null
+++ b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailHeader.js
@@ -0,0 +1,80 @@
+import React from 'react';
+import intl from 'react-intl-universal';
+import { defaultTo } from 'lodash';
+import classNames from 'classnames';
+
+import { If, DetailsMenu, DetailItem } from 'components';
+import { useItemDetailDrawerContext } from './ItemDetailDrawerProvider';
+
+/**
+ * Item header drawer of readonly details.
+ */
+export default function ItemDetailHeader() {
+ const { item } = useItemDetailDrawerContext();
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ 0,
+ })}
+ >
+ {defaultTo(item.quantity_on_hand, '-')}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailList.js b/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailList.js
deleted file mode 100644
index 0e8e12493..000000000
--- a/client/src/containers/Drawers/ItemDetailDrawer/ItemDetailList.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import React from 'react';
-import intl from 'react-intl-universal';
-
-import { DetailItem } from '../../../components/Details';
-
-export default function ItemDetailList({
- item: {
- name,
- code,
- type,
- category,
- sell_price_formatted,
- cost_price_formatted,
- cost_account,
- sell_account,
- },
-}) {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/client/src/containers/Drawers/ItemDetailDrawer/index.js b/client/src/containers/Drawers/ItemDetailDrawer/index.js
index 0a52423bb..af6ef5569 100644
--- a/client/src/containers/Drawers/ItemDetailDrawer/index.js
+++ b/client/src/containers/Drawers/ItemDetailDrawer/index.js
@@ -21,7 +21,7 @@ function ItemDetailDrawer({
return (
-
+
);
diff --git a/client/src/containers/Items/ItemsUniversalSearch.js b/client/src/containers/Items/ItemsUniversalSearch.js
index 023ab5cc6..89be60fb4 100644
--- a/client/src/containers/Items/ItemsUniversalSearch.js
+++ b/client/src/containers/Items/ItemsUniversalSearch.js
@@ -9,12 +9,14 @@ function ItemUniversalSearchSelectComponent({
// #ownProps
resourceType,
resourceId,
+ onAction,
// #withDrawerActions
openDrawer,
}) {
if (resourceType === RESOURCES_TYPES.ITEM) {
-
+ openDrawer('item-detail-drawer', { itemId: resourceId });
+ onAction && onAction();
}
return null;
}
@@ -29,6 +31,7 @@ export const ItemUniversalSearchSelectAction = withDrawerActions(
* @returns
*/
const transfromItemsToSearch = (item) => ({
+ id: item.id,
text: item.name,
subText: item.code,
label: item.type,
diff --git a/client/src/lang/en/index.json b/client/src/lang/en/index.json
index e98174d20..7bd01e4c8 100644
--- a/client/src/lang/en/index.json
+++ b/client/src/lang/en/index.json
@@ -1209,5 +1209,7 @@
"invoice_preview.dialog.title": "Invoice PDF Preview",
"estimate_preview.dialog.title":"Estimate PDF Preview",
"receipt_preview.dialog.title":"Receipt PDF Preview",
- "edit_contact":"Edit {name}"
+ "edit_contact":"Edit {name}",
+ "item.sell_description": "Sell description",
+ "item.purchase_description": "Purchase description"
}
\ No newline at end of file
diff --git a/client/src/style/components/Details.scss b/client/src/style/components/Details.scss
index bdb4c3735..165d784f8 100644
--- a/client/src/style/components/Details.scss
+++ b/client/src/style/components/Details.scss
@@ -7,6 +7,7 @@
.detail-item{
flex-direction: column;
+ flex-grow: 1;
&__content{
margin: 5px 0;
diff --git a/client/src/style/components/Drawers/ItemDrawer.scss b/client/src/style/components/Drawers/ItemDrawer.scss
new file mode 100644
index 000000000..b97b84eaa
--- /dev/null
+++ b/client/src/style/components/Drawers/ItemDrawer.scss
@@ -0,0 +1,45 @@
+.item-drawer {
+
+ .card {
+ margin: 15px;
+ padding: 22px 15px;
+ }
+
+ &__content {
+
+ .detail-item--name {
+ width: 30%;
+
+ .detail-item__content {
+ font-weight: 600;
+ }
+ }
+
+ .detail-item--quantity {
+
+ .detail-item__content {
+ font-weight: 600;
+
+ .mines {
+ color: #c23030;
+ }
+ }
+ }
+
+ .details-menu--vertical {
+ padding-bottom: 15px;
+ border-bottom: 1px solid #e2e2e2;
+ }
+
+ .details-menu--horizantal {
+
+ .detail-item:not(:first-of-type) {
+ margin-top: 16px;
+ }
+
+ .detail-item__label {
+ min-width: 180px;
+ }
+ }
+ }
+}
\ No newline at end of file