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 ControlEntrySample form screen #382

Merged
merged 30 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
279fe45
feat: add ControlEntryDetailsScreen and header
gca-axelor Jan 25, 2024
5db7014
feat: add slie and scrollist for controlEntrySample
gca-axelor Jan 25, 2024
f4998c6
feat: add ControlEntrySampleLine card
gca-axelor Jan 25, 2024
966f97b
refactor: use dispatch in header
gca-axelor Jan 25, 2024
ac1b493
feat: add button
gca-axelor Jan 25, 2024
ca7c575
fix: use DateDisplay from core and api file name
lme-axelor Jan 26, 2024
3052d9a
refactor: add props itemStyle to RadioSelect component
gca-axelor Jan 26, 2024
16e00d6
refactor: fix ToggleButton to avoid warning
gca-axelor Jan 26, 2024
c1e3616
feat: add ControlEntryFormScreen
gca-axelor Jan 29, 2024
c5b370d
feat: logic form for filling by sampple
gca-axelor Jan 30, 2024
b5f6661
feat: add logic by Characteristic
gca-axelor Jan 31, 2024
ed7a412
feat: fetch sample line by characr only for sample in control entry
gca-axelor Jan 31, 2024
c4d727e
feat: useCurrentSampleLine in customFielForm
gca-axelor Jan 31, 2024
381513f
feat: fix button logic
gca-axelor Feb 1, 2024
f388451
feat: add condition in all useEffect
gca-axelor Feb 1, 2024
9162bd0
feat: restore ControlEntryDetailsScreen
gca-axelor Feb 1, 2024
b439374
feat: restore ToggleButton
gca-axelor Feb 1, 2024
919cfa1
feat: add custom element in FormView
gca-axelor Feb 2, 2024
0ac4436
refactor: improve logic for json fields default action
lme-axelor Feb 2, 2024
5c60b92
refactor: simplify navigation logic
lme-axelor Feb 5, 2024
cc900e2
fix: avoid NPE on form helper
lme-axelor Feb 5, 2024
fadc2f8
refactor: add type file and smaller components, end navigation
lme-axelor Feb 5, 2024
2f01ae2
feat: enable post actions on default custom fields action
lme-axelor Feb 5, 2024
7b2e601
feat: add validation update on button, action when update field, and …
gca-axelor Feb 7, 2024
1d30d8f
fix: remove usless consol.log
gca-axelor Feb 7, 2024
ea0ea7e
feat: ajust trad
gca-axelor Feb 7, 2024
620f877
feat: add trad
gca-axelor Feb 7, 2024
345d5a8
feat: add progress bar values with new api
gca-axelor Feb 8, 2024
9a36139
refactor: refactor logic progressbar
gca-axelor Feb 8, 2024
9328294
fix: translation and exports
lme-axelor Feb 9, 2024
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
25 changes: 25 additions & 0 deletions packages/apps/quality/src/api/control-entry-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import {
axiosApiProvider,
createStandardFetch,
createStandardSearch,
getEndOfDay,
Expand Down Expand Up @@ -80,3 +81,27 @@ export async function fetchControlEntryById({controlEntryId}) {
fieldKey: 'quality_controlEntry',
});
}

export async function updateControlEntry({controlEntry}) {
return axiosApiProvider.post({
url: '/ws/rest/com.axelor.apps.quality.db.ControlEntry/',
data: {
data: controlEntry,
},
});
}

export async function getProgressValues({
controlEntryId,
characteristicId,
sampleId,
}) {
return axiosApiProvider.post({
url: 'ws/aos/controlentry/progressValues',
data: {
controlEntryId,
characteristicId,
sampleId,
},
});
}
54 changes: 53 additions & 1 deletion packages/apps/quality/src/api/control-entry-sample-line-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import {createStandardSearch} from '@axelor/aos-mobile-core';
import {
createStandardSearch,
createStandardFetch,
axiosApiProvider,
} from '@axelor/aos-mobile-core';

