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

feat: Introduce study status and add closing state #634

Merged
merged 24 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5c0f04f
chore: translation
johannesvedder May 25, 2024
3cf8804
feat: deprecate published for study_status
johannesvedder May 25, 2024
29310b7
chore: create migration temporarily
johannesvedder May 26, 2024
9aba30c
fix: improve status transition rules
johannesvedder May 26, 2024
15a72e5
feat: study close button
johannesvedder Jun 7, 2024
881f856
chore: format
johannesvedder Jun 7, 2024
acdbb1c
chore: copy migration to schema
johannesvedder Jun 10, 2024
aed1eff
fix: merge dashboard refactor pr
johannesvedder Jun 11, 2024
051552d
chore: fix seed
johannesvedder Jun 11, 2024
dbd1810
fix: study visibility policy no longer uses published field
johannesvedder Jun 11, 2024
1ce2f78
fix: potential isClosed error
johannesvedder Jun 11, 2024
7dcc928
fix: migrate app to status
johannesvedder Jun 11, 2024
1cb7740
fix: do not show separator if no delete item shown
johannesvedder Jun 11, 2024
b6dad92
fix: only show close button for editors
johannesvedder Jun 11, 2024
547c468
fix: add closed success description
johannesvedder Jun 11, 2024
4beb796
style: format
johannesvedder Jun 11, 2024
9ffc7ce
tests: migrate db test to status
johannesvedder Jun 11, 2024
7c5b8ae
tests: fix workflow trigger
johannesvedder Jun 11, 2024
f190d1f
Merge branch 'dev' into feat/study-closing-studystatus
johannesvedder Jun 12, 2024
e27a580
chore: format
johannesvedder Jun 12, 2024
dad913e
chore: format
johannesvedder Jun 12, 2024
cdcbca5
style: rephrase translation
johannesvedder Jun 13, 2024
9b66d33
feat: new severe close confirmation
johannesvedder Jun 13, 2024
931c4e2
Merge branch 'feat/study-closing' into feat/study-closing-studystatus
johannesvedder Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: new severe close confirmation
  • Loading branch information
johannesvedder committed Jun 13, 2024
commit 9b66d338ac1407aff9c7a038ef758816f3f6461c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:reactive_forms/reactive_forms.dart';
import 'package:studyu_core/core.dart';
import 'package:studyu_designer_v2/common_views/async_value_widget.dart';
import 'package:studyu_designer_v2/common_views/dialog.dart';
import 'package:studyu_designer_v2/common_views/form_buttons.dart';
import 'package:studyu_designer_v2/common_views/primary_button.dart';
import 'package:studyu_designer_v2/features/study/settings/study_settings_form_controller.dart';
import 'package:studyu_designer_v2/features/study/study_controller.dart';
import 'package:studyu_designer_v2/features/study/study_page_view.dart';
import 'package:studyu_designer_v2/localization/app_translation.dart';
Expand All @@ -15,51 +15,62 @@ class CloseConfirmationDialog extends StudyPageWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final controller = ref.watch(studyControllerProvider(studyId).notifier);
final formViewModel =
ref.watch(studySettingsFormViewModelProvider(studyId));
final state = ref.watch(studyControllerProvider(studyId));
final formKey = GlobalKey<FormState>();
String? inputStudyName;

return ReactiveForm(
formGroup: formViewModel.form,
child: StandardDialog(
titleText: tr.dialog_study_close_title,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
return AsyncValueWidget<Study>(
value: state.study,
data: (Study study) {
return StandardDialog(
titleText: tr.dialog_study_close_title,
body: Form(
key: formKey,
child: Column(
children: [
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(
text: tr.dialog_study_close_description,
),
),
],
Text(tr.dialog_study_close_description),
const SizedBox(height: 16.0),
SelectableText(
'Enter the title of the study "${study.title}" to confirm that you want to close it:',
),
const SizedBox(height: 16.0),
TextFormField(
decoration: const InputDecoration(
labelText: 'Title of the study to close',
),
validator: (value) {
if (value == null || value != study.title) {
return 'Study title does not match';
}
return null;
},
onSaved: (value) {
inputStudyName = value;
},
),
],
),
],
),
actionButtons: [
const DismissButton(),
ReactiveFormConsumer(
builder: (context, form, child) {
return PrimaryButton(
text: tr.dialog_close,
icon: null,
onPressedFuture: () => controller.closeStudy(),
);
},
),
],
maxWidth: 650,
minWidth: 610,
minHeight: 200,
),
actionButtons: [
const DismissButton(),
PrimaryButton(
text: tr.dialog_close,
icon: null,
onPressedFuture: () async {
if (formKey.currentState!.validate()) {
formKey.currentState!.save();
if (inputStudyName == study.title) {
await controller.closeStudy();
}
}
},
),
],
maxWidth: 650,
minWidth: 610,
minHeight: 200,
);
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class CloseSuccessDialog extends StudyPageWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = Theme.of(context);

