Skip to content

Commit

Permalink
feat: add internal purchase request details screen
Browse files Browse the repository at this point in the history
  • Loading branch information
gca-axelor committed Dec 11, 2024
1 parent 8c63f9a commit c7452a7
Show file tree
Hide file tree
Showing 20 changed files with 547 additions and 7 deletions.
8 changes: 7 additions & 1 deletion packages/apps/purchase/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export {searchPurchaseRequest as searchPurchaseRequestApi} from './purchase-request-api';
export {
getPurchaseRequest as getPurchaseRequestApi,
searchPurchaseRequest as searchPurchaseRequestApi,
} from './purchase-request-api';
export {
searchPurchaseRequestLine as searchPurchaseRequestLineApi,
} from './purchase-request-line-api';
export {searchSupplier as searchSupplierApi} from './supplier-api';
9 changes: 9 additions & 0 deletions packages/apps/purchase/src/api/purchase-request-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

import {
createStandardFetch,
createStandardSearch,
getSearchCriterias,
} from '@axelor/aos-mobile-core';
Expand Down Expand Up @@ -66,3 +67,11 @@ export async function searchPurchaseRequest({
page,
});
}

export async function getPurchaseRequest({id}) {
return createStandardFetch({
model: 'com.axelor.apps.purchase.db.PurchaseRequest',
id,
fieldKey: 'purchase_purchaseRequest',
});
}
39 changes: 39 additions & 0 deletions packages/apps/purchase/src/api/purchase-request-line-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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} from '@axelor/aos-mobile-core';

const createPurchaseRequestLineCriteria = purchaseRequestId => {
return [
{
fieldName: 'purchaseRequest.id',
operator: '=',
value: purchaseRequestId,
},
];
};

export async function searchPurchaseRequestLine({page = 0, purchaseRequestId}) {
return createStandardSearch({
model: 'com.axelor.apps.purchase.db.PurchaseRequestLine',
criteria: createPurchaseRequestLineCriteria(purchaseRequestId),
fieldKey: 'purchase_purchaseRequestLine',
sortKey: 'purchase_purchaseRequestLine',
page,
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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} from 'react-native';
import {checkNullString, LabelText} from '@axelor/aos-mobile-ui';
import {useSelector, useTranslator} from '@axelor/aos-mobile-core';

const DropdownRequestCharacteristics = () => {
const {purchaseRequest} = useSelector(
state => state.purchase_purchaseRequest,
);

const I18n = useTranslator();

return (
<View>
{!checkNullString(purchaseRequest.supplierPartner?.fullName) && (
<LabelText
title={purchaseRequest.supplierPartner?.fullName}
iconName="person-fill"
textSize={16}
/>
)}
{!checkNullString(purchaseRequest.stockLocation?.name) && (
<LabelText
title={`${I18n.t('Purchase_StockLocation')} :`}
value={purchaseRequest.stockLocation?.name}
textSize={16}
/>
)}
{!checkNullString(purchaseRequest.requesterUser?.fullName) && (
<LabelText
title={`${I18n.t('Purchase_RequesterUser')} :`}
value={purchaseRequest.requesterUser?.fullName}
textSize={16}
/>
)}
{!checkNullString(purchaseRequest.validatorUser?.fullName) && (
<LabelText
title={`${I18n.t('Purchase_ValidatorUser')} :`}
value={purchaseRequest.validatorUser?.fullName}
textSize={16}
/>
)}
</View>
);
};

export default DropdownRequestCharacteristics;
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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, TouchableOpacity, View} from 'react-native';
import {useTranslator} from '@axelor/aos-mobile-core';
import {
Card,
Icon,
NumberBubble,
useThemeColor,
Text,
} from '@axelor/aos-mobile-ui';

interface PurchaseSeeLinesButtonProps {
numberLines: number;
}

const PurchaseSeeLinesButton = ({numberLines}: PurchaseSeeLinesButtonProps) => {
const I18n = useTranslator();
const Colors = useThemeColor();

const styles = useMemo(
() => getStyles(Colors.secondaryColor.background),
[Colors.secondaryColor.background],
);

return (
<TouchableOpacity onPress={() => {}} activeOpacity={0.9}>
<Card style={styles.container}>
<Text style={styles.text}>{I18n.t('Purchase_SeeLines')}</Text>
<View style={styles.rightContainer}>
{numberLines > 0 && (
<NumberBubble
style={styles.numberBubble}
number={numberLines}
color={Colors.progressColor}
isNeutralBackground={false}
/>
)}
<Icon name="chevron-right" color={Colors.primaryColor.background} />
</View>
</Card>
</TouchableOpacity>
);
};

const getStyles = (borderColor: string) =>
StyleSheet.create({
container: {
width: '90%',
height: 40,
flexDirection: 'row',
justifyContent: 'space-between',
alignSelf: 'center',
alignItems: 'center',
marginRight: 0,
paddingVertical: 5,
paddingLeft: 10,
paddingRight: 10,
borderWidth: 1,
borderRadius: 7,
borderColor: borderColor,
marginVertical: 3,
},
text: {
fontWeight: 'bold',
},
rightContainer: {
flexDirection: 'row',
},
numberBubble: {
borderRadius: 7,
marginRight: 4,
},
});

export default PurchaseSeeLinesButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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 {StyleSheet, View} from 'react-native';
import {Text, LabelText, Badge, useThemeColor} from '@axelor/aos-mobile-ui';
import {useSelector, useTypeHelpers, useTypes} from '@axelor/aos-mobile-core';

const RequestHeader = ({}) => {
const Colors = useThemeColor();
const {PurchaseRequest} = useTypes();
const {getItemTitle} = useTypeHelpers();

const {purchaseRequest} = useSelector(
state => state.purchase_purchaseRequest,
);

return (
<View style={styles.container}>
<View style={styles.chlidrenContainer}>
<Text writingType="title">{purchaseRequest?.purchaseRequestSeq}</Text>
<Badge
title={getItemTitle(
PurchaseRequest?.statusSelect,
purchaseRequest.statusSelect,
)}
color={Colors.infoColor}
/>
</View>
<LabelText
iconName="building-fill"
size={16}
title={purchaseRequest?.company?.name}
/>
</View>
);
};

const styles = StyleSheet.create({
container: {
marginHorizontal: 15,
},
chlidrenContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 5,
},
});

