-
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.
feat: manage attached files header action
- Loading branch information
1 parent
9599e38
commit 16e7dd4
Showing
11 changed files
with
294 additions
and
15 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
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
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
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,85 @@ | ||
/* | ||
* 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, {useEffect, useState} from 'react'; | ||
import { | ||
handlerApiCall, | ||
useIsFocused, | ||
useTranslator, | ||
} from '@axelor/aos-mobile-core'; | ||
import {Alert, Text} from '@axelor/aos-mobile-ui'; | ||
import {fetchDirectory} from '../api/document-api'; | ||
import {DocumentList} from '../components'; | ||
|
||
const AttachedFilesScreen = ({navigation, route}) => { | ||
const _parent = route?.params?.parent; | ||
const model = route?.params?.model; | ||
const modelId = route?.params?.modelId; | ||
const I18n = useTranslator(); | ||
const isFocused = useIsFocused(); | ||
|
||
const [isVisible, setIsVisible] = useState(false); | ||
const [parent, setParent] = useState(_parent); | ||
|
||
useEffect(() => { | ||
!parent && setIsVisible(true); | ||
}, [parent]); | ||
|
||
useEffect(() => { | ||
if (isFocused && parent == null) { | ||
handlerApiCall({ | ||
fetchFunction: fetchDirectory, | ||
data: {model, modelId}, | ||
action: 'Dms_SliceAction_FetchDirectory', | ||
getState: () => {}, | ||
responseOptions: {isArrayResponse: false}, | ||
}).then(directory => setParent(directory)); | ||
} | ||
}, [isFocused, model, modelId, parent]); | ||
|
||
return ( | ||
<> | ||
{!isVisible && <DocumentList defaultParent={parent} />} | ||
<Alert | ||
visible={isVisible} | ||
title={I18n.t('Dms_NoAttachedFiles')} | ||
cancelButtonConfig={{ | ||
title: I18n.t('Base_No'), | ||
onPress: () => { | ||
setIsVisible(false); | ||
navigation.goBack(); | ||
}, | ||
}} | ||
confirmButtonConfig={{ | ||
title: I18n.t('Base_Yes'), | ||
onPress: () => { | ||
setIsVisible(false); | ||
navigation.navigate('DocumentFormScreen', { | ||
model, | ||
modelId, | ||
}); | ||
}, | ||
}} | ||
translator={I18n.t}> | ||
<Text>{I18n.t('Dms_DoYouWantToAddFile')}</Text> | ||
</Alert> | ||
</> | ||
); | ||
}; | ||
|
||
export default AttachedFilesScreen; |
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
Oops, something went wrong.