Skip to content

Commit

Permalink
#1365 | Hide UserType Subject RegistrationDetails if Form not associated
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed May 2, 2024
1 parent 2ce90db commit 9e8dc5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class IndividualProfile extends AbstractComponent {
visible={this.state.displayActionSelector}
actions={this.state.programActions}
/>
<View style={{flexDirection: 'row', alignItems: 'center', paddingBottom: 10, backgroundColor: Styles.greyBackground}}>
<View style={{flexDirection: 'row', alignItems: 'center', paddingTop: 10, paddingBottom: 10, backgroundColor: Styles.greyBackground}}>
<View style={{
paddingHorizontal: 20,
justifyContent: 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,39 +297,42 @@ class SubjectDashboardProfileTab extends AbstractComponent {

renderProfile() {
const formMappingService = this.getService(FormMappingService);
const registrationForm = formMappingService.findRegistrationForm(this.state.individual.subjectType);
const createdBy = this.getService(UserInfoService).getCreatedBy(this.state.individual, this.I18n);
const createdByMessage = _.isNil(createdBy) ? "" : this.I18n.t("by", {user: createdBy});
const createdByMessage = _.isEmpty(createdBy) ? "" : this.I18n.t("by", {user: createdBy});

const editProfileCriteria = `privilege.name = '${Privilege.privilegeName.editSubject}' AND privilege.entityType = '${Privilege.privilegeEntityType.subject}' AND subjectTypeUuid = '${this.state.individual.subjectType.uuid}'`;
const voidProfileCriteria = `privilege.name = '${Privilege.privilegeName.voidSubject}' AND privilege.entityType = '${Privilege.privilegeEntityType.subject}' AND subjectTypeUuid = '${this.state.individual.subjectType.uuid}'`;
const hasEditPrivilege = this.privilegeService.hasActionPrivilegeForCriteria(editProfileCriteria, 'subjectTypeUuid');
const hasVoidPrivilege = this.privilegeService.hasActionPrivilegeForCriteria(voidProfileCriteria, 'subjectTypeUuid');
return <View>
return registrationForm ? (<View>
<TouchableOpacity onPress={() => this.dispatchAction(Actions.ON_TOGGLE, {keyName: 'expand'})}>
<View style={{flexDirection: 'column'}}>
<Text style={{fontSize: Fonts.Medium, color: Colors.DefaultPrimaryColor}}>
{`${this.I18n.t("registeredOn")} ${General.toDisplayDate(this.state.individual.registrationDate)}. ${createdByMessage}`}
</Text>
</View>
<View style={{right: 2, position: 'absolute', alignSelf: 'center'}}>
{this.state.expand === false ?
<Icon name={'arrow-down'} size={12}/> :
<Icon name={'arrow-up'} size={12}/>}
{this.state.expand === false ? <Icon name={'arrow-down'} size={12}/> :
<Icon name={'arrow-up'} size={12}/>}
</View>
</TouchableOpacity>
<View style={{marginTop: 3}}>
{this.state.expand === true ?
<View style={{paddingHorizontal: 10}}>
<Observations form={formMappingService.findRegistrationForm(this.state.individual.subjectType)}
observations={this.state.individual.observations}
style={{marginVertical: 3}}
quickFormEdit={hasEditPrivilege}
onFormElementGroupEdit={(pageNumber) => this.editSubjectByFEG(pageNumber)}
/>
</View> : <View/>}
{this.state.expand === true ? <View style={{paddingHorizontal: 10}}>
<Observations form={registrationForm}
observations={this.state.individual.observations}
style={{marginVertical: 3}}
quickFormEdit={hasEditPrivilege}
onFormElementGroupEdit={(pageNumber) => this.editSubjectByFEG(pageNumber)}
/>
</View> : <View/>}
{this.renderSelectionOptions(hasEditPrivilege, hasVoidPrivilege)}
</View>
</View>
</View>) : (<View style={{flexDirection: 'column'}}>
<Text style={{fontSize: Fonts.Medium, color: Colors.DefaultPrimaryColor}}>
{`${this.I18n.t("registeredOn")} ${General.toDisplayDate(this.state.individual.registrationDate)}. ${createdByMessage}`}
</Text>
</View>);
}

renderProfileOrVoided(individual) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SubjectDashboardProgramsTab extends AbstractComponent {

getHeaderMessage(enrolment) {
const createdBy = this.getService(UserInfoService).getCreatedBy(enrolment, this.I18n);
const createdByMessage = _.isNil(createdBy) ? "" : this.I18n.t("by", { user: createdBy });
const createdByMessage = _.isEmpty(createdBy) ? "" : this.I18n.t("by", { user: createdBy });
return (
<View>
<Text>{`${this.I18n.t("enrolledOn")} ${General.toDisplayDate(enrolment.enrolmentDateTime)}. ${createdByMessage}`}</Text>
Expand Down

0 comments on commit 9e8dc5f

Please sign in to comment.