Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add requestDetails screen #834

Merged
merged 10 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 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,9 @@
* 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,80 @@
/*
* 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, Label, LabelText} from '@axelor/aos-mobile-ui';
import {useSelector, useTranslator} from '@axelor/aos-mobile-core';

const DropdownRequestCharacteristics = () => {
gca-axelor marked this conversation as resolved.
Show resolved Hide resolved
const I18n = useTranslator();

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

if (
checkNullString(purchaseRequest.supplierPartner?.fullName) &&
checkNullString(purchaseRequest.stockLocation?.name) &&
checkNullString(purchaseRequest.requesterUser?.fullName) &&
checkNullString(purchaseRequest.validatorUser?.fullName)
) {
return (
<Label
message={I18n.t('Purchase_NoInformationAvailable')}
type="info"
iconName="info-circle-fill"
/>
);
}

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,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 {StyleSheet, View} from 'react-native';
import {Text, LabelText, Badge} from '@axelor/aos-mobile-ui';
import {useSelector, useTypeHelpers, useTypes} from '@axelor/aos-mobile-core';

const RequestHeader = ({}) => {
const {PurchaseRequest} = useTypes();
const {getItemColor, 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={getItemColor(
PurchaseRequest?.statusSelect,
purchaseRequest.statusSelect,
)}
/>
</View>
<LabelText
iconName="building-fill"
size={16}
title={purchaseRequest?.company?.name}
/>
</View>
);
};

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

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

const RequestSeeLinesButton = () => {
const I18n = useTranslator();
const Colors = useThemeColor();

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

const {totalPurchaseRequestLine} = useSelector(
state => state.purchase_purchaseRequestLine,
);

return (
<TouchableOpacity
onPress={() => {}}
disabled={totalPurchaseRequestLine === 0}
activeOpacity={0.9}>
<Card style={styles.container}>
<Text style={styles.text}>{I18n.t('Purchase_SeeLines')}</Text>
<View style={styles.rightContainer}>
<NumberBubble
style={styles.numberBubble}
number={totalPurchaseRequestLine}
color={Colors.progressColor}
isNeutralBackground={false}
/>
{totalPurchaseRequestLine > 0 && (
<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 RequestSeeLinesButton;
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 RequestSeeLinesButton} from './RequestSeeLinesButton/RequestSeeLinesButton';
export {default as RequestCard} from './RequestCard/RequestCard';
export {default as RequestHeader} from './RequestHeader/RequestHeader';
2 changes: 2 additions & 0 deletions packages/apps/purchase/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
*/

export * from './atoms';
export * from './molecules';
export * from './organisms';
export * from './templates';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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 = ({style}: {style: any}) => {
const I18n = useTranslator();

return (
<DropdownCardSwitch
style={style}
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';
Loading
Loading