const createControlEntrySampleLineCriteria = controlEntrySampleId => {
return [
Expand All @@ -40,3 +44,51 @@ export async function searchControlEntrySampleLine({
page: page,
});
}

const createSampleLineOfControlEntryCriteria = controlEntryId => {
return [
{
fieldName: 'controlEntrySample.controlEntry.id',
operator: '=',
value: controlEntryId,
},
];
};

export async function searchControlEntrySampleLineOfControlEntry({
controlEntryId,
}) {
return createStandardSearch({
model: 'com.axelor.apps.quality.db.ControlEntryPlanLine',
criteria: createSampleLineOfControlEntryCriteria(controlEntryId),
fieldKey: 'quality_controlEntrySampleLine',
sortKey: 'quality_controlEntrySampleLine',
numberElementsByPage: null,
page: 0,
});
}

export async function fetchControlEntrySampleLine({id}) {
return createStandardFetch({
model: 'com.axelor.apps.quality.db.ControlEntryPlanLine',
id,
fieldKey: 'quality_controlEntrySampleLine',
});
}

export async function checkComformity({object}) {
return axiosApiProvider.post({
url: 'ws/action',
data: {
action:
'action-quality-control-entry-line-method-control-conformity,save',
data: {
context: {
...object,
_model: 'com.axelor.apps.quality.db.ControlEntryPlanLine',
},
},
model: 'com.axelor.apps.quality.db.ControlEntryPlanLine',
},
});
}
27 changes: 27 additions & 0 deletions packages/apps/quality/src/api/control-plan-api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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 {createStandardFetch} from '@axelor/aos-mobile-core';

export async function fetchControlPlanById({id}) {
return createStandardFetch({
model: 'com.axelor.apps.quality.db.ControlPlan',
id,
fieldKey: 'quality_controlPlan',
});
}
10 changes: 9 additions & 1 deletion packages/apps/quality/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
export {
fetchControlEntryById as fetchControlEntryByIdApi,
searchControlEntry as searchControlEntryApi,
updateControlEntry as updateControlEntryApi,
getProgressValues as getProgressValuesApi,
} from './control-entry-api';
export {searchControlEntrySample as searchControlEntrySampleApi} from './control-entry-sample-api';
export {searchControlEntrySampleLine as searchControlEntrySampleLineApi} from './control-entry-sample-line-api';
export {
checkComformity,
fetchControlEntrySampleLine as fetchControlEntrySampleLineApi,
searchControlEntrySampleLine as searchControlEntrySampleLineApi,
searchControlEntrySampleLineOfControlEntry as searchControlEntrySampleLineOfControlEntryApi,
} from './control-entry-sample-line-api';
export {fetchControlPlanById as fetchControlPlanByIdApi} from './control-plan-api';
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const ControlEntryCard = ({
<DateDisplay date={entryDateTime} />
</View>
<View style={styles.childrenContainer}>
<Text>{`${I18n.t('Quality_Sample')} : ${sampleCount}`}</Text>
<Text>{`${I18n.t('Quality_SampleCount')} : ${sampleCount}`}</Text>
<ProgressBar
style={styles.progressBar}
value={numberSampleFilled}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 {DateDisplay, useSelector, useTranslator} from '@axelor/aos-mobile-core';
import {Badge, Text, useThemeColor} from '@axelor/aos-mobile-ui';
import {ControlEntry} from '../../../types';

const ControlEntryHeader = ({}) => {
const I18n = useTranslator();
const Colors = useThemeColor();

const {controlEntry} = useSelector((state: any) => state.controlEntry);

return (
<View>
<View style={styles.row}>
<Text writingType="title">{controlEntry.name}</Text>
<Badge
color={ControlEntry.getStatusColor(controlEntry.statusSelect, Colors)}
title={ControlEntry.getStatus(controlEntry.statusSelect, I18n)}
/>
</View>
<View style={styles.row}>
<Text>{`${I18n.t('Quality_SampleCount')} : ${
controlEntry.sampleCount
}`}</Text>
<DateDisplay date={controlEntry.entryDateTime} />
</View>
<Text>{`${I18n.t('Quality_ControlPlan')} : ${
controlEntry.controlPlan?.name
}`}</Text>
</View>
);
};

const styles = StyleSheet.create({
row: {
justifyContent: 'space-between',
flexDirection: 'row',
alignItems: 'center',
},
});

export default ControlEntryHeader;
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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 {useSelector, useTranslator} from '@axelor/aos-mobile-core';
import {Badge, Text, useThemeColor} from '@axelor/aos-mobile-ui';
import {ControlEntry} from '../../../types';

const ControlEntrySampleLineHeader = ({}) => {
const I18n = useTranslator();
const Colors = useThemeColor();

const {sampleLine} = useSelector(
(state: any) => state.controlEntrySampleLine,
);

if (sampleLine?.id == null) {
return null;
}

return (
<View>
<View style={styles.row}>
<Text>{`${I18n.t('Quality_Sample')} : ${
sampleLine.controlEntrySample?.fullName
}`}</Text>
<Badge
color={ControlEntry.getSampleResultColor(
sampleLine.resultSelect,
Colors,
)}
title={ControlEntry.getSampleResultTitle(
sampleLine.resultSelect,
I18n,
)}
/>
</View>
<Text>{`${I18n.t('Quality_Characteristic')} : ${
sampleLine.controlPlanLine?.characteristic?.name
}`}</Text>
</View>
);
};

const styles = StyleSheet.create({
row: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
badge: {
margin: 0,
width: null,
},
});

export default ControlEntrySampleLineHeader;
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 React, {useMemo} from 'react';
import {StyleSheet, View} from 'react-native';
import {Button, Icon, useThemeColor} from '@axelor/aos-mobile-ui';

const NavigationButton = ({position, onPress, icon, disabled}) => {
const Colors = useThemeColor();

const positionStyle = useMemo(() => ({[position]: '15%'}), [position]);

return (
<View style={styles.buttonContainer}>
<Button
onPress={onPress}
color={Colors.priorityColor}
disabled={disabled}
iconName={icon}
/>
<Icon
name={`chevron-${position}`}
style={[styles.chevron, positionStyle]}
/>
</View>
);
};

const styles = StyleSheet.create({
buttonContainer: {
width: '45%',
alignItems: 'center',
justifyContent: 'center',
},
chevron: {
position: 'absolute',
},
});

export default NavigationButton;
3 changes: 3 additions & 0 deletions packages/apps/quality/src/components/atoms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
*/

export {default as ControlEntryCard} from './ControlEntryCard/ControlEntryCard';
export {default as ControlEntryHeader} from './ControlEntryHeader/ControlEntryHeader';
export {default as ControlEntrySampleCard} from './ControlEntrySampleCard/ControlEntrySampleCard';
export {default as ControlEntrySampleLineHeader} from './ControlEntrySampleLineHeader/ControlEntrySampleLineHeader';
export {default as NavigationButton} from './NavigationButton/NavigationButton';
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,33 @@
*/

import React from 'react';
import {useTranslator} from '@axelor/aos-mobile-core';
import {useDispatch, useSelector, useTranslator} from '@axelor/aos-mobile-core';
import {Button} from '@axelor/aos-mobile-ui';
import {updateControlEntry} from '../../../features/controlEntrySlice';
import {ControlEntry} from '../../../types';

const ControlEntryDetailsButtons = () => {
const dispatch = useDispatch();
const I18n = useTranslator();

const {controlEntry} = useSelector((state: any) => state.controlEntry);

return (
<Button title={I18n.t('Quality_MarkAsCompleted')} iconName="check-lg" />
<Button
title={I18n.t('Quality_MarkAsCompleted')}
onPress={() => {
dispatch(
(updateControlEntry as any)({
controlEntry: {
...controlEntry,
statusSelect: ControlEntry.status.Completed,
},
controlEntryId: controlEntry.id,
}),
);
}}
iconName="check-lg"
/>
);
};

Expand Down
Loading
Loading