-
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
5ad415c
commit 1aca1c8
Showing
24 changed files
with
1,014 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
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,55 @@ | ||
/* | ||
* 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 createProductCriteria = ({searchValue}) => { | ||
const criterias = [ | ||
getSearchCriterias('purchase_product', searchValue), | ||
{ | ||
fieldName: 'isModel', | ||
operator: '=', | ||
value: false, | ||
}, | ||
{ | ||
fieldName: 'purchasable', | ||
operator: '=', | ||
value: true, | ||
}, | ||
{ | ||
fieldName: 'dtype', | ||
operator: '=', | ||
value: 'Product', | ||
}, | ||
]; | ||
|
||
return criterias; | ||
}; | ||
|
||
export async function searchProduct({page = 0, searchValue}) { | ||
return createStandardSearch({ | ||
model: 'com.axelor.apps.base.db.Product', | ||
criteria: createProductCriteria(searchValue), | ||
fieldKey: 'purchase_product', | ||
sortKey: 'purchase_product', | ||
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,32 @@ | ||
/* | ||
* 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'; | ||
|
||
export async function searchUnit({page = 0, searchValue}) { | ||
return createStandardSearch({ | ||
model: 'com.axelor.apps.base.db.Unit', | ||
criteria: [getSearchCriterias('purchase_unit', searchValue)], | ||
fieldKey: 'purchase_unit', | ||
sortKey: 'purchase_unit', | ||
page, | ||
}); | ||
} |
69 changes: 69 additions & 0 deletions
69
packages/apps/purchase/src/components/atoms/HorizontalRuleText/HorizontalRuleText.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,69 @@ | ||
/* | ||
* 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 from 'react'; | ||
import {View, StyleSheet, Text} from 'react-native'; | ||
import {HorizontalRule, useThemeColor} from '@axelor/aos-mobile-ui'; | ||
|
||
interface HorizontalRuleTextProps { | ||
text?: string; | ||
style?: any; | ||
textStyle?: any; | ||
} | ||
|
||
const HorizontalRuleText = ({ | ||
text = '', | ||
style, | ||
textStyle, | ||
}: HorizontalRuleTextProps) => { | ||
const Colors = useThemeColor(); | ||
|
||
return ( | ||
<View style={[styles.container, style]}> | ||
<HorizontalRule style={styles.line} /> | ||
<Text | ||
style={[ | ||
styles.text, | ||
{color: Colors.secondaryColor.foreground}, | ||
textStyle, | ||
]}> | ||
{text} | ||
</Text> | ||
<HorizontalRule style={styles.line} /> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
width: '100%', | ||
}, | ||
line: { | ||
flex: 1, | ||
marginHorizontal: 10, | ||
}, | ||
text: { | ||
fontSize: 14, | ||
textAlign: 'center', | ||
}, | ||
}); | ||
|
||
export default HorizontalRuleText; |
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
60 changes: 60 additions & 0 deletions
60
packages/apps/purchase/src/components/templates/CompanyPicker/CompanyPicker.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,60 @@ | ||
/* | ||
* 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 from 'react'; | ||
import {useSelector, useTranslator} from '@axelor/aos-mobile-core'; | ||
import {Picker} from '@axelor/aos-mobile-ui'; | ||
|
||
interface CompanyPickerProps { | ||
style?: any; | ||
company?: any; | ||
emptyValue?: boolean; | ||
onChange: (state: any) => void; | ||
} | ||
|
||
const CompanyPicker = ({ | ||
style, | ||
company, | ||
onChange = () => {}, | ||
emptyValue = true, | ||
}: CompanyPickerProps) => { | ||
const I18n = useTranslator(); | ||
|
||
const {user} = useSelector((state: any) => state.user); | ||
|
||
if (!Array.isArray(user?.companySet) || user.companySet.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Picker | ||
placeholder={I18n.t('Purchase_Company')} | ||
style={style} | ||
defaultValue={company} | ||
listItems={user?.companySet} | ||
valueField="id" | ||
labelField="name" | ||
onValueChange={onChange} | ||
isValueItem | ||
emptyValue={emptyValue} | ||
translator={I18n.t} | ||
/> | ||
); | ||
}; | ||
|
||
export default CompanyPicker; |
91 changes: 91 additions & 0 deletions
91
packages/apps/purchase/src/components/templates/ProductSearchBar/ProductSearchBar.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,91 @@ | ||
/* | ||
* 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 { | ||
displayItemName, | ||
useDispatch, | ||
useSelector, | ||
useTranslator, | ||
} from '@axelor/aos-mobile-core'; | ||
import {AutoCompleteSearch} from '@axelor/aos-mobile-ui'; | ||
import {searchProduct} from '../../../features/productSlice'; | ||
|
||
interface ProductSearchBarProps { | ||
style?: any; | ||
title?: string; | ||
showTitle?: boolean; | ||
defaultValue?: string; | ||
onChange?: (any: any) => void; | ||
readonly?: boolean; | ||
required?: boolean; | ||
isScrollViewContainer?: boolean; | ||
} | ||
|
||
const ProductSearchBar = ({ | ||
style = null, | ||
title = 'Sale_Product', | ||
showTitle = false, | ||
defaultValue = null, | ||
onChange = () => {}, | ||
readonly = false, | ||
required = false, | ||
isScrollViewContainer = false, | ||
}: ProductSearchBarProps) => { | ||
const I18n = useTranslator(); | ||
const dispatch = useDispatch(); | ||
|
||
const {loadingProducts, moreLoadingProduct, isListEndProduct, productList} = | ||
useSelector((state: any) => state.purchase_product); | ||
|
||
const searchProductAPI = useCallback( | ||
({page = 0, searchValue}) => { | ||
dispatch( | ||
(searchProduct as any)({ | ||
page, | ||
searchValue, | ||
}), | ||
); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return ( | ||
<AutoCompleteSearch | ||
style={style} | ||
title={showTitle && I18n.t(title)} | ||
objectList={productList} | ||
value={defaultValue} | ||
required={required} | ||
readonly={readonly} | ||
onChangeValue={onChange} | ||
fetchData={searchProductAPI} | ||
displayValue={displayItemName} | ||
placeholder={I18n.t(title)} | ||
showDetailsPopup={true} | ||
loadingList={loadingProducts} | ||
moreLoading={moreLoadingProduct} | ||
isListEnd={isListEndProduct} | ||
navigate={false} | ||
oneFilter={false} | ||
isScrollViewContainer={isScrollViewContainer} | ||
/> | ||
); | ||
}; | ||
|
||
export default ProductSearchBar; |
Oops, something went wrong.