-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add PeriodInput on event form on crm (#884)
* RM#90595
- Loading branch information
1 parent
6e23346
commit e36df4e
Showing
8 changed files
with
170 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"title": "Event form: replace start and end dates inputs by PeriodInput component", | ||
"type": "refactor", | ||
"packages": "crm" | ||
} |
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,5 @@ | ||
{ | ||
"title": "PeriodInput: add props dateInputMode and nullable on date config", | ||
"type": "feat", | ||
"packages": "core" | ||
} |
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,5 @@ | ||
{ | ||
"title": "PeriodInput: add new props to detect error from outside", | ||
"type": "feat", | ||
"packages": "core" | ||
} |
77 changes: 77 additions & 0 deletions
77
packages/apps/crm/src/components/organisms/EventPeriodInput/EventPeriodInput.tsx
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,77 @@ | ||
/* | ||
* Axelor Business Solutions | ||
* | ||
* Copyright (C) 2025 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} from 'react-native'; | ||
import {PeriodInput} from '@axelor/aos-mobile-core'; | ||
|
||
interface EventPeriodInputProps { | ||
defaultValue?: any; | ||
onChange?: (value: any) => void; | ||
} | ||
|
||
const EventPeriodInputAux = ({ | ||
defaultValue = null, | ||
onChange, | ||
}: EventPeriodInputProps) => { | ||
const handleValueChange = (field: string, value: any) => { | ||
if (value !== defaultValue[field]) { | ||
onChange({ | ||
...defaultValue, | ||
[field]: value, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<PeriodInput | ||
style={styles.periodInput} | ||
horizontal={false} | ||
startDateConfig={{ | ||
dateInputMode: 'datetime', | ||
nullable: false, | ||
date: defaultValue.startDateTime, | ||
onDateChange: date => handleValueChange('startDateTime', date), | ||
}} | ||
endDateConfig={{ | ||
dateInputMode: 'datetime', | ||
nullable: false, | ||
date: defaultValue.endDateTime, | ||
onDateChange: date => handleValueChange('endDateTime', date), | ||
}} | ||
onPeriodErrorChange={isError => handleValueChange('isError', isError)} | ||
/> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
periodInput: { | ||
alignSelf: 'center', | ||
}, | ||
}); | ||
|
||
const EventPeriodInput = ({ | ||
defaultValue = null, | ||
onChange, | ||
}: EventPeriodInputProps) => { | ||
return ( | ||
<EventPeriodInputAux defaultValue={defaultValue} onChange={onChange} /> | ||
); | ||
}; | ||
|
||
export default EventPeriodInput; |
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