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

Feature/templatestudies Template studies support #558

Draft
wants to merge 296 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 232 commits
Commits
Show all changes
296 commits
Select commit Hold shift + click to select a range
d5cb004
fix: add margin between create button and overlay
hig-dev Dec 20, 2023
d4ee6e3
feat: change create overlay item icon to add
hig-dev Dec 20, 2023
84b109c
feat: implement expandable template studies
hig-dev Dec 20, 2023
08c7729
docs: update UML documentation
Dec 20, 2023
540ecc8
feat: add new sub-study from actions menu
hig-dev Dec 20, 2023
be8a3bf
docs: update UML documentation
Dec 20, 2023
4305dc3
feat: adapt study settings for templates
hig-dev Dec 20, 2023
f15baa0
docs: update UML documentation
Dec 20, 2023
d014c8a
Add docker network creation to contributing guide
malte-j Oct 24, 2023
823a390
Fix #513 (navigation bug)
hig-dev Oct 21, 2023
c9ba731
docs: update UML documentation
Oct 21, 2023
3b0a4c1
fix: constant animation in background
alisher-turubayev Oct 3, 2023
15bda9c
fix: authFormController incorrect disposal
alisher-turubayev Oct 3, 2023
0351ad7
fix: router cannot be reassigned between tests
alisher-turubayev Oct 3, 2023
5f81eab
fix: form fields unfindable by patrol_finders
alisher-turubayev Oct 3, 2023
1f5e6a4
docs: update UML documentation
Oct 3, 2023
d71956a
WIP: sign-in/sign-up/sign-out E2E tests
alisher-turubayev Sep 14, 2023
a0842d9
WIP: added Github action to run E2E tests
alisher-turubayev Sep 20, 2023
cca756d
fix: chromedriver not run in the background
alisher-turubayev Sep 20, 2023
fb07892
feat: completed e2e tests + script
alisher-turubayev Oct 1, 2023
8e17e76
fix: added missing test files
alisher-turubayev Oct 2, 2023
0f9f4a9
style: fix lint
johannesvedder Nov 13, 2023
46069b2
chore: lock
johannesvedder Nov 13, 2023
99bc7f9
fix: uml exclude integration_test and test_driver
johannesvedder Nov 13, 2023
adc2b35
style: typo
johannesvedder Nov 13, 2023
008fff6
docs: update UML documentation
Nov 13, 2023
2f813e7
fix: docs action create docker network
johannesvedder Nov 13, 2023
f807b3a
fix: remove old env and add new hpi dev env
johannesvedder Nov 14, 2023
4036a15
docs: update database documentation
Nov 14, 2023
61d04db
fix: study test frame exception and lints
johannesvedder Nov 14, 2023
620a367
feat: add app_config.sql to database
johannesvedder Nov 14, 2023
0d82816
fix: combine all integration tests due to lack of sequential testing
johannesvedder Nov 14, 2023
4af6fe4
ci: refactor integration test gh action
johannesvedder Nov 14, 2023
556e040
docs: update UML documentation
Nov 14, 2023
ebbbada
chore: lock files
johannesvedder Nov 13, 2023
fe2d6dd
fix: dart fix
johannesvedder Nov 7, 2023
9ba8415
fix: convert status code to int
johannesvedder Nov 7, 2023
406ddab
chore: remove excluded packages
johannesvedder Nov 7, 2023
a33cc89
chore: upgrade deps
johannesvedder Nov 7, 2023
c43987a
chore: upgrade root deps
johannesvedder Nov 7, 2023
164b59f
docs: update UML documentation
Nov 13, 2023
63c1a0f
chore: format
johannesvedder Nov 13, 2023
3da01c6
fix: upgrade deps
johannesvedder Nov 13, 2023
7115e96
chore(release): publish packages
johannesvedder Nov 13, 2023
8f4d7dd
chore(release): publish packages
johannesvedder Nov 14, 2023
401b5ac
chore: lock files
johannesvedder Nov 14, 2023
02cd8a0
chore: update podfile
johannesvedder Nov 14, 2023
bf15d67
chore: remove whitespace
johannesvedder Nov 14, 2023
fe82eab
Update CONTRIBUTING.md
hig-dev Nov 29, 2023
aacd2e4
Update CONTRIBUTING.md
hig-dev Nov 29, 2023
12536f1
fix: add required manifest entries for notifications to work again
johannesvedder Nov 17, 2023
fbc8f62
fix: refresh dashboard on app resume
johannesvedder Nov 17, 2023
6581b5c
chore: format
johannesvedder Nov 17, 2023
392b602
docs: update UML documentation
Nov 17, 2023
9681463
fix: Use default env urls again
johannesvedder Nov 29, 2023
b87abdf
chore: bump test and patrol_finders for e2e test
johannesvedder Nov 29, 2023
cc0d141
chore: do not allow the password_recovery page to be publicly accessible
johannesvedder Nov 29, 2023
44bb116
docs: update UML documentation
Nov 29, 2023
d00ac48
fix: add invoker to study_progress_export view
johannesvedder Nov 16, 2023
405bcee
fix: public results are visible to anyone
johannesvedder Nov 17, 2023
29825dc
docs: update database documentation
Nov 17, 2023
0bdafbe
feat: wrap schema in transaction
johannesvedder Nov 17, 2023
a94fe5c
chore: rename sql parameter
johannesvedder Dec 7, 2023
1c4b8c9
docs: update database documentation
Dec 7, 2023
ee08041
chore: add result export migration file
johannesvedder Dec 7, 2023
e57aa24
chore: run firebase pipeline for all package changes
johannesvedder Dec 7, 2023
9fdbdd3
fix: refresh dashboard on app resume
johannesvedder Nov 17, 2023
e47e18a
chore: format
johannesvedder Nov 17, 2023
f2e5e08
docs: update UML documentation
Nov 17, 2023
9d687cf
chore: lock files
johannesvedder Dec 8, 2023
3e9cca4
fix: adapt param names
johannesvedder Dec 8, 2023
f747931
chore: format
johannesvedder Dec 8, 2023
4c73e9b
chore: lock files
johannesvedder Dec 12, 2023
f186ac7
Update issue templates
johannesvedder Dec 7, 2023
7fab082
docs: update UML documentation
Dec 10, 2023
416b4d3
style: material 3 color fixes
johannesvedder Dec 5, 2023
147b11e
docs: update UML documentation
Dec 5, 2023
b02bc09
chore: format
johannesvedder Dec 13, 2023
d03e76e
docs: update UML documentation
Dec 13, 2023
af1a369
chore: upgrade images and supabase additions
johannesvedder Nov 16, 2023
91ba8ec
feat(docker): make outer nginx ports and hostname dynamic
johannesvedder Nov 19, 2023
d810b91
feat(docker): cli add proxy and QoL changes
johannesvedder Nov 19, 2023
7d6d390
feat(docker): add status to help option
johannesvedder Nov 19, 2023
d49ea98
fix(docker): improve output
johannesvedder Nov 19, 2023
298a4af
feat(docker): add multiselect
johannesvedder Nov 19, 2023
700d738
style(docker): cosmetic
johannesvedder Nov 19, 2023
678173c
style(docker): wording
johannesvedder Nov 19, 2023
d9a5d6c
feat(docker): show current settings in cli config
johannesvedder Nov 19, 2023
d7b5d47
feat(docker): introduce clean flag to start commands
johannesvedder Nov 19, 2023
949af87
feat(docker): Introduce advanced cli functionality
johannesvedder Nov 29, 2023
4b602f1
ci: quickfix e2e tests
johannesvedder Nov 29, 2023
51a4d77
feat(cli): simplify config, refactor help, check anon keys
johannesvedder Dec 6, 2023
ec7a117
fix(cli): debug command line arguments
johannesvedder Dec 7, 2023
86d8d48
fix(cli): use proxy component also for supabase
johannesvedder Dec 7, 2023
04e5127
docs: adapt readme to new cli
johannesvedder Dec 7, 2023
36e6309
docs: linter
johannesvedder Dec 7, 2023
515a1a2
chore: make cli executable
johannesvedder Dec 7, 2023
7b57408
chore: style
johannesvedder Dec 7, 2023
aaf6d80
docs: update UML documentation
Dec 9, 2023
86d1648
refactor(docker): new studyu structure
johannesvedder Dec 11, 2023
68b8f97
fix(docker): correct studyu component path
johannesvedder Dec 11, 2023
c3da10f
refactor(docker): template order and make upstream dynamic
johannesvedder Dec 11, 2023
54b2ddd
fix(docker): move cmd command to script
johannesvedder Dec 11, 2023
2737165
fix(docker): anon key cli option modified
johannesvedder Dec 11, 2023
000f217
feat(docker): add option to modify input again for interactive dialog
johannesvedder Dec 11, 2023
224c949
style: cli
johannesvedder Dec 12, 2023
629b2c1
feat(docker): retrieve dashboard data via cli
johannesvedder Dec 12, 2023
22a9bd2
style: formatting
johannesvedder Dec 12, 2023
655fd10
fix(docker): adapt e2e pipeline
johannesvedder Dec 12, 2023
334fbde
fix: allow reconfiguration of env files
johannesvedder Dec 13, 2023
dd2ced0
fix: do not show output of network creation
johannesvedder Dec 13, 2023
7ce9397
chore: linter
johannesvedder Dec 13, 2023
090906a
chore: style
johannesvedder Dec 13, 2023
404edd1
fix: set studyu base branch based on studyu path
johannesvedder Dec 14, 2023
4e70996
fix: delete studyu images after components are stopped
johannesvedder Dec 14, 2023
13eaa4c
fix: remove url_pattern
johannesvedder Dec 14, 2023
a962767
fix: do not rely on hardcoded authcallback
johannesvedder Dec 14, 2023
2f12992
feat: add build command when starting StudyU components
johannesvedder Dec 14, 2023
c7a1d6d
style: remove double quotes from --get outputs
johannesvedder Dec 14, 2023
0970ac0
style: colors
johannesvedder Dec 14, 2023
1943b91
refactor: rename env-edit to env
johannesvedder Dec 14, 2023
60d49f0
feat: add --get to all env commands
johannesvedder Dec 14, 2023
9c9607b
refactor: unify style
johannesvedder Dec 15, 2023
b7c106f
chore: clarify proxy running message
johannesvedder Dec 15, 2023
23bb49b
refactor: clarify delete output
johannesvedder Dec 15, 2023
14cc39b
chore: improve script output and documentation
johannesvedder Dec 15, 2023
c7deec2
chore: upgrade deps
johannesvedder Dec 7, 2023
bf7da11
chore: lock files
johannesvedder Dec 19, 2023
13194e1
chore(release): publish packages
johannesvedder Dec 19, 2023
773a394
chore: lock files
johannesvedder Dec 19, 2023
ebe376d
chore: bump podfile
johannesvedder Dec 19, 2023
708ba65
docs: remove references to studyu-v1
johannesvedder Dec 19, 2023
4e33d53
Implement studies table with ListView
hig-dev Oct 26, 2023
49b42c7
docs: update UML documentation
Nov 7, 2023
d482f54
feat: collapse enrolled, active, completed if horizontal space is low
hig-dev Dec 20, 2023
12703b2
feat: implement studies table using ListView
hig-dev Oct 26, 2023
9fea74c
Animate sorting arrows
hig-dev Nov 7, 2023
14f06bb
Animate sorting arrows
hig-dev Nov 7, 2023
8b3a9ed
Implement studies table with ListView
hig-dev Oct 26, 2023
a98fa45
feat: collapse enrolled, active, completed if horizontal space is low
hig-dev Oct 26, 2023
d44470c
docs: update UML documentation
Dec 21, 2023
951cf26
feat: collapse dashboard drawer if horizontal space is low
hig-dev Dec 21, 2023
612e285
fix: hardcoded width of search bar
hig-dev Dec 21, 2023
4cc1fc9
docs: update UML documentation
Dec 21, 2023
b01544b
refactor: remove unused title
johannesvedder Dec 22, 2023
6fa2981
style: increase logo size in app drawer
johannesvedder Dec 22, 2023
4ec5f4f
refactor: use logo in app bar for compact view
johannesvedder Dec 22, 2023
b4d6fc7
docs: update UML documentation
Dec 22, 2023
3e73911
Merge pull request #560 from hpi-studyu/feat/collapsedashboardmenu-logo
hig-dev Jan 1, 2024
aa9201d
chore: Decrease studyu logo size on dashboard appbar
hig-dev Jan 1, 2024
87cb14e
fix: Close drawer after selection
hig-dev Jan 1, 2024
7cd5a5f
docs: update UML documentation
Jan 1, 2024
96e6d52
revert: "refactor: remove unused title"
hig-dev Jan 1, 2024
500e553
docs: update UML documentation
Jan 1, 2024
37d24e3
Merge remote-tracking branch 'origin/feat/collapsedashboardmenu' into…
hig-dev Jan 3, 2024
adfa366
fix: Layout overflow of status and participation badge
hig-dev Jan 3, 2024
d3aa549
feat: Collapse "Created" column when available width is very low
hig-dev Jan 3, 2024
8ca7506
fix: Remove column spacing when column is collapsed
hig-dev Jan 3, 2024
631358d
fix: Shorter text for study title in German
hig-dev Jan 3, 2024
4c2fe41
fix: Layout overflow of column headers
hig-dev Jan 3, 2024
5e5ba8a
docs: update UML documentation
Jan 3, 2024
7c3318e
Merge branch 'feature/studiestablelistview' into feature/templatestudies
hig-dev Jan 10, 2024
b196efe
Merge branch 'feature/studiestablelistview' into feature/templatestudies
hig-dev Jan 10, 2024
2153f7e
docs: update database documentation
Jan 10, 2024
b079d01
feat: add view action for templates that cannot be edited
hig-dev Jan 16, 2024
a105965
feat: adapt study publish dialog for template
hig-dev Jan 16, 2024
18375eb
Merge remote-tracking branch 'origin/dev' into feature/templatestudies
hig-dev Jan 16, 2024
aa2fa99
Revert "revert: "refactor: remove unused title""
hig-dev Jan 17, 2024
ebcdf50
fix: update of selected route in app drawer
hig-dev Jan 17, 2024
816f544
docs: update UML documentation
Jan 17, 2024
58c731a
fix: restore new study button height
hig-dev Jan 23, 2024
1f709f5
fix: alignment of the sorting arrows
hig-dev Jan 23, 2024
2bd24a6
feat: style study table item without elevation
hig-dev Jan 23, 2024
f342c19
Merge branch 'feat/studiestablelistview' into feature/templatestudies
hig-dev Jan 23, 2024
199f510
feat: better study table item design for template
hig-dev Jan 23, 2024
6424edf
Merge remote-tracking branch 'origin/dev' into feature/templatestudies
hig-dev Jan 23, 2024
0970fca
feat: adapt study selection for templates
hig-dev Jan 23, 2024
a95e59e
docs: update UML documentation
Jan 23, 2024
5004929
Merge branch 'dev' into feature/templatestudies
hig-dev Feb 13, 2024
7d5bdb0
Merge remote-tracking branch 'origin/feature/templatestudies' into fe…
hig-dev Feb 13, 2024
a408ff7
Merge branch 'dev' into feature/templatestudies
hig-dev Feb 19, 2024
4732fda
fix: search
hig-dev Feb 19, 2024
f05ee18
docs: update UML documentation
Feb 19, 2024
a0751cc
refactor: search
hig-dev Feb 19, 2024
648942d
fix: ensure that provider family works as intended
hig-dev Feb 19, 2024
63a5e27
docs: update UML documentation
Feb 19, 2024
9a075cf
fix: sorting bug with expanded templates
hig-dev Feb 26, 2024
12f0167
docs: update UML documentation
Feb 26, 2024
a04f5c5
fix: make recruiting not available more similar to under construction
hig-dev Feb 26, 2024
d19ea0a
feat: show lock tooltip without help icon
hig-dev Feb 26, 2024
7906251
fix: observation bug
hig-dev Feb 26, 2024
903cbb8
fix: change template definition to template trial and subtrial
hig-dev Feb 26, 2024
5048a5b
feat: add study type column
hig-dev Feb 26, 2024
7476ba0
docs: update UML documentation
Feb 27, 2024
acef500
Merge branch 'dev' into feature/templatestudies
hig-dev Mar 6, 2024
26fc1c7
feat: change design of trial type and participation
hig-dev Mar 6, 2024
9f48910
docs: update UML documentation
Mar 6, 2024
663c127
feat: show selected template in subtrial selection
hig-dev Mar 6, 2024
416d934
feat: show number of subtrials
hig-dev Mar 6, 2024
ee0a118
docs: update UML documentation
Mar 6, 2024
ab26a2f
Merge branch 'dev' into feature/templatestudies
hig-dev Mar 21, 2024
5203be1
fix: merging
hig-dev Mar 21, 2024
3e3b483
docs: update database documentation
Mar 21, 2024
31619d5
fix: remove local environment
hig-dev Mar 21, 2024
d5e71cd
fix: prevent joining template trial using policy
hig-dev Mar 21, 2024
8e55ce2
chore: format
johannesvedder Mar 22, 2024
000e791
Merge branch 'dev' into feature/templatestudies
johannesvedder Mar 22, 2024
4efebe8
Merge branch 'dev' into feature/templatestudies
hig-dev Apr 3, 2024
9f9fea9
Merge branch 'dev' into feature/templatestudies
johannesvedder Apr 18, 2024
3d11830
chore: format
johannesvedder Apr 18, 2024
311f10c
chore: update .env.dev
johannesvedder Apr 18, 2024
0a5f6d9
docs: update UML documentation
Apr 18, 2024
150a806
chore: add workflow_dispatch to dev deployment
johannesvedder Apr 18, 2024
3061786
Merge branch 'dev' into feature/templatestudies
hig-dev Apr 24, 2024
7c2ac31
feat: change expand to IconButton
hig-dev Apr 24, 2024
c310391
fix: remove not needed "View" action
hig-dev Apr 24, 2024
fa49864
docs: update UML documentation
Apr 24, 2024
fc00f21
Merge branch 'refs/heads/dev' into feature/templatestudies
johannesvedder Jun 28, 2024
aee587f
chore: merge and fix
johannesvedder Jun 28, 2024
c44ddc9
chore: format
johannesvedder Jun 28, 2024
191a21f
chore: fix and format
johannesvedder Jun 28, 2024
a5d416e
chore: cleanup
johannesvedder Jun 28, 2024
75aa8e0
Merge branch 'refs/heads/dev' into feature/templatestudies
johannesvedder Jul 18, 2024
30a1888
fix: merge dev
johannesvedder Jul 18, 2024
46c1415
Merge branch 'dev' into feature/templatestudies
johannesvedder Jul 23, 2024
a09ff61
style: ui/ux improvements for locking feature
ibrahimozkn Jul 24, 2024
ae668f8
fix: disabled reactive for FormLock
ibrahimozkn Jul 24, 2024
17cbf48
chore: melos fix
ibrahimozkn Jul 24, 2024
c4b4dd9
fix: study fetch for dashboard
ibrahimozkn Jul 24, 2024
2e67cc0
Merge branch 'dev' into feature/templatestudies
rajuAhmed1705 Jul 24, 2024
a1efd79
lint: Apply final newline changes
rajuAhmed1705 Jul 24, 2024
192ac2b
style: study design navbar buttons
ibrahimozkn Jul 27, 2024
1b42862
style: study type indicator in study design
ibrahimozkn Jul 27, 2024
ad64132
fix: disable view for monitoring and recruit
ibrahimozkn Jul 27, 2024
f888c09
chore: remove old widget
ibrahimozkn Jul 27, 2024
cf95529
fix: Expanding a template without subtrial does nothing on Dashboard
ibrahimozkn Jul 29, 2024
f503af8
feat: update study settings logic based on study type
ibrahimozkn Aug 13, 2024
375931e
refactor: replace flutter_portal package
ibrahimozkn Sep 1, 2024
6c6ae77
feat: db restriction policy for creation of substudies for closed tem…
ibrahimozkn Sep 23, 2024
420700d
feat: creatSubStudy model action restriction for draft and closed tem…
ibrahimozkn Sep 23, 2024
cbd3b37
feat(designer): disable adding new participants to substudies when pa…
ibrahimozkn Sep 25, 2024
6fee813
feat(designer): disable adding new participants to substudies when pa…
ibrahimozkn Sep 25, 2024
c3666e4
feat(designer): disable adding new participants to substudies when pa…
ibrahimozkn Sep 25, 2024
ba5eac1
chore: code cleanup
ibrahimozkn Sep 25, 2024
03a7428
chore: translation
ibrahimozkn Sep 25, 2024
6cec786
feat(db): prevent joining substudies with closed parent templates policy
ibrahimozkn Sep 25, 2024
733c932
feat: navigate user to welcome page if there is an error on kickoff
ibrahimozkn Sep 28, 2024
7e1bfdd
chore: translation for create study subtitles
ibrahimozkn Sep 28, 2024
cb70eda
chore: translation
ibrahimozkn Sep 28, 2024
bc8189e
style: create popup menu item
ibrahimozkn Sep 28, 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
1 change: 1 addition & 0 deletions app/lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"test": "test10",
"study_selection": "Studienauswahl",
"study_selection_description": "Bitte wählen Sie eine Studie aus.",
"sub_study_selection_description": "Bitte wählen Sie eine Unterstudie aus.",
"study_selection_single": "Sie können zu jeder Zeit maximal an einer Studie teilnehmen.",
"study_selection_single_why": "Warum?",
"study_selection_single_reason": "Wenn Sie zur selben Zeit an mehreren Studien teilnehmen würde, könnten die Kombination der Interventionen die Ergebnisse verfälschen.",
Expand Down
1 change: 1 addition & 0 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"get_started": "Get started",
"study_selection": "Study Selection",
"study_selection_description": "Please select a study.",
"sub_study_selection_description": "Please select a sub-study.",
"study_selection_single": "You can only participate in one study at a time.",
"study_selection_single_why": "Why?",
"study_selection_single_reason": "If you were to participate in multiple studies at a time, the interventions of these studies might interfere with one another and alter the results.",
Expand Down
42 changes: 36 additions & 6 deletions app/lib/screens/study/onboarding/study_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@ Future<void> navigateToStudyOverview(
Navigator.pushNamed(context, Routes.studyOverview);
}

