-
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.
Showing
22 changed files
with
862 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
export {searchPurchaseRequest as searchPurchaseRequestApi} from './purchase-request-api'; | ||
export {searchSupplier as searchSupplierApi} from './supplier-api'; |
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,68 @@ | ||
/* | ||
* 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 { | ||
createStandardSearch, | ||
getSearchCriterias, | ||
} from '@axelor/aos-mobile-core'; | ||
|
||
const createPurchaseRequestCriteria = ({searchValue, statusList, supplier}) => { | ||
const criterias = [ | ||
getSearchCriterias('purchase_purchaseRequest', searchValue), | ||
]; | ||
|
||
if (supplier) { | ||
criterias.push({ | ||
fieldName: 'supplierPartner.id', | ||
operator: '=', | ||
value: supplier.id, | ||
}); | ||
} | ||
|
||
if (Array.isArray(statusList) && statusList.length > 0) { | ||
criterias.push({ | ||
operator: 'or', | ||
criteria: statusList.map(status => ({ | ||
fieldName: 'statusSelect', | ||
operator: '=', | ||
value: status.key, | ||
})), | ||
}); | ||
} | ||
|
||
return criterias; | ||
}; | ||
|
||
export async function searchPurchaseRequest({ | ||
page = 0, | ||
searchValue, | ||
statusList, | ||
supplier, | ||
}) { | ||
return createStandardSearch({ | ||
model: 'com.axelor.apps.purchase.db.PurchaseRequest', | ||
criteria: createPurchaseRequestCriteria({ | ||
searchValue, | ||
statusList, | ||
supplier, | ||
}), | ||
fieldKey: 'purchase_purchaseRequest', | ||
sortKey: 'purchase_purchaseRequest', | ||
page, | ||
}); | ||
} |
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,50 @@ | ||
/* | ||
* 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 { | ||
createStandardSearch, | ||
getSearchCriterias, | ||
} from '@axelor/aos-mobile-core'; | ||
|
||
const createSupplierCriteria = searchValue => { | ||
const criterias = [ | ||
getSearchCriterias('purchase_supplier', searchValue), | ||
{ | ||
fieldName: 'isContact', | ||
operator: '=', | ||
value: false, | ||
}, | ||
{ | ||
fieldName: 'isSupplier', | ||
operator: '=', | ||
value: true, | ||
}, | ||
]; | ||
|
||
return criterias; | ||
}; | ||
|
||
export async function searchSupplier({page = 0, searchValue}) { | ||
return createStandardSearch({ | ||
model: 'com.axelor.apps.base.db.Partner', | ||
criteria: createSupplierCriteria(searchValue), | ||
fieldKey: 'purchase_supplier', | ||
sortKey: 'purchase_supplier', | ||
page, | ||
}); | ||
} |
81 changes: 81 additions & 0 deletions
81
packages/apps/purchase/src/components/atoms/RequestCard/RequestCard.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} from '@axelor/aos-mobile-ui'; | ||
import {useTypeHelpers, useTypes} from '@axelor/aos-mobile-core'; | ||
|
||
interface RequestCardProps { | ||
style?: any; | ||
companyName: string; | ||
supplierPartnerName: string; | ||
reference: string; | ||
statusSelect: number; | ||
onPress: () => void; | ||
} | ||
|
||
const RequestCard = ({ | ||
style, | ||
companyName, | ||
supplierPartnerName, | ||
reference, | ||
statusSelect, | ||
onPress, | ||
}: RequestCardProps) => { | ||
const {PurchaseRequest} = useTypes(); | ||
const {getItemColor} = useTypeHelpers(); | ||
|
||
const borderStyle = useMemo(() => { | ||
return getStyles( | ||
getItemColor(PurchaseRequest?.statusSelect, statusSelect)?.background, | ||
)?.border; | ||
}, [PurchaseRequest?.statusSelect, getItemColor, statusSelect]); | ||
|
||
return ( | ||
<ObjectCard | ||
onPress={onPress} | ||
style={[borderStyle, style]} | ||
upperTexts={{ | ||
items: [ | ||
{ | ||
isTitle: true, | ||
displayText: reference, | ||
}, | ||
{ | ||
iconName: 'person-fill', | ||
indicatorText: supplierPartnerName, | ||
hideIfNull: true, | ||
}, | ||
{ | ||
iconName: 'building', | ||
indicatorText: companyName, | ||
hideIfNull: true, | ||
}, | ||
], | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
const getStyles = (color: string) => | ||
StyleSheet.create({ | ||
border: {borderLeftWidth: 7, borderLeftColor: color}, | ||
}); | ||
|
||
export default RequestCard; |
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,19 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
export {default as RequestCard} from './RequestCard/RequestCard'; |
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,20 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
export * from './atoms'; | ||
export * from './templates'; |
78 changes: 78 additions & 0 deletions
78
packages/apps/purchase/src/components/templates/SupplierSearchBar/SupplierSearchBar.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,78 @@ | ||
/* | ||
* 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, {useCallback} from 'react'; | ||
import {useDispatch, useSelector, useTranslator} from '@axelor/aos-mobile-core'; | ||
import {AutoCompleteSearch} from '@axelor/aos-mobile-ui'; | ||
import {searchSupplier} from '../../../features/supplierSlice'; | ||
|
||
const displaySimpleFullName = item => item.simpleFullName; | ||
|
||
interface SupplierSearchBarProps { | ||
placeholderKey?: string; | ||
defaultValue: any; | ||
showDetailsPopup?: boolean; | ||
navigate?: boolean; | ||
oneFilter?: boolean; | ||
onChange: (value: any) => void; | ||
} | ||
|
||
const SupplierSearchBar = ({ | ||
placeholderKey = 'Purchase_Supplier', | ||
defaultValue = '', | ||
onChange = () => {}, | ||
showDetailsPopup = true, | ||
navigate = false, | ||
oneFilter = false, | ||
}: SupplierSearchBarProps) => { | ||
const I18n = useTranslator(); | ||
const dispatch = useDispatch(); | ||
|
||
const { | ||
supplierList, | ||
loadingSuppliers, | ||
moreLoadingSupplier, | ||
isListEndSupplier, | ||
} = useSelector(state => state.purchase_supplier); | ||
|
||
const fetchSupplierAPI = useCallback( | ||
({page = 0, searchValue}) => { | ||
dispatch((searchSupplier as any)({page, searchValue})); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return ( | ||
<AutoCompleteSearch | ||
objectList={supplierList} | ||
value={defaultValue} | ||
onChangeValue={onChange} | ||
fetchData={fetchSupplierAPI} | ||
displayValue={displaySimpleFullName} | ||
placeholder={I18n.t(placeholderKey)} | ||
showDetailsPopup={showDetailsPopup} | ||
loadingList={loadingSuppliers} | ||
moreLoading={moreLoadingSupplier} | ||
isListEnd={isListEndSupplier} | ||
navigate={navigate} | ||
oneFilter={oneFilter} | ||
/> | ||
); | ||
}; | ||
|
||
export default SupplierSearchBar; |
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,19 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
export {default as SupplierSearchBar} from './SupplierSearchBar/SupplierSearchBar'; |
20 changes: 20 additions & 0 deletions
20
packages/apps/purchase/src/features/asyncFunctions-index.ts
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,20 @@ | ||
/* | ||
* 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/>. | ||
*/ | ||
|
||
export {searchPurchaseRequest} from './purchaseRequestSlice'; | ||
export {searchSupplier} from './supplierSlice'; |
Oops, something went wrong.