Skip to content

Commit

Permalink
fix: study was not returned completely
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesvedder committed Jul 4, 2023
1 parent 2ce9f68 commit db20562
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
12 changes: 4 additions & 8 deletions core/lib/src/models/tables/study.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Study extends SupabaseObjectFunctions<Study> {
Questionnaire? fhirQuestionnaire;

@JsonKey(includeToJson: false, includeFromJson: false)
late List<StudyTag> studyTags = [];
List<StudyTag> studyTags = [];

@JsonKey(includeToJson: false, includeFromJson: false)
int participantCount = 0;
Expand Down Expand Up @@ -108,16 +108,12 @@ class Study extends SupabaseObjectFunctions<Study> {
final study = _$StudyFromJson(json);
final List? studyTags = json['study_tags'] as List?;
if (studyTags != null) {
study.studyTags = studyTags
.map(
study.studyTags = studyTags.map(
(json) => StudyTag.fromTag(
studyId: study.id,
tag: Tag.fromJson(json as Map<String, dynamic>),
),
)
.toList();
} else {
study.studyTags = [];
).toList();
}

final List? repo = json['repo'] as List?;
Expand Down Expand Up @@ -265,6 +261,6 @@ class Study extends SupabaseObjectFunctions<Study> {

@override
String toString() {
return 'Study{id: $id, title: $title, description: $description, tag: $studyTags, userId: $userId, participation: $participation, resultSharing: $resultSharing, contact: $contact, iconName: $iconName, published: $published, questionnaire: $questionnaire, eligibilityCriteria: $eligibilityCriteria, consent: $consent, interventions: $interventions, observations: $observations, schedule: $schedule, reportSpecification: $reportSpecification, results: $results, collaboratorEmails: $collaboratorEmails, registryPublished: $registryPublished, fhirQuestionnaire: $fhirQuestionnaire, participantCount: $participantCount, endedCount: $endedCount, activeSubjectCount: $activeSubjectCount, missedDays: $missedDays, repo: $repo, invites: $invites, participants: $participants, participantsProgress: $participantsProgress, createdAt: $createdAt}';
return 'Study{id: $id, title: $title, description: $description, studyTags: $studyTags, userId: $userId, participation: $participation, resultSharing: $resultSharing, contact: $contact, iconName: $iconName, published: $published, questionnaire: $questionnaire, eligibilityCriteria: $eligibilityCriteria, consent: $consent, interventions: $interventions, observations: $observations, schedule: $schedule, reportSpecification: $reportSpecification, results: $results, collaboratorEmails: $collaboratorEmails, registryPublished: $registryPublished, fhirQuestionnaire: $fhirQuestionnaire, participantCount: $participantCount, endedCount: $endedCount, activeSubjectCount: $activeSubjectCount, missedDays: $missedDays, repo: $repo, invites: $invites, participants: $participants, participantsProgress: $participantsProgress, createdAt: $createdAt}';
}
}
4 changes: 2 additions & 2 deletions designer_v2/lib/domain/study.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ extension StudyDuplicateX on Study {
return copy;
}

// todo tags
Study copyJsonIgnoredAttributes({required Study from, createdAt = false}) {
studyTags = from.studyTags;
participantCount = from.participantCount;
activeSubjectCount = from.activeSubjectCount;
endedCount = from.endedCount;
Expand All @@ -147,8 +147,8 @@ extension StudyDuplicateX on Study {
return this;
}

// todo tags
Study resetJsonIgnoredAttributes() {
studyTags = [];
participantCount = 0;
activeSubjectCount = 0;
endedCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class StudyDesignInfoFormView extends StudyDesignPageWidget {
labelHelpText: 'tr.form_field_study_tags_tooltip',
input: ReactiveFormConsumer(builder: (context, form, child) {
final tags = ref.read(tagRepositoryProvider);
final studyTags = ref.watch(studyTagRepositoryProvider(studyId));
final studyTags = ref.read(studyTagRepositoryProvider(studyId));
final selectedTags = formViewModel.tagsControl.value!
.map((e) => MultiSelectItem<Tag>(value: e.tag, name: e.name))
.toList();
Expand Down
4 changes: 2 additions & 2 deletions designer_v2/lib/repositories/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class StudyUApiClient extends SupabaseClientDependant with SupabaseQueryMixin im
@override
Future<Study> saveStudy(Study study) async {
await _testDelay();
// Chain a fetch request to make sure we return a complete & updated study
final request = study.save(); //.then((study) => fetchStudy(study.id));
// Chain a fetch request to make sure we return a complete and updated study
final request = study.save().then((study) => fetchStudy(study.id));
return _awaitGuarded<Study>(request);
}

Expand Down

0 comments on commit db20562

Please sign in to comment.