Skip to content

Commit 501afe6

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 970c961 + 4cd6019 commit 501afe6

14 files changed

+91
-68
lines changed

packages/openchs-android/android/app/build.gradle

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ googleServices {
77

88
import com.android.build.OutputFile
99

10+
def enableHermes = System.getenv("enableHermes") ? System.getenv("enableHermes").toBoolean() : false;
11+
println('[Avni] Hermes Enabled:' + enableHermes)
12+
1013
project.ext.react = [
11-
extraPackagerArgs: ["--sourcemap-output", "$buildDir/generated/sourcemap.js"]
14+
extraPackagerArgs: ["--sourcemap-output", "$buildDir/generated/sourcemap.js"],
15+
enableHermes: enableHermes
1216
]
1317

1418
apply from: "../../node_modules/react-native/react.gradle"
@@ -29,7 +33,6 @@ def enableSeparateBuildPerCPUArchitecture = System.getenv("enableSeparateBuildPe
2933
*/
3034
def enableProguardInReleaseBuilds = true
3135

32-
def jscFlavor = 'org.webkit:android-jsc:+'
3336

3437
android {
3538
ndkVersion rootProject.ext.ndkVersion
@@ -143,14 +146,21 @@ dependencies {
143146
implementation "androidx.appcompat:appcompat:${rootProject.ext.supportLibVersion}"
144147
implementation project(':react-native-device-info')
145148
implementation "com.facebook.react:react-native:+"
149+
implementation 'com.facebook.soloader:soloader:0.10.5'
146150
implementation 'com.android.support:multidex:1.0.1'
147151
implementation 'androidx.appcompat:appcompat:1.1.0'
148152
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
149153

150154
// required to avoid crash on Android 12 API 31
151155
implementation 'androidx.work:work-runtime:2.7.1'
152156

153-
implementation jscFlavor
157+
if (enableHermes) {
158+
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
159+
exclude group:'com.facebook.fbjni'
160+
}
161+
} else {
162+
implementation 'org.webkit:android-jsc:+'
163+
}
154164

155165
debugImplementation('com.facebook.flipper:flipper:0.174.0') {
156166
exclude group:'com.facebook.fbjni'

packages/openchs-android/android/app/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
-keep public class com.horcrux.svg.** {*;}
2222
#-keep class com.facebook.hermes.unicode.** { *; }
2323
#-keep class com.facebook.jni.** { *; }
24+
-keep class com.facebook.hermes.unicode.** { *; }
25+
-keep class com.facebook.jni.** { *; }

packages/openchs-android/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"lodash": "4.17.21",
5151
"moment": "2.29.4",
5252
"native-base": "3.4.9",
53-
"openchs-models": "1.27.25",
53+
"openchs-models": "1.27.26",
5454
"prop-types": "15.8.1",
5555
"react": "18.2.0",
5656
"react-native": "0.69.7",

packages/openchs-android/src/Playground.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ function TxQueries() {
4949
</>
5050
}
5151

52+
function SelectableGroup() {
53+
const labelValuePairs = [
54+
new RadioLabelValue("Item 1", "item1", false),
55+
new RadioLabelValue("Very very very long item 2", "item2", false),
56+
new RadioLabelValue("Very very very long item 3", "item3", false),
57+
new RadioLabelValue("Item 4", "item4", false)
58+
];
59+
60+
const singleLabelValuePairs = [
61+
new RadioLabelValue("Item 1", "item1", false)
62+
]
63+
64+
return (
65+
<CHSContainer>
66+
<SelectableItemGroup onPress={(value) => this.setState({value: value === this.state.value ? null : value})}
67+
selectionFn={(value) => this.state.value === value}
68+
labelValuePairs={singleLabelValuePairs} labelKey={"Selectable Group"}
69+
I18n={{t: _.identity}} locale={"en"} inPairs={true} allowUnselect={false} multiSelect={false}/>
70+
</CHSContainer>
71+
);
72+
}
73+
5274
export default class App extends Component {
5375
constructor(props, context) {
5476
super(props, context);
@@ -58,24 +80,6 @@ export default class App extends Component {
5880
}
5981

6082
render() {
61-
const labelValuePairs = [
62-
new RadioLabelValue("Item 1", "item1", false),
63-
new RadioLabelValue("Very very very long item 2", "item2", false),
64-
new RadioLabelValue("Very very very long item 3", "item3", false),
65-
new RadioLabelValue("Item 4", "item4", false)
66-
];
67-
68-
const singleLabelValuePairs = [
69-
new RadioLabelValue("Item 1", "item1", false)
70-
]
71-
72-
return (
73-
<CHSContainer>
74-
<SelectableItemGroup onPress={(value) => this.setState({value: value === this.state.value ? null : value})}
75-
selectionFn={(value) => this.state.value === value}
76-
labelValuePairs={singleLabelValuePairs} labelKey={"Selectable Group"}
77-
I18n={{t: _.identity}} locale={"en"} inPairs={true} allowUnselect={false} multiSelect={false}/>
78-
</CHSContainer>
79-
);
83+
return <TxQueries/>;
8084
}
8185
}

packages/openchs-android/src/service/EncounterService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class EncounterService extends BaseService {
9090
const db = this.db;
9191
this.db.write(() => {
9292
if (!skipCreatingPendingStatus && isApprovalEnabled)
93-
encounter.latestEntityApprovalStatus = entityApprovalStatusService.createPendingStatus(encounter.uuid, Encounter.schema.name, db);
93+
encounter.latestEntityApprovalStatus = entityApprovalStatusService.createPendingStatus(encounter.uuid, Encounter.schema.name, db, encounter.encounterType.uuid);
9494
this._saveEncounter(encounter, db);
9595
this.saveScheduledVisits(encounter.individual, nextScheduledVisits, db, encounter.encounterDateTime);
9696
});

packages/openchs-android/src/service/EntityApprovalStatusService.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class EntityApprovalStatusService extends BaseService {
2828
return EntityApprovalStatus.schema.name;
2929
}
3030

31-
saveStatus(entityUUID, entityType, status, db, approvalStatusComment) {
31+
saveStatus(entityUUID, entityType, status, db, approvalStatusComment, entityTypeUuid) {
3232
const approvalStatus = this.getService(EntityService).findByKey("status", status, ApprovalStatus.schema.name);
33-
const entityApprovalStatus = EntityApprovalStatus.create(entityUUID, entityType, approvalStatus, approvalStatusComment);
33+
const entityApprovalStatus = EntityApprovalStatus.create(entityUUID, entityType, approvalStatus, approvalStatusComment, false, entityTypeUuid);
3434
const savedStatus = db.create(this.getSchema(), entityApprovalStatus);
3535
db.create(EntityQueue.schema.name, EntityQueue.create(savedStatus, this.getSchema()));
3636
return savedStatus;
@@ -77,14 +77,16 @@ class EntityApprovalStatusService extends BaseService {
7777
this.saveEntityWithStatus(entity, schema, ApprovalStatus.statuses.Rejected, comment);
7878
}
7979

80-
createPendingStatus(entityUUID, schema, db) {
81-
return this.saveStatus(entityUUID, this._getEntityTypeForSchema(schema), ApprovalStatus.statuses.Pending, db);
80+
createPendingStatus(entityUUID, schema, db, entityTypeUuid) {
81+
return this.saveStatus(entityUUID, this._getEntityTypeForSchema(schema), ApprovalStatus.statuses.Pending, db, null, entityTypeUuid);
8282
}
8383

8484
saveEntityWithStatus(entity, schema, status, comment) {
8585
const db = this.db;
86+
const entityTypeUuid = _.get(entity, 'subjectType.uuid') || _.get(entity, 'encounterType.uuid') || _.get(entity, 'program.uuid');
87+
8688
this.db.write(() => {
87-
entity.latestEntityApprovalStatus = this.saveStatus(entity.uuid, this._getEntityTypeForSchema(schema), status, db, comment);
89+
entity.latestEntityApprovalStatus = this.saveStatus(entity.uuid, this._getEntityTypeForSchema(schema), status, db, comment, entityTypeUuid);
8890
db.create(schema, entity, true);
8991
db.create(EntityQueue.schema.name, EntityQueue.create(entity, schema));
9092
});

packages/openchs-android/src/service/EntitySyncStatusService.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class EntitySyncStatusService extends BaseService {
5757
const entityQueueService = this.getService(EntityQueueService);
5858
const entities = _.map(this.findAllByUniqueEntityName(), ({entityName, loadedSince}) => {
5959
const isNeverSynced = loadedSince.getTime() === EntitySyncStatus.REALLY_OLD_DATE.getTime();
60+
6061
return {
6162
entityName: entityName,
6263
loadedSince: isNeverSynced ? 'Never' : moment(loadedSince).format("DD-MM-YYYY HH:MM:SS"),
@@ -88,6 +89,7 @@ class EntitySyncStatusService extends BaseService {
8889
if (_.isNil(self.get(entity.entityName)) && _.isEmpty(entity.privilegeParam)) {
8990
General.logDebug('EntitySyncStatusService', `Setting up base entity sync status for ${entity.entityName}`);
9091
try {
92+
//TODO check that this works
9193
const entitySyncStatus = EntitySyncStatus.create(entity.entityName, EntitySyncStatus.REALLY_OLD_DATE, General.randomUUID(), '');
9294
self.save(entitySyncStatus);
9395
} catch (e) {

packages/openchs-android/src/service/IndividualService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class IndividualService extends BaseService {
7272
const isApprovalEnabled = formMappingService.isApprovalEnabledForRegistrationForm(individual.subjectType);
7373
this.db.write(() => {
7474
if (!skipCreatingPendingStatus && isApprovalEnabled)
75-
individual.latestEntityApprovalStatus = this.entityApprovalStatusService.createPendingStatus(individual.uuid, Individual.schema.name, db);
75+
individual.latestEntityApprovalStatus = this.entityApprovalStatusService.createPendingStatus(individual.uuid, Individual.schema.name, db, individual.subjectType.uuid);
7676
const saved = db.create(Individual.schema.name, individual, true);
7777
db.create(EntityQueue.schema.name, EntityQueue.create(individual, Individual.schema.name));
7878
this.getService(MediaQueueService).addMediaToQueue(individual, Individual.schema.name);

packages/openchs-android/src/service/PrivilegeService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class PrivilegeService extends BaseService {
7979
}
8080
const requiredEntities = ['Encounter', 'ProgramEncounter', 'ChecklistItem', 'Checklist', 'IndividualRelationship', 'ProgramEnrolment', 'Individual'];
8181
const metadata = EntityMetaData.model().filter(({type, entityName}) => type === "tx" && _.includes(requiredEntities, entityName));
82-
const getNonPrivilegeUUIDs = (entityName) => {
82+
const x = (entityName) => {
8383
const {privilegeEntity, privilegeName, privilegeParam} = _.find(metadata, d => d.entityName === entityName);
8484
return this.getRevokedEntityTypeUuidList(privilegeEntity, privilegeName, privilegeParam);
8585
};

packages/openchs-android/src/service/ProgramEnrolmentService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ProgramEnrolmentService extends BaseService {
8181
this.db.write(() => {
8282
ProgramEnrolmentService.convertObsForSave(programEnrolment);
8383
if (!skipCreatingPendingStatus && isApprovalEnabled)
84-
programEnrolment.latestEntityApprovalStatus = entityApprovalStatusService.createPendingStatus(programEnrolment.uuid, ProgramEnrolment.schema.name, db);
84+
programEnrolment.latestEntityApprovalStatus = entityApprovalStatusService.createPendingStatus(programEnrolment.uuid, ProgramEnrolment.schema.name, db, programEnrolment.program.uuid);
8585
programEnrolment = db.create(ProgramEnrolment.schema.name, programEnrolment, true);
8686
entityQueueItems.push(EntityQueue.create(programEnrolment, ProgramEnrolment.schema.name));
8787
this.getService(MediaQueueService).addMediaToQueue(programEnrolment, ProgramEnrolment.schema.name);
@@ -116,7 +116,7 @@ class ProgramEnrolmentService extends BaseService {
116116
const isApprovalEnabled = this.getService(FormMappingService).isApprovalEnabledForProgramForm(individual.subjectType, programEnrolment.program, true);
117117
this.db.write(() => {
118118
if (!skipCreatingPendingStatus && isApprovalEnabled)
119-
programEnrolment.latestEntityApprovalStatus = entityApprovalStatusService.createPendingStatus(programEnrolment.uuid, ProgramEnrolment.schema.name, db);
119+
programEnrolment.latestEntityApprovalStatus = entityApprovalStatusService.createPendingStatus(programEnrolment.uuid, ProgramEnrolment.schema.name, db, programEnrolment.program.uuid);
120120
db.create(ProgramEnrolment.schema.name, programEnrolment, true);
121121
db.create(EntityQueue.schema.name, EntityQueue.create(programEnrolment, ProgramEnrolment.schema.name));
122122
_.forEach(groupSubjectObservations, this.getService(GroupSubjectService).addSubjectToGroup(individual, db));

0 commit comments

Comments
 (0)