-
Notifications
You must be signed in to change notification settings - Fork 4
Pragadeeswar -Test Screen #3
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
Open
prag1989
wants to merge
6
commits into
sshepard:master
Choose a base branch
from
prag1989:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,75 +1,46 @@ | ||
| <!DOCTYPE html> | ||
| <html xmlns:ng="http://angularjs.org"> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
|
||
| <title ng-bind="title"></title> | ||
|
|
||
| <link rel="stylesheet" href="css/bootstrap.css"/> | ||
| <style> | ||
| h1 { color: darkred } | ||
| h1 { weight: bolder } | ||
| h1 { margin: 20px; display: block; opacity: 80%; } | ||
| h1:hover { opacity:1; } | ||
| </style> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
|
||
| <title ng-bind="title"></title> | ||
|
|
||
| <link rel="stylesheet" href="css/bootstrap.css" /> | ||
|
|
||
| <style> | ||
| h1 { | ||
| color: darkred | ||
| } | ||
| h1 { | ||
| weight: bolder | ||
| } | ||
| h1 { | ||
| margin: 20px; | ||
| display: block; | ||
| opacity: 80%; | ||
| } | ||
| h1:hover { | ||
| opacity: 1; | ||
| } | ||
| </style> | ||
|
|
||
| <!--[if lte IE 7]> | ||
| <!--[if lte IE 7]> | ||
| <script src="js/vendor/json3.js"></script> | ||
| <![endif]--> | ||
|
|
||
| <script src="js/vendor/angular.min.js"></script> | ||
| <script src="js/vendor/angular-route.min.js"></script> | ||
| <script src="js/app.js"></script> | ||
| </head> | ||
| <body> | ||
| <div class="container"> | ||
| <div class="row"> | ||
| <h1>The User Interface Developer Test</h1> | ||
| </div> | ||
| <div class="well"> | ||
| <div class="well"> | ||
| <ul> | ||
| <li>This Page and results.html should be converted to AngularJS templates.</li> | ||
| <li>Add a select-all toggle for the checkbox list.</li> | ||
| <li>Select-all should be checked if all fields are checked, unchecked if all fields are unchecked and indeterminate if some are checked.</li> | ||
| <li>Sor the checkboxes by name</l> | ||
| <li>When submitting the form, if only "Language" is checked, then an error should appear stating " Please choose more items! "</li> | ||
| <li>Successfully submitting the form takes us to results.html and shows what the user submitted.</li> | ||
| <li>Maybe the page can look a little better?</li> | ||
| <p>Read the README.md</p> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| <form role="form"> | ||
| <div class="form-group"> | ||
| <input type="checkbox">Select All | ||
| </div> | ||
| <div class="form-group"> | ||
| <label class="checkbox"> | ||
| <input type="checkbox" name="fields" value="Abstract">Abstract | ||
| </label> | ||
| <label class="checkbox"> | ||
| <input type="checkbox" name="fields" value="Abstract">Publication | ||
| </label> | ||
| <label class="checkbox"> | ||
| <input type="checkbox" value="Abstract">Inventor | ||
| </label> | ||
| <label class="checkbox"> | ||
| <input type="checkbox" name="fields" value="Abstract">Language | ||
| </label> | ||
| <label class="checkbox"> | ||
| <input type="checkbox" name="field" value="Abstract">Source | ||
| </label> | ||
| <label class="checkbox"> | ||
| <input type="checkbox" name="fields" value="Abstract">Priority | ||
| </label> | ||
|
|
||
| </div> | ||
| <button type="submit" class="btn btn-default">Submit</button> | ||
| </form> | ||
| <script>console.log('page loaded');</script> | ||
| </head> | ||
|
|
||
| <body ng-app="TestMe"> | ||
| <div class="container"> | ||
| <div ng-view></div> | ||
| </div> | ||
| <script src="js/vendor/angular.min.js"></script> | ||
| <script src="js/vendor/angular-route.min.js"></script> | ||
| <script src="js/app.js"></script> | ||
| </body> | ||
| </html> | ||
|
|
||
| </html> |
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,113 @@ | ||
| angular.module('TestMe', []); | ||
| angular.module('TestMe', ['ngTest.cbSelector', 'ngTest.results', 'ngRoute']) | ||
| .config(['$routeProvider', | ||
| function($routeProvider) { | ||
| $routeProvider. | ||
| when('/', { | ||
| templateUrl: '/testForm.html', | ||
| controller: 'CheckBoxController' | ||
| }). | ||
| when('/results', { | ||
| templateUrl: '/results.html', | ||
| controller: 'ResultsController' | ||
| }). | ||
| otherwise({ | ||
| redirectTo: '/' | ||
| }); | ||
| } | ||
| ]); | ||
|
|
||
| angular.module('ngTest.cbSelector', []) | ||
| .controller('CheckBoxController', ['$scope', '$rootScope','$location', function($scope, $rootScope, $location){ | ||
| $scope.cbSelectedByVal = { | ||
| abstract: false, | ||
| publication: false, | ||
| inventor: false, | ||
| language: false, | ||
| source: false, | ||
| priority: false | ||
| }; | ||
| $scope.cbSelectAll = false; | ||
|
|
||
| $scope.getKeys = function(Obj,order){ | ||
| return Object.keys(Obj).sort(); //ensures that checkboxes are sorted by name. | ||
| } | ||
|
|
||
| //checks for the indeterminate condition. | ||
| var checkIndeterminate = function(selectObject){ | ||
| var keys = $scope.getKeys(selectObject); | ||
| var counter = 0; max_limit = keys.length, t = true; | ||
| var elm = document.getElementById('selectAllChkBox'); | ||
| keys.forEach(function(el, i){ | ||
| t = t && selectObject[el]; | ||
| if(selectObject[el]){counter++;} | ||
| }); | ||
| if(counter<max_limit && counter!==0){ | ||
| if(elm!==null){ | ||
| elm.indeterminate = true; | ||
| } | ||
| } | ||
| else{ | ||
| elm.indeterminate = false; | ||
| } | ||
| }; | ||
|
|
||
| $scope.testSelectAll = function(){ | ||
| var isAllSelected = true; | ||
| for(var key in $scope.cbSelectedByVal){ | ||
| if($scope.cbSelectedByVal.hasOwnProperty(key)){ | ||
| if($scope.cbSelectedByVal[key] == false){ | ||
| isAllSelected = false; | ||
| } | ||
| } | ||
| } | ||
| if(isAllSelected){ | ||
| $scope.cbSelectAll = true; | ||
| }else{ | ||
| $scope.cbSelectAll = false; | ||
| } | ||
| checkIndeterminate($scope.cbSelectedByVal); | ||
|
|
||
| }; | ||
|
|
||
| $scope.selectAllCheckBoxes = function(){ | ||
| if($scope.cbSelectAll){ | ||
| for(var key in $scope.cbSelectedByVal){ | ||
| if($scope.cbSelectedByVal.hasOwnProperty(key)){ | ||
| $scope.cbSelectedByVal[key] = true; | ||
| } | ||
| } | ||
| }else{ | ||
| $scope.testSelectAll(); | ||
| } | ||
| }; | ||
|
|
||
| $scope.submit = function(){ | ||
| var selectedItems = []; | ||
| for(var key in $scope.cbSelectedByVal){ | ||
| if($scope.cbSelectedByVal.hasOwnProperty(key)){ | ||
| if($scope.cbSelectedByVal[key] == true){ | ||
| selectedItems.push(key); | ||
| } | ||
| } | ||
| } | ||
| if(selectedItems && selectedItems.length==1 && selectedItems.indexOf("language")!= -1){ | ||
| alert('Please select more items!'); | ||
| }else{ | ||
| $rootScope.selectedItems = selectedItems; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extraneous console.log() statements need to be removed. |
||
| $location.url('/results'); //prevents page change when only language is selected. | ||
| } | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| }]); | ||
|
|
||
|
|
||
|
|
||
| angular.module('ngTest.results', []) | ||
| .controller('ResultsController', ['$scope', '$rootScope', function($scope, $rootScope){ | ||
| $scope.results = []; | ||
| if($rootScope.selectedItems){ | ||
| $scope.results = $rootScope.selectedItems; | ||
| } | ||
| }]); | ||
This file contains hidden or 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 hidden or 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,34 @@ | ||
| <div ng-controller="CheckBoxController"> | ||
| <div class="row"> | ||
| <h1>The User Interface Developer Test</h1> | ||
| </div> | ||
| <div class="well"> | ||
| <ul> | ||
| <li>This Page and results.html should be converted to AngularJS templates.</li> | ||
| <li>Add a select-all toggle for the checkbox list.</li> | ||
| <li>Select-all should be checked if all fields are checked, unchecked if all fields are unchecked and indeterminate if some are checked.</li> | ||
| <li>Sor the checkboxes by name</li> | ||
| <li>When submitting the form, if only "Language" is checked, then an error should appear stating " Please choose more items! "</li> | ||
| <li>Successfully submitting the form takes us to results.html and shows what the user submitted.</li> | ||
| <li>Maybe the page can look a little better?</li> | ||
| <p>Read the README.md</p> | ||
| </ul> | ||
| </div> | ||
| <form role="form" ng-submit="submit()"> | ||
| <div class="form-group"> | ||
| <input type="checkbox" ng-model="cbSelectAll" ng-change="selectAllCheckBoxes()" id="selectAllChkBox">Select All | ||
| </div> | ||
| <div class="form-group col-md-6"> | ||
| <div ng-repeat-start="item in getKeys(cbSelectedByVal)| orderBy:item"> | ||
| <input type="checkbox" name="fields" value="{{item}}" ng-model="cbSelectedByVal[item]" ng-change="testSelectAll()"> | ||
| <label> | ||
| {{item}} | ||
| </label> | ||
| </div> | ||
| <div ng-repeat-end></div> | ||
| <button type="submit" class="btn btn-primary" ng-click="submit()">Submit</button> | ||
| </div> | ||
| </form> | ||
| <script> | ||
| </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.
use === to specifically test the boolean true. Otherwise, "if ($scope.cbSelectedByVal[key])" is sufficient for testing if the value is "truthy"