-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1295618
commit 38f722d
Showing
11 changed files
with
261 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/apps/purchase/src/components/atoms/RequestLineCard/RequestLineCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Axelor Business Solutions | ||
* | ||
* Copyright (C) 2024 Axelor (<http://axelor.com>). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React, {useMemo} from 'react'; | ||
import {StyleSheet} from 'react-native'; | ||
import { | ||
ObjectCard, | ||
TextUnit, | ||
usePriceFormat, | ||
useThemeColor, | ||
} from '@axelor/aos-mobile-ui'; | ||
|
||
interface RequestLineCardProps { | ||
style?: any; | ||
productName?: string; | ||
unit?: string; | ||
qty?: string; | ||
newProduct?: boolean; | ||
} | ||
|
||
const RequestLineCard = ({ | ||
style, | ||
productName, | ||
unit, | ||
qty, | ||
newProduct, | ||
}: RequestLineCardProps) => { | ||
const priceFormat = usePriceFormat(); | ||
const Colors = useThemeColor(); | ||
|
||
const borderStyle = useMemo(() => { | ||
if (newProduct) { | ||
return getStyles(Colors.plannedColor.background)?.border; | ||
} | ||
}, [Colors.plannedColor.background, newProduct]); | ||
|
||
return ( | ||
<ObjectCard | ||
style={[borderStyle, style]} | ||
upperTexts={{ | ||
items: [ | ||
{ | ||
isTitle: true, | ||
displayText: productName, | ||
}, | ||
], | ||
}} | ||
sideBadges={{ | ||
items: [ | ||
{ | ||
customComponent: ( | ||
<TextUnit unit={unit} value={priceFormat(qty)} fontSize={20} /> | ||
), | ||
}, | ||
], | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
const getStyles = (color: string) => | ||
StyleSheet.create({ | ||
border: {borderLeftWidth: 7, borderLeftColor: color}, | ||
}); | ||
|
||
export default RequestLineCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
packages/apps/purchase/src/screens/RequestLineListScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Axelor Business Solutions | ||
* | ||
* Copyright (C) 2024 Axelor (<http://axelor.com>). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React, {useMemo, useState} from 'react'; | ||
import {ChipSelect, Screen} from '@axelor/aos-mobile-ui'; | ||
import { | ||
SearchListView, | ||
useSelector, | ||
useTranslator, | ||
useTypeHelpers, | ||
useTypes, | ||
} from '@axelor/aos-mobile-core'; | ||
import {RequestHeader, RequestLineCard} from '../components'; | ||
import {searchPurchaseRequestLine} from '../features/purchaseRequestLineSlice'; | ||
|
||
const RequestLineListScreen = () => { | ||
const I18n = useTranslator(); | ||
const {PurchaseRequestLine} = useTypes(); | ||
const {getSelectionItems} = useTypeHelpers(); | ||
|
||
const {purchaseRequest} = useSelector( | ||
state => state.purchase_purchaseRequest, | ||
); | ||
const { | ||
loadingPurchaseRequestLines, | ||
moreLoadingPurchaseRequestLine, | ||
isListEndPurchaseRequestLine, | ||
purchaseRequestLineList, | ||
} = useSelector(state => state.purchase_purchaseRequestLine); | ||
|
||
const [selectedStatus, setSelectedStatus] = useState([]); | ||
|
||
const statusList = useMemo( | ||
() => getSelectionItems(PurchaseRequestLine?.newProduct, selectedStatus), | ||
[PurchaseRequestLine?.newProduct, getSelectionItems, selectedStatus], | ||
); | ||
|
||
const sliceFunctionData = useMemo( | ||
() => ({ | ||
purchaseRequestId: purchaseRequest.id, | ||
newProduct: selectedStatus[0]?.value, | ||
}), | ||
[purchaseRequest.id, selectedStatus], | ||
); | ||
|
||
return ( | ||
<Screen removeSpaceOnTop={true}> | ||
<SearchListView | ||
topFixedItems={<RequestHeader />} | ||
actionList={[ | ||
{ | ||
iconName: 'plus', | ||
title: I18n.t('Purchase_AddProduct'), | ||
onPress: () => {}, | ||
}, | ||
]} | ||
chipComponent={ | ||
<ChipSelect | ||
mode="switch" | ||
onChangeValue={setSelectedStatus} | ||
selectionItems={statusList} | ||
/> | ||
} | ||
expandableFilter={false} | ||
searchPlaceholder={I18n.t('Base_Search')} | ||
list={purchaseRequestLineList} | ||
loading={loadingPurchaseRequestLines} | ||
moreLoading={moreLoadingPurchaseRequestLine} | ||
isListEnd={isListEndPurchaseRequestLine} | ||
sliceFunction={searchPurchaseRequestLine} | ||
sliceFunctionData={sliceFunctionData} | ||
renderListItem={({item}) => ( | ||
<RequestLineCard | ||
productName={item.product?.fullName} | ||
qty={item.quantity} | ||
unit={item.unit?.name} | ||
newProduct={item.newProduct} | ||
/> | ||
)} | ||
/> | ||
</Screen> | ||
); | ||
}; | ||
|
||
export default RequestLineListScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters