Skip to content

Commit

Permalink
Merge pull request #752 from stasgm/old_selectors
Browse files Browse the repository at this point in the history
chore: auto saving
  • Loading branch information
sunnycreature authored Feb 20, 2024
2 parents 70a1e3b + 6040dc1 commit 1f5809a
Show file tree
Hide file tree
Showing 43 changed files with 638 additions and 277 deletions.
4 changes: 2 additions & 2 deletions apps/app-fp-movement/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "GDMN Отгрузка",
"slug": "gdmn-fp-movement",
"version": "0.4.4",
"version": "0.4.6",
"githubUrl": "https://github.com/stasgm/gdmn-mob",
"orientation": "default",
"icon": "./assets/icon.png",
Expand All @@ -26,7 +26,7 @@
"android": {
"package": "com.gsbelarus.fpmovement",
"permissions": ["CAMERA", "VIBRATE"],
"versionCode": 36
"versionCode": 38
},
"web": {
"favicon": "./assets/favicon.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const FreeShipmentListScreen = () => {
</View>
),
sentDate: i.sentDate,
erpCreationDate: i.erpCreationDate,
}) as IListItemProps,
);
}, [list, status, sortDateType.id]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ export const FreeShipmentViewScreen = () => {

const goodRemains = useMemo<IRemGood[]>(() => {
return doc?.head?.fromDepart?.id && isFocused && remains
? getRemGoodListByContact(goods, remains[doc.head.fromDepart.id], docList, doc.head.fromDepart.id)
? getRemGoodListByContact(goods, remains[doc.head.fromDepart.id] /*, docList, doc.head.fromDepart.id*/)
: [];
}, [doc?.head?.fromDepart?.id, goods, remains, docList, isFocused]);
}, [doc?.head?.fromDepart?.id, goods, remains, isFocused]);

const [screenState, setScreenState] = useState<ScreenState>('idle');
const [visibleDialog, setVisibleDialog] = useState(false);
Expand Down Expand Up @@ -503,6 +503,8 @@ export const FreeShipmentViewScreen = () => {
[doc?.status, handlePressLine, lines?.length],
);

const [isDateVisible, setIsDateVisible] = useState(false);

const [scanned, setScanned] = useState(false);

const handleErrorMessage = useCallback((visible: boolean, text: string) => {
Expand Down Expand Up @@ -656,6 +658,8 @@ export const FreeShipmentViewScreen = () => {
}
}, [navigation, screenState]);

const isEditable = useMemo(() => (doc ? ['DRAFT', 'READY'].includes(doc?.status) : false), [doc]);

const viewStyle: StyleProp<ViewStyle> = useMemo(
() => ({ ...styles.container, justifyContent: lineType === 'last' ? 'flex-start' : 'center' }),
[lineType],
Expand Down Expand Up @@ -695,20 +699,33 @@ export const FreeShipmentViewScreen = () => {
<InfoBlock
colorLabel={getStatusColor(doc?.status || 'DRAFT')}
title={doc.documentType.description || ''}
onPress={handleEditDocHead}
disabled={!['DRAFT', 'READY'].includes(doc.status)}
isBlocked={isBlocked}
onPress={() => (isEditable ? handleEditDocHead() : setIsDateVisible(!isDateVisible))}
editable={isEditable}
>
<View style={styles.infoBlock}>
<MediumText>{doc.head.fromDepart?.name || ''}</MediumText>
<MediumText>{`№ ${doc.number} от ${getDateString(doc.documentDate)}`}</MediumText>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)} {new Date(doc.sentDate).toLocaleTimeString()}
</MediumText>
</View>
) : null}
{isDateVisible && (
<>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)}{' '}
{new Date(doc.sentDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
{doc.erpCreationDate ? (
<View style={styles.rowCenter}>
<MediumText>
Обработано: {getDateString(doc.erpCreationDate)}{' '}
{new Date(doc.erpCreationDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
</>
)}
</View>
</InfoBlock>
<LineTypes />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const InventoryListScreen = () => {
lineCount: i.lines.length,
errorMessage: i.errorMessage,
sentDate: i.sentDate,
erpCreationDate: i.erpCreationDate,
}) as IListItemProps,
);
}, [status, list]);
Expand Down
35 changes: 26 additions & 9 deletions apps/app-fp-movement/src/screens/Inventory/InventoryViewScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ export const InventoryViewScreen = () => {
[doc?.head.fromDepart?.isAddressStore, doc?.status, handlePressLine, lines?.length],
);

const [isDateVisible, setIsDateVisible] = useState(false);

const [scanned, setScanned] = useState(false);

const ref = useRef<TextInput>(null);
Expand Down Expand Up @@ -582,6 +584,8 @@ export const InventoryViewScreen = () => {
}
}, [navigation, screenState]);

const isEditable = useMemo(() => (doc ? ['DRAFT', 'READY'].includes(doc?.status) : false), [doc]);

const isFocused = useIsFocused();
if (!isFocused) {
return <AppActivityIndicator />;
Expand Down Expand Up @@ -617,20 +621,33 @@ export const InventoryViewScreen = () => {
<InfoBlock
colorLabel={getStatusColor(doc?.status || 'DRAFT')}
title={doc.documentType.description || ''}
onPress={handleEditDocHead}
disabled={!['DRAFT', 'READY'].includes(doc.status)}
onPress={() => (isEditable ? handleEditDocHead() : setIsDateVisible(!isDateVisible))}
editable={isEditable}
isBlocked={isBlocked}
>
<View style={styles.infoBlock}>
<MediumText>{doc.head.fromDepart?.name || ''}</MediumText>
<MediumText>{`№ ${doc.number} от ${getDateString(doc.documentDate)}`}</MediumText>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)} {new Date(doc.sentDate).toLocaleTimeString()}
</MediumText>
</View>
) : null}
{isDateVisible && (
<>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)}{' '}
{new Date(doc.sentDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
{doc.erpCreationDate ? (
<View style={styles.rowCenter}>
<MediumText>
Обработано: {getDateString(doc.erpCreationDate)}{' '}
{new Date(doc.erpCreationDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
</>
)}
</View>
</InfoBlock>
<LineTypes />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const LaboratoryListScreen = () => {
lineCount: i.lines.length,
errorMessage: i.errorMessage,
sentDate: i.sentDate,
erpCreationDate: i.erpCreationDate,
}) as IListItemProps,
);
}, [status, list]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ export const LaboratoryViewScreen = () => {

const goodRemains = useMemo<IRemGood[]>(() => {
return doc?.head?.fromDepart?.id && isFocused && remains
? getRemGoodListByContact(goods, remains[doc.head.fromDepart.id], docList, doc.head.fromDepart.id)
? getRemGoodListByContact(goods, remains[doc.head.fromDepart.id] /*, docList, doc.head.fromDepart.id*/)
: [];
}, [doc?.head?.fromDepart?.id, docList, goods, isFocused, remains]);
}, [doc?.head.fromDepart.id, goods, isFocused, remains]);

const [screenState, setScreenState] = useState<ScreenState>('idle');
const [visibleDialog, setVisibleDialog] = useState(false);
Expand Down Expand Up @@ -458,6 +458,8 @@ export const LaboratoryViewScreen = () => {
[doc?.status, lines?.length],
);

const [isDateVisible, setIsDateVisible] = useState(false);

const [scanned, setScanned] = useState(false);

const ref = useRef<TextInput>(null);
Expand Down Expand Up @@ -597,6 +599,8 @@ export const LaboratoryViewScreen = () => {
}
}, [navigation, screenState]);

const isEditable = useMemo(() => (doc ? ['DRAFT', 'READY'].includes(doc?.status) : false), [doc]);

