New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: fix #1820, Added Create Self-Service User Form #2139
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
app/scripts/controllers/selfservice/CreateSelfServiceUserController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
(function (module) { | ||
mifosX.controllers = _.extend(module, { | ||
CreateSelfServiceUserController: function (scope, resourceFactory, routeParams,$uibModal) { | ||
// TODO: Add Account Is Active Logic through email validation | ||
scope.accountActive = false; | ||
scope.available = []; | ||
scope.selected = []; | ||
scope.selectedRoles = [] ; | ||
scope.availableRoles = []; | ||
scope.formData = { | ||
isSelfServiceUser: true, | ||
sendPasswordToEmail: true, | ||
roles: [] | ||
}; | ||
scope.clientId = routeParams.clientId; | ||
resourceFactory.userTemplateResource.get(function (data) { | ||
scope.availableRoles = data.availableRoles; | ||
}); | ||
resourceFactory.clientResource.get({clientId: scope.clientId},function(data){ | ||
scope.formData.firstname = data.firstname; | ||
scope.formData.lastname = data.lastname; | ||
scope.formData.email = ''; | ||
scope.formData.officeId = data.officeId; | ||
scope.formData.staffId = data.staffId; | ||
scope.formData.clients = [scope.clientId]; | ||
}); | ||
|
||
scope.addRole = function () { | ||
for (var i in this.available) { | ||
for (var j in scope.availableRoles) { | ||
if (scope.availableRoles[j].id == this.available[i]) { | ||
var temp = {}; | ||
temp.id = this.available[i]; | ||
temp.name = scope.availableRoles[j].name; | ||
scope.selectedRoles.push(temp); | ||
scope.availableRoles.splice(j, 1); | ||
} | ||
} | ||
} | ||
//We need to remove selected items outside of above loop. If we don't remove, we can see empty item appearing | ||
//If we remove available items in above loop, all items will not be moved to selectedRoles | ||
for (var i in this.available) { | ||
for (var j in scope.selectedRoles) { | ||
if (scope.selectedRoles[j].id == this.available[i]) { | ||
scope.available.splice(i, 1); | ||
} | ||
} | ||
} | ||
}; | ||
scope.removeRole = function () { | ||
for (var i in this.selected) { | ||
for (var j in scope.selectedRoles) { | ||
if (scope.selectedRoles[j].id == this.selected[i]) { | ||
var temp = {}; | ||
temp.id = this.selected[i]; | ||
temp.name = scope.selectedRoles[j].name; | ||
scope.availableRoles.push(temp); | ||
scope.selectedRoles.splice(j, 1); | ||
} | ||
} | ||
} | ||
//We need to remove selected items outside of above loop. If we don't remove, we can see empty item appearing | ||
//If we remove selected items in above loop, all items will not be moved to availableRoles | ||
for (var i in this.selected) { | ||
for (var j in scope.availableRoles) { | ||
if (scope.availableRoles[j].id == this.selected[i]) { | ||
scope.selected.splice(i, 1); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
scope.submit = function(){ | ||
for (var i in scope.selectedRoles) { | ||
scope.formData.roles.push(scope.selectedRoles[i].id) ; | ||
} | ||
resourceFactory.userListResource.save(this.formData, function (data) { | ||
scope.accountActive = true; | ||
$uibModal.open({ | ||
templateUrl: 'selfserviceModal.html', | ||
controller: SuccessModalCtrl, | ||
}); | ||
}); | ||
|
||
} | ||
|
||
var SuccessModalCtrl = function ($scope, $uibModalInstance) { | ||
$scope.cancel = function () { | ||
$uibModalInstance.dismiss('cancel'); | ||
}; | ||
}; | ||
|
||
} | ||
}); | ||
mifosX.ng.application.controller('CreateSelfServiceUserController', ['$scope', 'ResourceFactory', '$routeParams','$uibModal', mifosX.controllers.CreateSelfServiceUserController]).run(function ($log) { | ||
$log.info("CreateSelfServiceUserController initialized"); | ||
}); | ||
}(mifosX.controllers || {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<div class="content-container" ng-controller="CreateSelfServiceUserController"> | ||
<ul class="breadcrumb"> | ||
<li><a href="#/viewclient/{{clientId}}">{{formData.firstname}} {{formData.lastname}}</a></li> | ||
<li class="active">{{'label.createselfserviceuser' | translate}}</li> | ||
</ul> | ||
<div class="card"> | ||
<form name="createselfserviceuserform" novalidate="" class="card form-horizontal well" rc-submit="submit()"> | ||
<legend>{{'label.createselfserviceuser' | translate}}</legend> | ||
<api-validate></api-validate> | ||
<fieldset> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2" for="username">{{'label.input.username' | translate}}<span | ||
class="required">*</span></label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="text" id="username" name="username" ng-model="formData.username" class="form-control" required late-Validate/> | ||
</div> | ||
<div class="col-sm-3"> | ||
<form-validate valattributeform="createuserform" valattribute="username"/> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2" for="firstname">{{'label.input.firstname' | translate}}<span | ||
class="required">*</span></label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="text" id="firstname" name="firstname" ng-model="formData.firstname" class="form-control" required | ||
late-Validate ng-disabled="true"/> | ||
</div> | ||
<div class="col-sm-3"> | ||
<form-validate valattributeform="createselfserviceuserform" valattribute="firstname"/> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2" for="lastname">{{'label.input.lastname' | translate}}<span | ||
class="required">*</span></label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="text" id="lastname" name="lastname" ng-model="formData.lastname" class="form-control" required late-Validate ng-disabled="true"/> | ||
</div> | ||
<div class="col-sm-3"> | ||
<form-validate valattributeform="createselfserviceuserform" valattribute="lastname"/> | ||
</div> | ||
</div> | ||
<div data-ng-switch on="formData.sendPasswordToEmail"> | ||
<div data-ng-switch-when="true"> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2" for="email">{{'label.input.email' | translate}}<span | ||
class="required">*</span></label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="email" id="email" name="email" class="form-control" ng-model="formData.email" required late-Validate/> | ||
</div> | ||
<div class="col-sm-3"> | ||
<form-validate valattributeform="createselfserviceuserform" valattribute="email"/> | ||
</div> | ||
</div> | ||
</div> | ||
<div data-ng-switch-when="false"> | ||
<div class="form-group" data-ng-show="!formData.sendPasswordToEmail"> | ||
<label class="control-label col-sm-2" for="email1">{{'label.input.email' | translate}}</label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="email" id="email1" name="email1" class="form-control" ng-model="formData.email"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2">{{'label.input.autogeneratepassword' | translate}}</label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="checkbox" ng-model="formData.sendPasswordToEmail"> | ||
</div> | ||
|
||
<label class="control-label col-sm-3">{{'label.input.overridepasswordexpiry' | translate}} | ||
<i class="fa fa-question-circle control-label fa fa-align-left" | ||
uib-tooltip="{{'label.tooltip.overridepasswordexpiry' | translate}}"></i></label> | ||
<div class="col-sm-3"> | ||
<label class="checkbox"> | ||
<input type="checkbox" ng-model="formData.passwordNeverExpires"> | ||
</label> | ||
</div> | ||
</div> | ||
<div data-ng-switch on="formData.sendPasswordToEmail"> | ||
<div data-ng-switch-when="false"> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2" for="password">{{'label.input.password' | translate}}<span | ||
class="required">*</span></label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="password" id="password" name="password" ng-model="formData.password" class="form-control" required | ||
late-Validate> | ||
</div> | ||
<div class="col-sm-3"> | ||
<form-validate valattributeform="createselfserviceuserform" valattribute="password"/> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2" for="repeatPassword">{{'label.input.repeatpassword' | translate}}<span | ||
class="required">*</span></label> | ||
|
||
<div class="col-sm-3"> | ||
<input type="password" id="repeatPassword" name="repeatPassword" class="form-control" | ||
ng-model="formData.repeatPassword" required late-Validate> | ||
</div> | ||
<div class="col-sm-3"> | ||
<form-validate valattributeform="createselfserviceuserform" valattribute="repeatPassword"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-3 col-md-3 col-md-offset-1"> | ||
<label class="control-label col-sm-9">{{ 'label.input.availableroles' | translate }}</label> | ||
<select id="availableroles" ng-model="available" name="availableroles" class="form-control multiselectmin" multiple> | ||
<option ng-repeat="availablerole in availableRoles" value="{{availablerole.id}}"> | ||
{{availablerole.name}} | ||
</option> | ||
</select> | ||
</div> | ||
<div class="col-sm-1 col-md-1 paddedtop25px"> | ||
<button type="button" class="btn btn-primary" data-ng-click="addRole()"><i | ||
class="fa fa-angle-double-right"></i></button> | ||
<br/> | ||
<button type="button" class="btn btn-primary" data-ng-click="removeRole()"><i | ||
class="fa fa-angle-double-left"></i></button> | ||
</div> | ||
<div class="col-sm-3 col-md-3"> | ||
<label class="control-label col-sm-9">{{ 'label.input.selectedroles' | translate}}<span | ||
class="required">*</span></label> | ||
<select id="roles" name="roles" ng-model="selected" name="role" class="form-control multiselectmin" multiple> | ||
<option ng-repeat="availablerole in selectedRoles" value="{{availablerole.id}}"> | ||
{{availablerole.name}} | ||
</option> | ||
</select> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label class="control-label col-sm-2">{{'label.input.status' | translate}}</label> | ||
<div class="col-sm-3"> | ||
{{ (accountActive ? 'label.tooltip.loanProduct.active' : 'label.tooltip.loanProduct.inActive') | translate }} | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-3 col-sm-offset-2"> | ||
<input type="submit" value="{{'label.button.activateselfservice' | translate }}" ng-disabled="accountActive" ng-class="accountActive ? 'btn btn-md btn-disabled' : 'btn btn-md btn-primary' "/> | ||
</div> | ||
<div class="col-sm-2"> | ||
<a uib-tooltip="{{'label.button.selfserviceactivatehelp' | translate}}" class="ng-binding"> | ||
<i class="fa fa-question-circle fa-2x"></i> | ||
</a> | ||
</div> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> | ||
<script type="text/ng-template" id="selfserviceModal.html"> | ||
<div class="modal-header silver"> | ||
<h3 class="bolder text-success"><i class="fa fa-check-circle"></i> {{'label.heading.selfserivceaccountactivated' | translate}}</h3> | ||
</div> | ||
<div class="modal-body"> | ||
<p>{{'label.createdselfserviceuser' | translate}}</p> | ||
</div> | ||
<div class="modal-footer"> | ||
<button class="btn btn-default" ng-click="cancel()">{{'label.button.close' | translate}}</button> | ||
</div> | ||
</script> | ||
</div> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to retrieve all roles? For example 'Super User' is not applicable in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nazeer1100126 Yes I did have doubts on this, What roles are the valid role for creation of the self-service user?
How do I fetch roles specific for creating the self-service user?
Can we update the template on the backend for normal user creation and a self-service user creation with appropriate roles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we need to have a separate API to retrieve only self service user roles so that we can filter out other roles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that would be great. I'll wait for self service template for available roles to be created. Thanks @nazeer1100126!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@botraunak Can you try adding this API from platform side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nazeer1100126 I'm sorry I didn't get that? Could you explain a bit more?