-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add group table support to repopulated items
- Loading branch information
Showing
12 changed files
with
357 additions
and
47 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
apps/smart-forms-app/src/features/repopulate/components/RepopulateGroupTable.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,63 @@ | ||
/* | ||
* Copyright 2023 Commonwealth Scientific and Industrial Research | ||
* Organisation (CSIRO) ABN 41 687 119 230. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Grid, Typography } from '@mui/material'; | ||
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4'; | ||
import { GroupTable } from '@aehrc/smart-forms-renderer'; | ||
|
||
interface RepopulateRepeatGroupProps { | ||
qItem: QuestionnaireItem; | ||
oldQRItem?: QuestionnaireResponseItem; | ||
newQRItem: QuestionnaireResponseItem; | ||
} | ||
|
||
function RepopulateGroupTable(props: RepopulateRepeatGroupProps) { | ||
const { qItem, oldQRItem, newQRItem } = props; | ||
|
||
if (!newQRItem.item) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Grid container columnSpacing={2} mt={0.25}> | ||
<Grid item xs={12}> | ||
<Typography color="text.secondary" variant="overline" fontSize={7.5}> | ||
Old answer | ||
</Typography> | ||
<GroupTable | ||
qItem={qItem} | ||
qrItems={oldQRItem ? [oldQRItem] : []} | ||
groupCardElevation={1} | ||
onQrRepeatGroupChange={() => void 0} | ||
/> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<Typography color="text.secondary" variant="overline" fontSize={7.5}> | ||
New answer | ||
</Typography> | ||
<GroupTable | ||
qItem={qItem} | ||
qrItems={[newQRItem]} | ||
groupCardElevation={1} | ||
onQrRepeatGroupChange={() => void 0} | ||
/> | ||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default RepopulateGroupTable; |
39 changes: 39 additions & 0 deletions
39
apps/smart-forms-app/src/features/repopulate/components/RepopulateItemSwitcher.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,39 @@ | ||
/* | ||
* Copyright 2023 Commonwealth Scientific and Industrial Research | ||
* Organisation (CSIRO) ABN 41 687 119 230. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4'; | ||
import RepopulateSingleItem from './RepopulateSingleItem.tsx'; | ||
import RepopulateGroupTable from './RepopulateGroupTable.tsx'; | ||
import { isSpecificItemControl } from '@aehrc/smart-forms-renderer'; | ||
|
||
interface RepopulateItemSwitcherProps { | ||
qItem: QuestionnaireItem; | ||
oldQRItem?: QuestionnaireResponseItem; | ||
newQRItem: QuestionnaireResponseItem; | ||
} | ||
|
||
function RepopulateItemSwitcher(props: RepopulateItemSwitcherProps) { | ||
const { qItem, oldQRItem, newQRItem } = props; | ||
|
||
if (qItem.type === 'group' && qItem.repeats && isSpecificItemControl(qItem, 'gtable')) { | ||
return <RepopulateGroupTable qItem={qItem} newQRItem={newQRItem} oldQRItem={oldQRItem} />; | ||
} | ||
|
||
return <RepopulateSingleItem qItem={qItem} oldQRItem={oldQRItem} newQRItem={newQRItem} />; | ||
} | ||
|
||
export default RepopulateItemSwitcher; |
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
70 changes: 70 additions & 0 deletions
70
apps/smart-forms-app/src/features/repopulate/components/RepopulateSingleItem.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,70 @@ | ||
/* | ||
* Copyright 2023 Commonwealth Scientific and Industrial Research | ||
* Organisation (CSIRO) ABN 41 687 119 230. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Grid, Stack, Typography } from '@mui/material'; | ||
import { SingleItem } from '@aehrc/smart-forms-renderer'; | ||
import { QuestionnaireItem, QuestionnaireResponseItem } from 'fhir/r4'; | ||
|
||
interface RepopulateSingleItemProps { | ||
qItem: QuestionnaireItem; | ||
oldQRItem?: QuestionnaireResponseItem; | ||
newQRItem: QuestionnaireResponseItem; | ||
} | ||
|
||
function RepopulateSingleItem(props: RepopulateSingleItemProps) { | ||
const { qItem, oldQRItem, newQRItem } = props; | ||
|
||
return ( | ||
<Grid container columnSpacing={2} mt={0.25}> | ||
<Grid item xs={12} md={6}> | ||
<Stack rowGap={0.25}> | ||
<Typography color="text.secondary" variant="overline" fontSize={7.5}> | ||
Old answer | ||
</Typography> | ||
<SingleItem | ||
qItem={qItem} | ||
qrItem={ | ||
oldQRItem ?? { | ||
linkId: qItem.linkId, | ||
text: qItem.text | ||
} | ||
} | ||
isRepeated={true} | ||
isTabled={false} | ||
onQrItemChange={() => void 0} | ||
/> | ||
</Stack> | ||
</Grid> | ||
<Grid item xs={12} md={6}> | ||
<Stack rowGap={0.25}> | ||
<Typography color="text.secondary" variant="overline" fontSize={7.5}> | ||
New answer | ||
</Typography> | ||
<SingleItem | ||
qItem={qItem} | ||
qrItem={newQRItem} | ||
isRepeated={true} | ||
isTabled={false} | ||
onQrItemChange={() => void 0} | ||
/> | ||
</Stack> | ||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default RepopulateSingleItem; |
18 changes: 18 additions & 0 deletions
18
packages/smart-forms-renderer/src/components/FormComponents/RepeatGroup/index.ts
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,18 @@ | ||
/* | ||
* Copyright 2023 Commonwealth Scientific and Industrial Research | ||
* Organisation (CSIRO) ABN 41 687 119 230. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export { default as RepeatGroup } from './RepeatGroup'; |
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
18 changes: 18 additions & 0 deletions
18
packages/smart-forms-renderer/src/components/FormComponents/Tables/index.ts
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,18 @@ | ||
/* | ||
* Copyright 2023 Commonwealth Scientific and Industrial Research | ||
* Organisation (CSIRO) ABN 41 687 119 230. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export { default as GroupTable } from './QItemGroupTable'; |
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 |
---|---|---|
|
@@ -16,3 +16,5 @@ | |
*/ | ||
|
||
export * from './SingleItem'; | ||
export * from './RepeatGroup'; | ||
export * from './Tables'; |
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,18 @@ | ||
/* | ||
* Copyright 2023 Commonwealth Scientific and Industrial Research | ||
* Organisation (CSIRO) ABN 41 687 119 230. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export { isSpecificItemControl } from './itemControl'; |
Oops, something went wrong.