const viewStyle: StyleProp<ViewStyle> = useMemo(
() => ({ ...styles.container, justifyContent: lineType === 'last' ? 'flex-start' : 'center' }),
[lineType],
Expand Down Expand Up @@ -636,20 +640,33 @@ export const LaboratoryViewScreen = () => {
<InfoBlock
colorLabel={getStatusColor(doc?.status || 'DRAFT')}
title={doc.documentType.description || ''}
onPress={handleEditDocHead}
disabled={!['DRAFT', 'READY'].includes(doc.status)}
onPress={() => (isEditable ? handleEditDocHead() : setIsDateVisible(!isDateVisible))}
editable={isEditable}
isBlocked={isBlocked}
>
<View style={styles.infoBlock}>
<MediumText>{doc.head.fromDepart?.name || ''}</MediumText>
<MediumText>{`№ ${doc.number} от ${getDateString(doc.documentDate)}`}</MediumText>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)} {new Date(doc.sentDate).toLocaleTimeString()}
</MediumText>
</View>
) : null}
{isDateVisible && (
<>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)}{' '}
{new Date(doc.sentDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
{doc.erpCreationDate ? (
<View style={styles.rowCenter}>
<MediumText>
Обработано: {getDateString(doc.erpCreationDate)}{' '}
{new Date(doc.erpCreationDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
</>
)}
</View>
</InfoBlock>
<LineTypes />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const MoveFromListScreen = () => {
</View>
),
sentDate: i.sentDate,
erpCreationDate: i.erpCreationDate,
}) as IListItemProps,
);
}, [status, list]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export const MoveFromViewScreen = () => {

const goodRemains = useMemo<IRemGood[]>(() => {
return doc?.head?.fromDepart?.id && isFocused && remains
? getRemGoodListByContact(goods, remains[doc.head.fromDepart.id], docList, doc.head.fromDepart.id)
? getRemGoodListByContact(goods, remains[doc.head.fromDepart.id] /*, docList, doc.head.fromDepart.id*/)
: [];
}, [doc?.head?.fromDepart?.id, docList, goods, isFocused, remains]);
}, [doc?.head?.fromDepart?.id, goods, isFocused, remains]);

const handleFocus = () => {
ref?.current?.focus();
Expand Down Expand Up @@ -447,6 +447,8 @@ export const MoveFromViewScreen = () => {
[doc?.head.fromDepart?.isAddressStore, doc?.head.toDepart?.isAddressStore, doc?.status, lines?.length],
);

const [isDateVisible, setIsDateVisible] = useState(false);

const [scanned, setScanned] = useState(false);

const ref = useRef<TextInput>(null);
Expand Down Expand Up @@ -607,6 +609,8 @@ export const MoveFromViewScreen = () => {
}
}, [navigation, screenState]);

const isEditable = useMemo(() => (doc ? ['DRAFT', 'READY'].includes(doc?.status) : false), [doc]);

if (!isFocused) {
return <AppActivityIndicator />;
}
Expand Down Expand Up @@ -641,8 +645,8 @@ export const MoveFromViewScreen = () => {
<InfoBlock
colorLabel={getStatusColor(doc?.status || 'DRAFT')}
title={doc.head.subtype.name || ''}
onPress={handleEditDocHead}
disabled={!['DRAFT', 'READY'].includes(doc.status)}
onPress={() => (isEditable ? handleEditDocHead() : setIsDateVisible(!isDateVisible))}
editable={isEditable}
isBlocked={isBlocked}
>
<>
Expand All @@ -653,13 +657,26 @@ export const MoveFromViewScreen = () => {
<View style={styles.rowCenter}>
<MediumText>Куда: {doc.head.toDepart?.name || ''}</MediumText>
</View>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)} {new Date(doc.sentDate).toLocaleTimeString()}
</MediumText>
</View>
) : null}
{isDateVisible && (
<>
{doc.sentDate ? (
<View style={styles.rowCenter}>
<MediumText>
Отправлено: {getDateString(doc.sentDate)}{' '}
{new Date(doc.sentDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
{doc.erpCreationDate ? (
<View style={styles.rowCenter}>
<MediumText>
Обработано: {getDateString(doc.erpCreationDate)}{' '}
{new Date(doc.erpCreationDate).toLocaleTimeString('ru', { hour12: false })}
</MediumText>
</View>
) : null}
</>
)}
</>
</InfoBlock>
<LineTypes />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const MoveToListScreen = () => {
</View>
),
sentDate: i.sentDate,
erpCreationDate: i.erpCreationDate,
}) as IListItemProps,
);
}, [status, list]);
Expand Down
Loading

0 comments on commit 1f5809a

Please sign in to comment.