-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PR - 1 - Fix bootstrap style issues - Refactor filter style - Reorganize some styles files - Update StudentsIndexCtrl to use $routeParams to grab filter's values Removed students _index.scss
- Loading branch information
1 parent
ef09424
commit a925c47
Showing
12 changed files
with
338 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
define(['paw'], function(paw) { | ||
paw.controller('StudentsIndexCtrl', ['$routeParams', function($routeParams) { | ||
var _this = this; | ||
this.filter = { | ||
docket: $routeParams.docket, | ||
firstName: $routeParams.firstName, | ||
lastName: $routeParams.lastName | ||
}; | ||
|
||
this.resetSearch = function() { | ||
this.filter = {}; | ||
}; | ||
|
||
this.students = [ | ||
{ | ||
firstName: 'Matías', | ||
lastName: 'Mercado', | ||
docket: '55019' | ||
}, | ||
{ | ||
firstName: 'Facundo', | ||
lastName: 'Mercado', | ||
docket: '51202' | ||
}, | ||
{ | ||
firstName: 'Gibar', | ||
lastName: 'Sin', | ||
docket: '54655' | ||
}, | ||
{ | ||
firstName: 'Obi Wan', | ||
lastName: 'Kenobi', | ||
docket: '12000' | ||
}, | ||
{ | ||
firstName: 'Darth', | ||
lastName: 'Vader', | ||
docket: '66666' | ||
}, | ||
{ | ||
firstName: 'Luke', | ||
lastName: 'Skywalker', | ||
docket: '53222' | ||
}]; | ||
}]); | ||
}); |
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
File renamed without changes.
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,103 @@ | ||
// disable max-nested-callbacks linter for this test | ||
// it is good to have a good separation of contexts inside tests | ||
|
||
/* eslint-disable max-nested-callbacks */ | ||
|
||
'use strict'; | ||
|
||
define(['paw', | ||
'angular-mocks', | ||
'controllers/StudentsIndexCtrl'], | ||
function() { | ||
describe('Students Index Ctrl', function() { | ||
beforeEach(module('paw')); | ||
|
||
// Hardcoded data until Service call is tested | ||
var expectedStudents = [ | ||
{ | ||
firstName: 'Matías', | ||
lastName: 'Mercado', | ||
docket: '55019' | ||
}, | ||
{ | ||
firstName: 'Facundo', | ||
lastName: 'Mercado', | ||
docket: '51202' | ||
}, | ||
{ | ||
firstName: 'Gibar', | ||
lastName: 'Sin', | ||
docket: '54655' | ||
}, | ||
{ | ||
firstName: 'Obi Wan', | ||
lastName: 'Kenobi', | ||
docket: '12000' | ||
}, | ||
{ | ||
firstName: 'Darth', | ||
lastName: 'Vader', | ||
docket: '66666' | ||
}, | ||
{ | ||
firstName: 'Luke', | ||
lastName: 'Skywalker', | ||
docket: '53222' | ||
}]; | ||
|
||
var $controller, $rootScope, controller; | ||
|
||
var expectedParams = { | ||
docket: 123, | ||
firstName: 'Hello', | ||
lastName: 'Test' | ||
}; | ||
|
||
beforeEach(inject( | ||
function(_$controller_, _$rootScope_) { | ||
$controller = _$controller_; | ||
$rootScope = _$rootScope_; | ||
controller = $controller('StudentsIndexCtrl', {$routeParams: expectedParams}); | ||
})); | ||
|
||
it('correctly fetch the students', function() { | ||
expect(controller.students).toEqual(expectedStudents); | ||
}); | ||
|
||
describe('when initializing the filter values', function() { | ||
it('correctly fetch the docket', function() { | ||
expect(controller.filter.docket).toEqual(expectedParams.docket); | ||
}); | ||
|
||
it('correctly fetch the first name', function() { | ||
expect(controller.filter.firstName).toEqual(expectedParams.firstName); | ||
}); | ||
|
||
it('correctly fetch the last name', function() { | ||
expect(controller.filter.lastName).toEqual(expectedParams.lastName); | ||
}); | ||
}); | ||
|
||
describe('when reset button is clicked', function() { | ||
beforeEach(function() { | ||
controller.filter = {}; | ||
controller.filter.docket = 12345; | ||
controller.filter.firstName = 'John'; | ||
controller.filter.lastName = 'Doe'; | ||
controller.resetSearch(); | ||
}); | ||
|
||
it('clears the docket search input', function() { | ||
expect(controller.filter).toEqual({}); | ||
}); | ||
|
||
it('clears the firstName search input', function() { | ||
expect(controller.filter).toEqual({}); | ||
}); | ||
|
||
it('clears the lastName search input', function() { | ||
expect(controller.filter).toEqual({}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,63 @@ | ||
.filter-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
padding: 15px; | ||
|
||
.filter-fields { | ||
width: 100%; | ||
|
||
.own-input-group { | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
|
||
.search-label { | ||
flex: 2; | ||
min-width: 80px; | ||
max-width: 120px; | ||
width: 100%; | ||
font-weight: 700; | ||
height: 35px; | ||
line-height: 35px; | ||
text-align: center; | ||
border: 1px solid $silver; | ||
} | ||
|
||
.form-input-field { | ||
flex: 8; | ||
display: block; | ||
min-width: 100px; | ||
max-width: 500px; | ||
width: 100%; | ||
height: 35px; | ||
padding: 6px 12px; | ||
background-color: $white; | ||
background-image: none; | ||
border: 1px solid $silver; | ||
border-radius: 0; | ||
transition: border-color ease-in-out 0.15s; | ||
|
||
&:focus { | ||
border-color: $mine-shaft; | ||
outline: none; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.filter-buttons { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
padding: 15px; | ||
|
||
.btn { | ||
min-width: 150px; | ||
margin: 0 15px; | ||
} | ||
} | ||
} |
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,22 @@ | ||
.table { | ||
> tbody, | ||
> tfoot, | ||
> thead { | ||
> tr { | ||
> th, | ||
> td { | ||
border-bottom: none; | ||
vertical-align: middle; | ||
} | ||
} | ||
} | ||
|
||
.actions-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
|
||
.btn { | ||
flex: 1; | ||
} | ||
} | ||
} |
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,71 @@ | ||
<div ng-controller='StudentsIndexCtrl as controller'> | ||
<div class='students-index-container'> | ||
<!-- Page Heading --> | ||
<div class='row'> | ||
<div class='col-xs-12'> | ||
<h1 translate='i18nStudentsPanelSection' class='page-header'></h1> | ||
</div> | ||
</div> | ||
<!-- /Page Heading --> | ||
|
||
<!-- Filter --> | ||
<div class='filter-container'> | ||
<div class='filter-fields'> | ||
<div class='own-input-group'> | ||
<span class='search-label' translate=i18Docket></span> | ||
<input type='text' class='form-input-field' ng-model='controller.filter.docket' placeholder="{{ 'i18Docket' | translate }}..."/> | ||
</div> | ||
<div class='own-input-group'> | ||
<span class='search-label' translate='i18nFirstName'></span> | ||
<input type='text' class='form-input-field' ng-model='controller.filter.firstName' placeholder="{{ 'i18nFirstName' | translate }}..."/> | ||
</div> | ||
<div class='own-input-group'> | ||
<span class='search-label' translate='i18nLastName'></span> | ||
<input type='text' class='form-input-field' ng-model='controller.filter.lastName' placeholder="{{ 'i18nLastName' | translate }}..."/> | ||
</div> | ||
</div> | ||
<div class='filter-buttons'> | ||
<button class='btn btn-default' type='submit'> | ||
<span class='fa fa-search' aria-hidden='true'></span> | ||
<span translate='i18SearchButton' translate ></span> | ||
</button> | ||
<button class='btn btn-default' ng-click='controller.resetSearch()' type='submit'> | ||
<span class='fa fa-repeat' aria-hidden='true'></span> | ||
<span translate='i18ResetButton'></span> | ||
</button> | ||
</div> | ||
</div> | ||
<!-- /Filter --> | ||
|
||
<!-- Students --> | ||
<div class='table-responsive'> | ||
<table class='table table-hover'> | ||
<thead> | ||
<tr> | ||
<th translate='i18Docket'></th> | ||
<th translate='i18nFirstName'></th> | ||
<th translate='i18nLastName'></th> | ||
<th translate='i18Actions'></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-hide='controller.students.length > 0' class='bg-warning'> | ||
<td colspan='4' class='text-danger text-center' translate='i18NoStudentsFound'></td> | ||
</tr> | ||
<tr ng-repeat='student in controller.students'> | ||
<td>{{ student.docket }}</td> | ||
<td>{{ student.firstName }}</td> | ||
<td>{{ student.lastName }}</td> | ||
<td class='actions-container'> | ||
<a class='btn btn-default fullWidthButton' role='button'> | ||
<span class='fa fa-user' aria-hidden='true'></span> | ||
<span translate='i18nStudentShow'></span> | ||
</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<!-- /Students --> | ||
</div> | ||
</div> |