Skip to content

Commit

Permalink
Merge branch '8.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/openchs-android/package-lock.json
#	packages/openchs-android/package.json
#	packages/openchs-android/src/views/customDashboard/CustomDashboardView.js
  • Loading branch information
1t5j0y committed May 2, 2024
2 parents a7d872a + d0503d5 commit e1361f3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class CustomDashboardActions {
static setCustomDashboardFilters(state, action, context) {
const newState = {...state};
newState.customDashboardFilters = action.filterApplied ? action.customDashboardFilters
: CustomDashboardActions.getDefaultCustomDashboardFilters();
: CustomDashboardActions.getDefaultCustomDashboardFilters();
return newState;
}
}
Expand Down
20 changes: 19 additions & 1 deletion packages/openchs-android/src/service/BackupRestoreRealm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import {EntitySyncStatus, IdentifierAssignment, UserInfo, Concept, MyGroups, UserSubjectAssignment} from 'openchs-models';
import {
EntitySyncStatus,
IdentifierAssignment,
UserInfo,
Concept,
MyGroups,
UserSubjectAssignment,
DraftSubject,
DraftEncounter
} from 'openchs-models';
import FileSystem from "../model/FileSystem";
import General from "../utility/General";
import fs from 'react-native-fs';
Expand Down Expand Up @@ -147,6 +156,10 @@ export default class BackupRestoreRealmService extends BaseService {
this._deleteUserInfoAndIdAssignment();
General.logDebug("BackupRestoreRealmService", "Deleted user info and id assignment");
})
.then(() => {
this._deleteDrafts();
General.logDebug("BackupRestoreRealmService", "Deleted drafts");
})
.then(() => {
this._restoreUserInfo(prevUserInfo);
General.logDebug("BackupRestoreRealmService", "Restoring prev userInfo to ensure we have user details" +
Expand Down Expand Up @@ -187,6 +200,11 @@ export default class BackupRestoreRealmService extends BaseService {
this._deleteAndResetSync(IdentifierAssignment.schema.name);
}

_deleteDrafts() {
this._deleteAndResetSync(DraftEncounter.schema.name);
this._deleteAndResetSync(DraftSubject.schema.name);
}

_deleteUserGroups() {
this._deleteAndResetSync(MyGroups.schema.name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DraftSubjectService extends BaseService {
const registrationForm = this.getService(FormMappingService).findRegistrationForm(subject.subjectType);
this.db.write(() => {
const saved = db.create(DraftSubject.schema.name, subject, true);
this.getService(IdentifierAssignmentService).assignPopulatedIdentifiersFromObservations(registrationForm, subject.observations);
});
}

Expand Down
15 changes: 9 additions & 6 deletions packages/openchs-android/src/state/AbstractDataEntryState.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from "lodash";
import RuleEvaluationService from "../service/RuleEvaluationService";
import {BaseEntity, SubjectType, ValidationResult, WorkItem, WorkLists, Individual, ProgramEnrolment} from "avni-models";
import General from "../utility/General";
import ObservationHolderActions from "../action/common/ObservationsHolderActions";
import ObservationsHolderActions from "../action/common/ObservationsHolderActions";
import SettingsService from "../service/SettingsService";
import Geo from "../framework/geo";
import UserInfoService from "../service/UserInfoService";
Expand Down Expand Up @@ -115,14 +115,15 @@ class AbstractDataEntryState {
handlePrevious(action, context) {
this.movePrevious();

ObservationHolderActions.updateFormElements(this.formElementGroup, this, context);
const formElementStatuses = ObservationsHolderActions.updateFormElements(this.formElementGroup, this, context);
this.observationsHolder.removeNonApplicableObs(this.formElementGroup.getFormElements(), this.filteredFormElements);

if (this.hasNoFormElements() && !this.wizard.isFirstPage()) {
General.logDebug("No form elements here. Moving to previous screen");
return this.handlePrevious(action, context);
}

const formElementRuleValidationErrors = ObservationsHolderActions.getRuleValidationErrors(formElementStatuses);
this.handleValidationResults(formElementRuleValidationErrors, context);
if (!(_.isNil(action) || _.isNil(action.cb)))
action.cb(this);
return this;
Expand Down Expand Up @@ -176,16 +177,18 @@ class AbstractDataEntryState {
if (action.popVerificationVew)
action.popVerificationVewFunc();
this.moveNext();
const formElementStatuses = ObservationHolderActions.updateFormElements(this.formElementGroup, this, context);
const formElementStatuses = ObservationsHolderActions.updateFormElements(this.formElementGroup, this, context);
this.observationsHolder.removeNonApplicableObs(this.formElementGroup.getFormElements(), this.filteredFormElements);
this.observationsHolder.updatePrimitiveCodedObs(this.filteredFormElements, formElementStatuses);
if (ObservationHolderActions.hasQuestionGroupWithValueInElementStatus(formElementStatuses, this.formElementGroup.getFormElements())) {
ObservationHolderActions.updateFormElements(this.formElementGroup, this, context);
if (ObservationsHolderActions.hasQuestionGroupWithValueInElementStatus(formElementStatuses, this.formElementGroup.getFormElements())) {
ObservationsHolderActions.updateFormElements(this.formElementGroup, this, context);
}
if (this.hasNoFormElements()) {
General.logDebug("No form elements here. Moving to next screen");
return this.handleNext(action, context);
}
const formElementRuleValidationErrors = ObservationsHolderActions.getRuleValidationErrors(formElementStatuses);
this.handleValidationResults(formElementRuleValidationErrors, context);
if (_.isFunction(action.movedNext)) action.movedNext(this);
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class CustomDashboardView extends AbstractComponent {
reportFilters: reportFilters,
approvalStatus_status: approvalStatus_status,
indicatorActionName: Actions.LOAD_INDICATOR,
headerTitle: status || _.truncate(reportCard.name, {'length': 30}),
headerTitle: _.truncate(reportCard.name, {'length': 30}) || status,
results: results,
reportCardUUID,
listType: _.lowerCase(status),
Expand Down

0 comments on commit e1361f3

Please sign in to comment.