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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: format
  • Loading branch information
johannesvedder committed Jun 12, 2024
commit e27a58027240ffd52906ba61c3f938b1d6c369a0
7 changes: 5 additions & 2 deletions core/lib/src/models/tables/study.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,11 @@ class Study extends SupabaseObjectFunctions<Study>
static Future<ExtractionResult<Study>> publishedPublicStudies() async {
ExtractionResult<Study> result;
try {
final response =
await env.client.from(tableName).select().eq('participation', 'open').neq('status', StudyStatus.closed.name);
final response = await env.client
.from(tableName)
.select()
.eq('participation', 'open')
.neq('status', StudyStatus.closed.name);
final extracted = SupabaseQuery.extractSupabaseList<Study>(
List<Map<String, dynamic>>.from(response),
);
Expand Down
4 changes: 3 additions & 1 deletion core/lib/src/models/tables/study_subject.dart
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ class StudySubject extends SupabaseObjectFunctions<StudySubject> {
Future<StudySubject> save({bool onlyUpdate = false}) async {
try {
final tableQuery = env.client.from(tableName);
final query = onlyUpdate ? tableQuery.update(toJson()).eq("id", id) : tableQuery.upsert(toJson());
final query = onlyUpdate
? tableQuery.update(toJson()).eq("id", id)
: tableQuery.upsert(toJson());
final response = await query.select();
final json = toFullJson(
partialJson: List<Map<String, dynamic>>.from(response).single,
Expand Down
24 changes: 12 additions & 12 deletions designer_v2/lib/common_views/action_popup_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ class ActionPopUpMenuButton extends StatelessWidget {
itemBuilder: (BuildContext context) {
final textTheme = theme.textTheme.labelMedium!;
final List<PopupMenuEntry> popupList = [];
for (final action in actions) {
if (action.isSeparator) {
popupList.add(const PopupMenuDivider());
continue;
}
popupList.add(PopupMenuItem(
value: action,
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 8.0),
for (final action in actions) {
if (action.isSeparator) {
popupList.add(const PopupMenuDivider());
continue;
}
popupList.add(PopupMenuItem(
value: action,
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 8.0),
horizontalTitleGap: 4.0,
leading: (action.icon == null)
? const SizedBox.shrink()
Expand All @@ -112,9 +112,9 @@ class ActionPopUpMenuButton extends StatelessWidget {
: Text(action.label, style: textTheme),
),
));
continue;
}
return popupList;
continue;
}
return popupList;
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ 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 formViewModel =
ref.watch(studySettingsFormViewModelProvider(studyId));

return ReactiveForm(
formGroup: formViewModel.form,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class CloseSuccessDialog extends StudyPageWidget {
EmptyBody(
leading: Text("\u{1f512}".hardcoded,
style: theme.textTheme.displayLarge?.copyWith(
fontSize: (theme.textTheme.displayLarge?.fontSize ?? 48.0) * 1.5,
fontSize:
(theme.textTheme.displayLarge?.fontSize ?? 48.0) * 1.5,
)),
title: tr.notification_study_closed,
description: tr.notification_study_closed_description,
Expand Down
11 changes: 8 additions & 3 deletions designer_v2/lib/features/dialogs/study_dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ class StudyDialog extends StudyPageWidget {

switch (dialogType) {
case StudyDialogType.publish:
return state.isPublished ? PublishSuccessDialog(studyId) : PublishConfirmationDialog(studyId);
return state.isPublished
? PublishSuccessDialog(studyId)
: PublishConfirmationDialog(studyId);
case StudyDialogType.close:
return state.isClosed ? CloseSuccessDialog(studyId) : CloseConfirmationDialog(studyId);
return state.isClosed
? CloseSuccessDialog(studyId)
: CloseConfirmationDialog(studyId);
}
}
}

showStudyDialog(BuildContext context, StudyID studyId, StudyDialogType dialogType) {
showStudyDialog(
BuildContext context, StudyID studyId, StudyDialogType dialogType) {
final theme = Theme.of(context);
return showDialog(
context: context,
Expand Down
4 changes: 2 additions & 2 deletions designer_v2/lib/features/recruit/study_recruit_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ class StudyRecruitScreen extends StudyPageWidget {
? null
: () {
final formViewModel =
ref.read(inviteCodeFormViewModelProvider(studyId));
ref.read(inviteCodeFormViewModelProvider(studyId));
showFormSideSheet<InviteCodeFormViewModel>(
context: context,
formViewModel: formViewModel,
formViewBuilder: (formViewModel) =>
InviteCodeFormView(formViewModel: formViewModel),
InviteCodeFormView(formViewModel: formViewModel),
);
},
);
Expand Down
9 changes: 6 additions & 3 deletions designer_v2/lib/features/study/study_controller_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ class StudyControllerState extends StudyControllerBaseState
this.lastSynced,
});

bool get isPublished => study.value != null && study.value!.status == StudyStatus.running;
bool get isPublished =>
study.value != null && study.value!.status == StudyStatus.running;

bool get isClosed => study.value != null && study.value!.status == StudyStatus.closed;
bool get isClosed =>
study.value != null && study.value!.status == StudyStatus.closed;

// - ISyncIndicatorViewModel

Expand Down Expand Up @@ -79,7 +81,8 @@ class StudyControllerState extends StudyControllerBaseState

@override
bool get isClosedVisible =>
studyWithMetadata?.model.status == StudyStatus.running && studyWithMetadata!.model.canEdit(super.currentUser);
studyWithMetadata?.model.status == StudyStatus.running &&
studyWithMetadata!.model.canEdit(super.currentUser);

@override
StudyStatus? get studyStatus => study.value?.status;
Expand Down
11 changes: 7 additions & 4 deletions designer_v2/lib/features/study/study_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:studyu_designer_v2/common_views/utils.dart';
import 'package:studyu_designer_v2/constants.dart';
import 'package:studyu_designer_v2/features/app_drawer.dart';
import 'package:studyu_designer_v2/features/design/study_form_providers.dart';
import 'package:studyu_designer_v2/features/dialogs/study_dialogs.dart';
import 'package:studyu_designer_v2/features/forms/form_validation.dart';
import 'package:studyu_designer_v2/features/study/study_controller.dart';
import 'package:studyu_designer_v2/features/study/study_controller_state.dart';
Expand All @@ -20,7 +21,6 @@ import 'package:studyu_designer_v2/features/study/study_page_view.dart';
import 'package:studyu_designer_v2/features/study/study_status_badge.dart';
import 'package:studyu_designer_v2/localization/app_translation.dart';
import 'package:studyu_designer_v2/theme.dart';
import 'package:studyu_designer_v2/features/dialogs/study_dialogs.dart';

abstract class IStudyAppBarViewModel
implements IStudyStatusBadgeViewModel, IStudyNavViewModel {
Expand Down Expand Up @@ -243,7 +243,8 @@ class _StudyScaffoldState extends ConsumerState<StudyScaffold> {
"${tr.form_invalid_prompt}\n\n${form.validationErrorSummary}",
icon: null,
enabled: formViewModel.isValid,
onPressed: () => showStudyDialog(context, widget.studyId, StudyDialogType.publish),
onPressed: () => showStudyDialog(
context, widget.studyId, StudyDialogType.publish),
);
},
),
Expand All @@ -253,7 +254,8 @@ class _StudyScaffoldState extends ConsumerState<StudyScaffold> {
}

if (state.isClosedVisible) {
final formViewModel = ref.watch(studyPublishValidatorProvider(widget.studyId));
final formViewModel =
ref.watch(studyPublishValidatorProvider(widget.studyId));
final closeButton = ReactiveForm(
formGroup: formViewModel.form,
child: ReactiveFormConsumer(
Expand All @@ -262,7 +264,8 @@ class _StudyScaffoldState extends ConsumerState<StudyScaffold> {
return SecondaryButton(
text: tr.action_button_study_close,
icon: null,
onPressed: () => showStudyDialog(context, widget.studyId, StudyDialogType.close),
onPressed: () =>
showStudyDialog(context, widget.studyId, StudyDialogType.close),
);
}),
);
Expand Down
1 change: 0 additions & 1 deletion designer_v2/lib/features/study/study_status_badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class StudyStatusBadge extends StatelessWidget {

final tooltipMessage =
'${status?.description ?? ''}\n${(status == StudyStatus.closed ? null : participation?.description) ?? ''}'

.trim();

Widget inTooltip(Widget child) {
Expand Down
7 changes: 4 additions & 3 deletions designer_v2/lib/utils/model_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class ModelAction<T> {
required this.label,
required this.onExecute,
this.isSeparator = false,
this.isAvailable = true,
this.isDestructive = false,
this.icon,});
this.isAvailable = true,
this.isDestructive = false,
this.icon,
});

static ModelAction addSeparator() {
return ModelAction(
Expand Down