return StandardDialog(
body: Column(
children: [
Expand All @@ -34,7 +33,7 @@ class CloseSuccessDialog extends StudyPageWidget {
),
actionButtons: [
PrimaryButton(
text: tr.action_button_study_close,
text: tr.dialog_close,
icon: null,
onPressedFuture: () => Navigator.maybePop(context),
),
Expand Down
8 changes: 7 additions & 1 deletion designer_v2/lib/features/study/study_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ import 'package:studyu_designer_v2/theme.dart';
abstract class IStudyAppBarViewModel
implements IStudyStatusBadgeViewModel, IStudyNavViewModel {
bool get isSyncIndicatorVisible;

bool get isStatusBadgeVisible;

bool get isPublishVisible;

bool get isClosedVisible;
}

Expand Down Expand Up @@ -268,7 +271,10 @@ class _StudyScaffoldState extends ConsumerState<StudyScaffold> {
text: tr.action_button_study_close,
icon: null,
onPressed: () => showStudyDialog(
context, widget.studyId, StudyDialogType.close),
context,
widget.studyId,
StudyDialogType.close,
),
);
},
),
Expand Down
3 changes: 1 addition & 2 deletions designer_v2/lib/localization/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"phase_sequence_counterbalanced": "Ausgeglichen (AB BA)",
"phase_sequence_random": "Zufällig",
"phase_sequence_custom": "Benutzerdefiniert",

"form_enrollment_option_open": "Open",
"form_enrollment_option_invite": "Private (Invite-only)",
"@__________________NAV_DRAWER__________________": {},
Expand Down Expand Up @@ -123,7 +122,7 @@
"notification_study_closed": "Die Studie wurde geschlossen",
"notification_study_closed_description": "Neue Teilnehmer können sich nicht mehr einschreiben",
"dialog_study_close_title": "Teilnahme schließen?",
"dialog_study_close_description": "Bist du sicher, dass die Teilnahme an der Studie geschlossen werden soll? Es können keine neuen Teilnehmer mehr eingeschrieben werden, aber bereits angemeldete Teilnehmer können die Studie weiterhin durchführen.",
"dialog_study_close_description": "Bist du sicher, dass die Teilnahme an der Studie geschlossen werden soll? Dadurch können keine neuen Teilnehmer mehr aufgenommen werden. Bereits eingeschriebene Teilnehmer werden die Studie weiterhin durchführen können. Das Schließen einer Studie kann nicht rückgängig gemacht werden.",
"dialog_study_delete_title": "Dauerhaft löschen?",
"dialog_study_delete_description": "Bist du sicher, dass die Studie gelöscht werden soll? Die Studie und alle gesammelten Daten gehen dabei unwiderruflich verloren.",
"@__________________STUDYPAGE_DESIGN_SHARED__________________": {},
Expand Down
2 changes: 1 addition & 1 deletion designer_v2/lib/localization/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"notification_study_closed": "Study was closed",
"notification_study_closed_description": "New participants can no longer enroll in this study.",
"dialog_study_close_title": "Close participation?",
"dialog_study_close_description": "Are you sure that you want to stop new enrollments for this study? New participants can no longer join, but those who are already enrolled can still continue.",
"dialog_study_close_description": "Are you sure that you want to stop new enrollments for this study? New participants can no longer join, but those who are already enrolled can still continue. This action cannot be undone.",
"dialog_study_delete_title": "Permanently delete?",
"dialog_study_delete_description": "Are you sure you want to delete this study? You will permanently lose the study and all data that has been collected.",
"@__________________STUDYPAGE_DESIGN_SHARED__________________": {},
Expand Down