RA-1513 Added support to allow the extensions to add the custom fragments to the Manage Account dashboard #44
Conversation
if (person != null) { | ||
PersonAttribute attr = person.getAttribute(Context.getPersonService().getPersonAttributeTypeByUuid( | ||
attributeTypeUuid)); | ||
if (attr != null) { |
dkayiwa
Jul 22, 2018
Member
What value does checking for not null add?
What value does checking for not null add?
suthagar23
Jul 23, 2018
Author
Member
No need it here, removed
No need it here, removed
@@ -13,6 +20,7 @@ angular.module("adminui.personDetails", ["personService"]) | |||
$scope.person.familyName = familyName; | |||
$scope.person.givenName = givenName; | |||
$scope.genders = {M: male, F: female}; | |||
$scope.personAttributeInfoMap = personAttributeInfoMap; |
dkayiwa
Jul 22, 2018
Member
What value does "Info" add to the name?
What value does "Info" add to the name?
suthagar23
Jul 23, 2018
Author
Member
Changed
Changed
} | ||
} | ||
} | ||
|
dkayiwa
Jul 22, 2018
Member
Can we do some bit of uniformity with our indention?
Can we do some bit of uniformity with our indention?
suthagar23
Jul 23, 2018
Author
Member
Sorry, I didn't get you properly
Sorry, I didn't get you properly
dkayiwa
Jul 23, 2018
Member
The indention is not the same. Can you look at it again?
The indention is not the same. Can you look at it again?
suthagar23
Jul 23, 2018
Author
Member
Do you mention the implementation after this line which points to person attribute? I used the existing patient registration implementation to build this one. Any brief comments to make this better?
Do you mention the implementation after this line which points to person attribute? I used the existing patient registration implementation to build this one. Any brief comments to make this better?
dkayiwa
Jul 23, 2018
Member
Can you look at lines 138 and 156?
Can you look at lines 138 and 156?
suthagar23
Jul 23, 2018
Author
Member
You mentioned about the names at these lines? "createUser.manageAccountUserFragments" and "createUser.manageAccountPersonFragments"
You mentioned about the names at these lines? "createUser.manageAccountUserFragments" and "createUser.manageAccountPersonFragments"
dkayiwa
Jul 23, 2018
Member
At what vertical column numbers do they start? In other words, do they have the same indention?
At what vertical column numbers do they start? In other words, do they have the same indention?
suthagar23
Jul 23, 2018
Author
Member
Just got it, and fixed it as well. Please see the updated code
Just got it, and fixed it as well. Please see the updated code
d28ab9b
to
1703c78
String[] parameterValues = parameterMap.get(formFiledName); | ||
if (parameterValues != null && parameterValues.length > 0) { | ||
if (parameterValues.length > 1) { | ||
log.warn("Multiple values for a single person attribute type not supported, ignoring extra values"); |
dkayiwa
Jul 23, 2018
Member
Shouldn't you throw an exception for the above?
Shouldn't you throw an exception for the above?
suthagar23
Jul 23, 2018
Author
Member
if we sent the exception, then it will break the registration workflow. It will happen when the user configured the dashboard with duplicate filed ids. In the patient registration also, We followed this way.
if we sent the exception, then it will break the registration workflow. It will happen when the user configured the dashboard with duplicate filed ids. In the patient registration also, We followed this way.
Object type = ext.getExtensionParams().get("type"); | ||
Object personAttributeTypeUuid = ext.getExtensionParams().get("uuid"); | ||
Person person = account.getPerson(); | ||
if (person!=null && type!=null && personAttributeTypeUuid!=null && |
dkayiwa
Jul 23, 2018
Member
Can we put some spaces for != null
Can we put some spaces for != null
suthagar23
Jul 23, 2018
Author
Member
added
added
@@ -10,6 +10,11 @@ | |||
%> | |||
|
|||
<% if(!createAccount) { %> | |||
<script type="text/javascript"> | |||
//This function is in personDetails.js |
dkayiwa
Jul 23, 2018
Member
Do we need the above comment?
Do we need the above comment?
title : ui.message(sect.extensionParams.title), | ||
label : ui.message(sect.extensionParams.label), | ||
initialValue : ui.message(account.getPersonAttribute(sect.extensionParams.uuid) != null ? | ||
account.getPersonAttribute(sect.extensionParams.uuid).value : '') |
dkayiwa
Jul 23, 2018
Member
Can we indent the above line correctly?
Can we indent the above line correctly?
suthagar23
Jul 23, 2018
Author
Member
That is the continue part of the above line. Does it contain wrong indent?
That is the continue part of the above line. Does it contain wrong indent?
var personToSave = { | ||
uuid: $scope.person.personUuid, | ||
gender: $scope.person.gender, | ||
names: [{ | ||
uuid: $scope.person.personNameUuid, | ||
familyName: $scope.person.familyName, | ||
givenName: $scope.person.givenName}] | ||
givenName: $scope.person.givenName}], | ||
attributes: attributesSet |
dkayiwa
Jul 23, 2018
Member
Can you indent the above correctly?
Can you indent the above correctly?
suthagar23
Jul 23, 2018
Author
Member
changed
changed
personId : account.person.personId, | ||
personUuid : account.person.uuid, | ||
initialValue : ui.message(account.getPersonAttribute(sect.extensionParams.uuid) != null ? | ||
account.getPersonAttribute(sect.extensionParams.uuid).value : '') |
dkayiwa
Jul 23, 2018
Member
Can you indent the above correctly?
Can you indent the above correctly?
suthagar23
Jul 23, 2018
Author
Member
That is the continue part of the above line. Does it contain wrong indent?
That is the continue part of the above line. Does it contain wrong indent?
@@ -138,6 +138,15 @@ angular.module("adminui.userDetails", ["userService", "ngDialog", "adminui.shoul | |||
if(modelUser.userProperties.forcePassword){ | |||
uProperties.forcePassword = "true"; | |||
} | |||
angular.forEach(modelUser.userProperties, function(value, key) { | |||
if(key != "forcePassword") { | |||
var domElement = document.getElementById(key+userUuid); |
dkayiwa
Jul 23, 2018
Member
Can we put spaces around the + sign?
Can we put spaces around the + sign?
suthagar23
Jul 23, 2018
Author
Member
changed
changed
@@ -128,6 +128,16 @@ | |||
ng-model="uuidUserMap['${userUuid}'].userProperties.forcePassword" />${ ui.message("adminui.account.user.forcePasswordChange") } | |||
</p> | |||
|
|||
<% customUserFragments.each { sect -> %> | |||
${ ui.includeFragment(sect.extensionParams.provider, sect.extensionParams.fragment, [ | |||
formFieldName : sect.extensionParams.userPropertyName+userUuid, |
dkayiwa
Jul 23, 2018
Member
Can we put spaces around the + sign?
Can we put spaces around the + sign?
suthagar23
Jul 23, 2018
Author
Member
changed
changed
HttpServletRequest request, UiUtils uu) throws IOException { | ||
|
||
Errors errors = new BeanPropertyBindingResult(account, "account"); | ||
|
||
List<Extension> customUserFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountUserFragments"); |
dkayiwa
Jul 23, 2018
•
Member
Do you have any reason for making createUser.manageAccountUserFragments plural?
The same applies for the rest downwards.
Do you have any reason for making createUser.manageAccountUserFragments plural?
The same applies for the rest downwards.
suthagar23
Jul 23, 2018
Author
Member
No need, better to change it to "createUser.manageAccountUserFragment"
No need, better to change it to "createUser.manageAccountUserFragment"
log.warn("Multiple userProperty for a single user type not supported, ignoring extra values"); | ||
} | ||
String parameterValue = parameterValues[0]; | ||
if (userPropertyName !=null && parameterValue != null) { |
dkayiwa
Jul 23, 2018
Member
Can we also put space around the above !=
Can we also put space around the above !=
suthagar23
Jul 23, 2018
Author
Member
changed
changed
@@ -203,7 +254,21 @@ public void setModelAttributes(PageModel model, Account account, OtherAccountDat | |||
model.addAttribute("allowedLocales", administrationService.getAllowedLocales()); | |||
List<ProviderRole> providerRoles = providerManagementService.getAllProviderRoles(false); | |||
model.addAttribute("providerRoles", providerRoles); | |||
|
|||
|
|||
List<Extension> customPersonFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountPersonFragments"); |
dkayiwa
Jul 23, 2018
Member
Since the other one has "View" shouldn't this have "Edit"?
Since the other one has "View" shouldn't this have "Edit"?
|
||
|
||
List<Extension> customPersonFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountPersonFragment"); | ||
Collections.sort(customPersonFragments); |
dkayiwa
Jul 23, 2018
Member
Since the other one one has "View", shouldn't this have "Edit"?
Since the other one one has "View", shouldn't this have "Edit"?
suthagar23
Jul 24, 2018
Author
Member
replaced with "Edit"
replaced with "Edit"
@@ -128,6 +128,16 @@ | |||
ng-model="uuidUserMap['${userUuid}'].userProperties.forcePassword" />${ ui.message("adminui.account.user.forcePasswordChange") } | |||
</p> | |||
|
|||
<% customUserFragments.each { sect -> %> |
dkayiwa
Jul 23, 2018
Member
Since the other one one has "View", shouldn't this have "Edit"?
Since the other one one has "View", shouldn't this have "Edit"?
suthagar23
Jul 24, 2018
Author
Member
replaced with "Edit"
replaced with "Edit"
@@ -38,6 +42,19 @@ | |||
<th valign="top">${ui.message("Person.gender")}</th> | |||
<td valign="top">{{genders[person.gender]}}</td> | |||
</tr> | |||
|
|||
<% customPersonViewFragments.each { sect -> |
dkayiwa
Jul 23, 2018
Member
What does "sect" mean?
What does "sect" mean?
suthagar23
Jul 24, 2018
Author
Member
Updated with "fragment"
Updated with "fragment"
HttpServletRequest request, UiUtils uu) throws IOException { | ||
|
||
Errors errors = new BeanPropertyBindingResult(account, "account"); | ||
|
||
List<Extension> customUserFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountUserFragment"); |
dkayiwa
Jul 24, 2018
Member
I thought this would include "UserProperty" in its name?
I thought this would include "UserProperty" in its name?
suthagar23
Jul 24, 2018
Author
Member
Changed to "customUserPropertyFragments"
Changed to "customUserPropertyFragments"
} | ||
} | ||
|
||
List<Extension> customPersonFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountPersonFragment"); |
dkayiwa
Jul 24, 2018
Member
I thought this would include "PersonAttribute" in its name?
I thought this would include "PersonAttribute" in its name?
suthagar23
Jul 24, 2018
Author
Member
Changed to "customPersonAttributeFragments"
Changed to "customPersonAttributeFragments"
@@ -203,7 +254,21 @@ public void setModelAttributes(PageModel model, Account account, OtherAccountDat | |||
model.addAttribute("allowedLocales", administrationService.getAllowedLocales()); | |||
List<ProviderRole> providerRoles = providerManagementService.getAllProviderRoles(false); | |||
model.addAttribute("providerRoles", providerRoles); | |||
|
|||
|
|||
List<Extension> customPersonEditFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountPersonFragment"); |
dkayiwa
Jul 24, 2018
Member
If this is dealing with strictly person attributes, then it should include "PersonAttribute" in its name.
If this is dealing with strictly person attributes, then it should include "PersonAttribute" in its name.
suthagar23
Jul 24, 2018
Author
Member
Changed
Changed
Collections.sort(customPersonViewFragments); | ||
model.addAttribute("customPersonViewFragments", customPersonViewFragments); | ||
|
||
List<Extension> customUserEditFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountUserFragment"); |
dkayiwa
Jul 24, 2018
Member
If this is dealing with strictly user properties, then it should include "UserProperty" in its name.
If this is dealing with strictly user properties, then it should include "UserProperty" in its name.
suthagar23
Jul 24, 2018
Author
Member
changed
changed
@@ -250,6 +315,12 @@ public void setModelAttributes(PageModel model, Account account, OtherAccountDat | |||
force = (user.getUserId() == null) ? true : account.isSupposedToChangePassword(user); | |||
} | |||
userProperties.put(OpenmrsConstants.USER_PROPERTY_CHANGE_PASSWORD, force); |
dkayiwa
Jul 24, 2018
Member
Same here as above.
Same here as above.
suthagar23
Jul 24, 2018
Author
Member
I think you have mentioned the next line. Changed
I think you have mentioned the next line. Changed
|
||
|
||
so = new SimpleObject(); | ||
for(Extension ext : customPersonEditFragments) { |
dkayiwa
Jul 24, 2018
Member
Same here as above.
Same here as above.
suthagar23
Jul 24, 2018
Author
Member
changed
changed
@@ -38,6 +42,19 @@ | |||
<th valign="top">${ui.message("Person.gender")}</th> | |||
<td valign="top">{{genders[person.gender]}}</td> | |||
</tr> | |||
|
|||
<% customPersonViewFragments.each { fragment -> |
dkayiwa
Jul 24, 2018
Member
Same here as above.
Same here as above.
suthagar23
Jul 24, 2018
Author
Member
changed
changed
@@ -97,6 +114,20 @@ | |||
${ui.message("adminui.field.required")} | |||
</span> | |||
</span> | |||
|
|||
<% customPersonEditFragments.each { fragment -> |
dkayiwa
Jul 24, 2018
Member
Same here as above
Same here as above
suthagar23
Jul 24, 2018
Author
Member
changed
changed
@@ -128,6 +128,16 @@ | |||
ng-model="uuidUserMap['${userUuid}'].userProperties.forcePassword" />${ ui.message("adminui.account.user.forcePasswordChange") } | |||
</p> | |||
|
|||
<% customUserEditFragments.each { fragment -> %> |
dkayiwa
Jul 24, 2018
Member
Same here as above
Same here as above
suthagar23
Jul 24, 2018
Author
Member
changed
changed
@@ -30,6 +31,18 @@ | |||
{{yesOrNo[uuidUserMap['${uuid}'].userProperties.forcePassword]}} | |||
</td> | |||
</tr> | |||
|
|||
<% customUserViewFragments.each { fragment -> %> |
dkayiwa
Jul 24, 2018
Member
Same here as above
Same here as above
suthagar23
Jul 24, 2018
Author
Member
changed
changed
HttpServletRequest request, UiUtils uu) throws IOException { | ||
|
||
Errors errors = new BeanPropertyBindingResult(account, "account"); | ||
|
||
List<Extension> customUserPropertyFragments = appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountUserFragment"); |
dkayiwa
Jul 24, 2018
Member
The extension names also need to reflect these changes.
The extension names also need to reflect these changes.
|
||
|
||
List<Extension> customPersonAttributeEditFragments = | ||
appFrameworkService.getExtensionsForCurrentUser("createUser.manageAccountPersonAttributeFragment"); |
dkayiwa
Jul 24, 2018
Member
Shouldn't the extension name include "Edit"?
Shouldn't the extension name include "Edit"?
} | ||
|
||
/** | ||
* Gets the person attribute for the specified person for the getPersonAttributeTypeByUuid |
dkayiwa
Jul 24, 2018
Member
Does the javadoc have to talk about implementation details? (The actual API method being called)
Does the javadoc have to talk about implementation details? (The actual API method being called)
suthagar23
Jul 24, 2018
Author
Member
Removed
Removed
* Gets the person attribute for the specified person for the getPersonAttributeTypeByUuid | ||
* that matches the specified uuid | ||
* | ||
* @return the attribute |
dkayiwa
Jul 24, 2018
Member
Can you document the above return?
Can you document the above return?
HttpServletRequest request, UiUtils uu) throws IOException { | ||
|
||
Errors errors = new BeanPropertyBindingResult(account, "account"); | ||
|
||
List<Extension> customUserPropertyEditFragments = |
dkayiwa
Jul 24, 2018
Member
Since some times you are not creating a user, but just updating their details, can we use a convention like? userAccount.userPropertyEditFragment
Since some times you are not creating a user, but just updating their details, can we use a convention like? userAccount.userPropertyEditFragment
…ents to the dashboard Minor fix Minor fix PR review fixes PR review fixes PR review fixes PR review fixes PR review fixes PR review fixes PR review fixes PR review fixes PR review fixes
Description
Along with this PR,
Ticket Information
Ticket : https://issues.openmrs.org/browse/RA-1513