Fixed #2904 - Recreated from another in-active PR (#3301)

* Fixed #2904 - Recreated from another in-active PR


- https://github.com/openMF/community-app/pull/2905
- Had merge conflicts and branch is inactive
- Tested the scenarios

* Fixed #2904 - Fixed the existing test
This commit is contained in:
Alex Anto Navis L 2020-08-25 22:51:03 +05:30 committed by GitHub
parent 617c0b6502
commit 6bc5426e08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 25 deletions

View File

@ -14,6 +14,17 @@
scope.isRoleEnable = function(value) {
return value;
};
if (!scope.searchCriteria.rolesFilterText) {
scope.searchCriteria.rolesFilterText = null;
scope.saveSC();
}
scope.filterText = scope.searchCriteria.rolesFilterText || '';
scope.onFilter = function () {
scope.searchCriteria.rolesFilterText = scope.filterText;
scope.saveSC();
};
}
});
mifosX.ng.application.controller('RoleController', ['$scope', 'ResourceFactory', '$location', mifosX.controllers.RoleController]).run(function ($log) {

View File

@ -3,31 +3,39 @@
<li><a href="#/system">{{'label.anchor.system' | translate}}</a></li>
<li class="active">{{'label.anchor.viewroles' | translate}}</li>
</ul>
<div class="pull-right">
<a href="#/admin/addrole" class="btn btn-primary" has-permission='CREATE_ROLE'><i class="fa fa-plus "></i>&nbsp;&nbsp;{{'label.button.addrole' |
translate}}</a>
</div>
<div class="card" data-ng-controller="RoleController">
<br>
<table class="table">
<thead>
<tr class="graybg">
<th>{{'label.heading.name' | translate}}</th>
<th>{{'label.heading.description' | translate}}</th>
<th>{{'label.heading.status' | translate}}</th>
</tr>
</thead>
<tbody>
<tr class="pointer-main" dir-paginate="role in roles | orderBy:'name':reverse | filter:filterText | itemsPerPage: RolesPerPage">
<td class="pointer" data-ng-click="routeTo(role.id)">{{role.name}}</td>
<td class="pointer" data-ng-click="routeTo(role.id)">{{role.description}}</td>
<td class="pointer" data-ng-click="routeTo(role.id)">
<div ng-if="!isRoleEnable(role.disabled)">{{'label.heading.enabledrole' | translate }}</div>
<div ng-if="isRoleEnable(role.disabled)">{{'label.heading.disabled' | translate }}</div>
</td>
</tr>
</tbody>
</table>
<div class="content">
<div class="toolbar"></div>
<br>
<div class="row">
<div class="col-md-6">
<input ng-autofocus="true" ng-model="filterText" type="text" ng-keyup="onFilter()" class="form-control" placeholder="{{'label.input.filterbyname' | translate}}">
</div>
<div class="col-md-6">
<a href="#/admin/addrole" class="btn btn-primary pull-right" has-permission='CREATE_ROLE'><i class="fa fa-plus "></i> {{'label.button.addrole' | translate}}</a>
</div>
</div>
<hr/>
<table class="table">
<thead>
<tr class="graybg">
<th>{{'label.heading.name' | translate}}</th>
<th>{{'label.heading.description' | translate}}</th>
<th>{{'label.heading.status' | translate}}</th>
</tr>
</thead>
<tbody>
<tr class="pointer-main" dir-paginate="role in roles | orderBy:'name':reverse | filter:filterText | itemsPerPage: RolesPerPage">
<td class="pointer" data-ng-click="routeTo(role.id)">{{role.name}}</td>
<td class="pointer" data-ng-click="routeTo(role.id)">{{role.description}}</td>
<td class="pointer" data-ng-click="routeTo(role.id)">
<div ng-if="!isRoleEnable(role.disabled)">{{'label.heading.enabledrole' | translate }}</div>
<div ng-if="isRoleEnable(role.disabled)">{{'label.heading.disabled' | translate }}</div>
</td>
</tr>
</tbody>
</table>
</div>
<dir-pagination-controls boundary-links="true" template-url="bower_components/angular-utils-pagination/dirPagination.tpl.html"></dir-pagination-controls>
</div>
</div>

View File

@ -2,7 +2,9 @@ describe("RoleController", function () {
var resourceCallback;
beforeEach(function () {
this.scope = {};
this.scope = jasmine.createSpyObj("$scope", ['saveSC']);
this.scope.searchCriteria = {}
this.resourceFactory = { roleResource: {
getAllRoles: jasmine.createSpy('roleResource.getAllRoles()').andCallFake(function (params, callback) {
resourceCallback = callback;