export default RequestHeader;
3 changes: 3 additions & 0 deletions packages/apps/purchase/src/components/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export {default as DropdownRequestCharacteristics} from './DropdownRequestCharacteristics/DropdownRequestCharacteristics';
export {default as PurchaseSeeLinesButton} from './PurchaseSeeLinesButton/PurchaseSeeLinesButton';
export {default as RequestCard} from './RequestCard/RequestCard';
export {default as RequestHeader} from './RequestHeader/RequestHeader';
1 change: 1 addition & 0 deletions packages/apps/purchase/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
*/

export * from './atoms';
export * from './molecules';
export * from './templates';
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 {useTranslator} from '@axelor/aos-mobile-core';
import {DropdownCardSwitch} from '@axelor/aos-mobile-ui';
import {DropdownRequestCharacteristics} from '../../atoms';

const RequestDropdownCards = () => {
const I18n = useTranslator();

return (
<DropdownCardSwitch
dropdownItems={[
{
key: 1,
title: I18n.t('Purchase_Characteristics'),
childrenComp: <DropdownRequestCharacteristics />,
},
]}
/>
);
};

export default RequestDropdownCards;
19 changes: 19 additions & 0 deletions packages/apps/purchase/src/components/molecules/index.ts
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 RequestDropdownCards} from './RequestDropdownCards/RequestDropdownCards';
6 changes: 5 additions & 1 deletion packages/apps/purchase/src/features/asyncFunctions-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export {searchPurchaseRequest} from './purchaseRequestSlice';
export {
getPurchaseRequest,
searchPurchaseRequest,
} from './purchaseRequestSlice';
export {searchSupplier} from './supplierSlice';
export {searchPurchaseRequestLine} from './purchaseRequestLineSlice';
1 change: 1 addition & 0 deletions packages/apps/purchase/src/features/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@

export {purchaseRequestReducer as purchase_purchaseRequest} from './purchaseRequestSlice';
export {supplierReducer as purchase_supplier} from './supplierSlice';
export {purchaseRequestLineReducer as purchase_purchaseRequestLine} from './purchaseRequestLineSlice';
Loading

0 comments on commit c7452a7

Please sign in to comment.