class StudySelectionScreenArgs {
final List<Study> subStudies;

StudySelectionScreenArgs({this.subStudies = const []});
}

class StudySelectionScreen extends StatelessWidget {
const StudySelectionScreen({super.key});

@override
Widget build(BuildContext context) {
List<Study> subStudies = [];
final args = ModalRoute.of(context)!.settings.arguments;
if (args is StudySelectionScreenArgs) {
subStudies = args.subStudies;
}
final theme = Theme.of(context);
return Scaffold(
body: SafeArea(
Expand All @@ -42,7 +53,9 @@ class StudySelectionScreen extends StatelessWidget {
child: Column(
children: [
Text(
AppLocalizations.of(context)!.study_selection_description,
subStudies.isEmpty
? AppLocalizations.of(context)!.study_selection_description
: AppLocalizations.of(context)!.sub_study_selection_description,
style: theme.textTheme.headlineSmall,
),
const SizedBox(height: 8),
Expand Down Expand Up @@ -76,17 +89,34 @@ class StudySelectionScreen extends StatelessWidget {
),
Expanded(
child: RetryFutureBuilder<List<Study>>(
tryFunction: () async => Study.publishedPublicStudies(),
tryFunction: () async =>
subStudies.isEmpty ? Study.publishedPublicStudies() : Future.value(subStudies),
successBuilder: (BuildContext context, List<Study>? studies) {
// Filter out sub-studies and templates without sub studies
final filteredStudies = subStudies.isEmpty
? studies!
.where((study) =>
!study.isSubStudy &&
(!study.isTemplate || studies.any((s) => s.parentTemplateId == study.id)))
.toList()
: studies!;

return ListView.builder(
itemCount: studies!.length,
itemCount: filteredStudies.length,
itemBuilder: (context, index) {
final study = filteredStudies[index];
return Hero(
tag: 'study_tile_${studies[index].id}',
tag: 'study_tile_${study.id}',
child: Material(
child: StudyTile.fromStudy(
study: studies[index],
onTap: () => navigateToStudyOverview(context, studies[index]),
study: study,
onTap: () => study.isTemplate
? Navigator.pushNamed(context, Routes.studySelection,
arguments: StudySelectionScreenArgs(
subStudies: studies
.where((s) => s.isSubStudy && s.parentTemplateId == study.id)
.toList()))
: navigateToStudyOverview(context, study),
),
),
);
Expand Down
73 changes: 70 additions & 3 deletions core/lib/src/models/tables/study.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:csv/csv.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:studyu_core/src/env/env.dart' as env;
import 'package:studyu_core/src/models/models.dart';
import 'package:studyu_core/src/models/template/template_configuration.dart';
import 'package:studyu_core/src/util/supabase_object.dart';
import 'package:supabase/supabase.dart';
import 'package:uuid/uuid.dart';
Expand Down Expand Up @@ -34,6 +35,15 @@ enum ResultSharing {
static ResultSharing fromJson(String json) => values.byName(json);
}

enum StudyType {
standalone,
template,
subStudy;

String toJson() => name;
static StudyType fromJson(String json) => values.byName(json);
}

@JsonSerializable()
class Study extends SupabaseObjectFunctions<Study> implements Comparable<Study> {
static const String tableName = 'study';
Expand All @@ -43,6 +53,10 @@ class Study extends SupabaseObjectFunctions<Study> implements Comparable<Study>

static const String baselineID = '__baseline';
String id;
@JsonKey(name: 'parent_template_id')
String? parentTemplateId;
@JsonKey(name: 'template_configuration')
TemplateConfiguration? templateConfiguration;
String? title;
String? description;
@JsonKey(name: 'user_id')
Expand All @@ -68,7 +82,6 @@ class Study extends SupabaseObjectFunctions<Study> implements Comparable<Study>
late List<String> collaboratorEmails = [];
@JsonKey(name: 'registry_published')
late bool registryPublished = false;

@JsonKey(includeToJson: false, includeFromJson: false)
int participantCount = 0;
@JsonKey(includeToJson: false, includeFromJson: false)
Expand All @@ -95,10 +108,14 @@ class Study extends SupabaseObjectFunctions<Study> implements Comparable<Study>

Study(this.id, this.userId);

Study.withId(this.userId) : id = const Uuid().v4();
Study.create(this.userId) : id = const Uuid().v4();

factory Study.fromJson(Map<String, dynamic> json) {
final study = _$StudyFromJson(json);
final parentTemplateId = json['parent_template_id'] as String?;
final templateConfiguration = json['template_configuration'];
final study = parentTemplateId != null
? _$TemplateSubStudyFromJson(json)
: (templateConfiguration != null ? _$TemplateFromJson(json) : _$StudyFromJson(json));

final List? repo = json['repo'] as List?;
if (repo != null && repo.isNotEmpty) {
Expand Down Expand Up @@ -177,6 +194,20 @@ class Study extends SupabaseObjectFunctions<Study> implements Comparable<Study>
}
}

StudyType get type {
if (parentTemplateId != null) {
return StudyType.subStudy;
}
if (templateConfiguration != null) {
return StudyType.template;
}
return StudyType.standalone;
}

bool get isStandalone => type == StudyType.standalone;
bool get isTemplate => type == StudyType.template;
bool get isSubStudy => type == StudyType.subStudy;

bool isOwner(User? user) => user != null && userId == user.id;

bool isEditor(User? user) => user != null && collaboratorEmails.contains(user.email);
Expand Down Expand Up @@ -252,3 +283,39 @@ class Study extends SupabaseObjectFunctions<Study> implements Comparable<Study>
return id.compareTo(other.id);
}
}

@JsonSerializable()
class Template extends Study {
Template(super.id, super.userId);

Template.create(String userId) : super(const Uuid().v4(), userId) {
templateConfiguration = TemplateConfiguration();
}
}

@JsonSerializable()
class TemplateSubStudy extends Study {
TemplateSubStudy(super.id, super.userId);

TemplateSubStudy.create(String userId, Template template) : super(const Uuid().v4(), userId) {
if (template.templateConfiguration == null) {
throw ArgumentError('Template must have a templateConfiguration');
}
parentTemplateId = template.id;
templateConfiguration =
template.templateConfiguration!.copyWith(title: template.title, description: template.description);
participation = template.participation;
resultSharing = template.resultSharing;
contact = template.contact;
iconName = template.iconName;
questionnaire = template.questionnaire;
eligibilityCriteria = template.eligibilityCriteria;
consent = template.consent;
interventions = template.interventions;
observations = template.observations;
schedule = template.schedule;
reportSpecification = template.reportSpecification;
collaboratorEmails = template.collaboratorEmails;
registryPublished = template.registryPublished;
}
}
169 changes: 169 additions & 0 deletions core/lib/src/models/tables/study.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading