From 3786f73c5def513556e3b6d67b8bfa33a168e8a4 Mon Sep 17 00:00:00 2001 From: prag1989 Date: Fri, 12 Dec 2014 10:25:33 -0600 Subject: [PATCH 1/6] Module for List and Result page --- js/app.js | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index e81250d..26424a2 100644 --- a/js/app.js +++ b/js/app.js @@ -1 +1,88 @@ -angular.module('TestMe', []); \ No newline at end of file +angular.module('TestMe', ['ngTest.cbSelector', 'ngTest.results', 'ngRoute']) +.config(['$routeProvider', + function($routeProvider) { + $routeProvider. + when('/', { + templateUrl: '/TestMe_NG-master/testForm.html', + controller: 'CheckBoxController' + }). + when('/results', { + templateUrl: '/TestMe_NG-master/results.html', + controller: 'ResultsController' + }). + otherwise({ + redirectTo: '/' + }); + } +]); + +angular.module('ngTest.cbSelector', []) +.controller('CheckBoxController', ['$scope', '$rootScope', function($scope, $rootScope){ + $scope.cbSelectedByVal = { + abstract: false, + publication: false, + inventor: false, + language: false, + source: false, + priority: false + }; + $scope.cbSelectAll = 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; + } + }; + + $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(){ + //debugger; + 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!') + return false; + }else{ + console.log('Submitting...') + $rootScope.selectedItems = selectedItems; + } + }; +}]); + +angular.module('ngTest.results', []) +.controller('ResultsController', ['$scope', '$rootScope', function($scope, $rootScope){ + console.log('Results'); + $scope.results = []; + //debugger; + if($rootScope.selectedItems){ + //debugger; + $scope.results = $rootScope.selectedItems; + } +}]); From 95de4b2f3103889b219009bbee81e894350d9e0e Mon Sep 17 00:00:00 2001 From: prag1989 Date: Fri, 12 Dec 2014 10:26:57 -0600 Subject: [PATCH 2/6] Update index.html --- index.html | 51 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/index.html b/index.html index 6f5c271..32d1201 100644 --- a/index.html +++ b/index.html @@ -23,53 +23,10 @@ - +
-
-

The User Interface Developer Test

-
-
-
-
    -
  • This Page and results.html should be converted to AngularJS templates.
  • -
  • Add a select-all toggle for the checkbox list.
  • -
  • Select-all should be checked if all fields are checked, unchecked if all fields are unchecked and indeterminate if some are checked.
  • -
  • Sor the checkboxes by name -
  • When submitting the form, if only "Language" is checked, then an error should appear stating " Please choose more items! "
  • -
  • Successfully submitting the form takes us to results.html and shows what the user submitted.
  • -
  • Maybe the page can look a little better?
  • -

    Read the README.md

    -
-
-
-
-
- Select All -
-
- - - - - - - -
- -
- +
+
- \ No newline at end of file + From 53778868f4807101148ed27e089810d05e6aaa79 Mon Sep 17 00:00:00 2001 From: prag1989 Date: Fri, 12 Dec 2014 10:27:43 -0600 Subject: [PATCH 3/6] Update results.html --- results.html | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/results.html b/results.html index dfe49cf..d14568a 100644 --- a/results.html +++ b/results.html @@ -16,22 +16,23 @@ json3.appendChild(document.getElementsByTagName('head')[0]); - - + + + - +

You made it to the results page!

-

On this page you will:

-
    -
  • Tastefully display the selections the user made .
  • -
  • Fix the json3 and css includes for IE7.
  • +

    Selected Items:

    +
      +
    • {{item}}
    -
- \ No newline at end of file + From 768a19dff240f5ae73a8da2923ba7e02feab2a55 Mon Sep 17 00:00:00 2001 From: prag1989 Date: Fri, 12 Dec 2014 10:28:56 -0600 Subject: [PATCH 4/6] Create testForm.html --- testForm.html | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 testForm.html diff --git a/testForm.html b/testForm.html new file mode 100644 index 0000000..9a90cb8 --- /dev/null +++ b/testForm.html @@ -0,0 +1,48 @@ +
+
+

The User Interface Developer Test

+
+
+
    +
  • This Page and results.html should be converted to AngularJS templates.
  • +
  • Add a select-all toggle for the checkbox list.
  • +
  • Select-all should be checked if all fields are checked, unchecked if all fields are unchecked and indeterminate if some are checked.
  • +
  • Sor the checkboxes by name
  • +
  • When submitting the form, if only "Language" is checked, then an error should appear stating " Please choose more items! "
  • +
  • Successfully submitting the form takes us to results.html and shows what the user submitted.
  • +
  • Maybe the page can look a little better?
  • +

    Read the README.md

    +
+
+
+
+ Select All +
+
+ + + + + + +
+ +
+ + + + + +
From ad72c988a0cd49ba9f57a4309975dae389cc4235 Mon Sep 17 00:00:00 2001 From: Pragadeeswar Date: Tue, 16 Dec 2014 00:44:28 -0600 Subject: [PATCH 5/6] Changes-v1 --- index.html | 58 +++++++++++++++++++++++-------------- js/app.js | 45 ++++++++++++++++++++++------- results.html | 39 +++++++++---------------- testForm.html | 79 +++++++++++++++++++++------------------------------ 4 files changed, 117 insertions(+), 104 deletions(-) diff --git a/index.html b/index.html index 32d1201..869136b 100644 --- a/index.html +++ b/index.html @@ -1,32 +1,46 @@ + - - - - - - - - - - - - - + - -
-
-
+ +
+
+
+ + + + diff --git a/js/app.js b/js/app.js index 26424a2..458e73e 100644 --- a/js/app.js +++ b/js/app.js @@ -3,11 +3,11 @@ angular.module('TestMe', ['ngTest.cbSelector', 'ngTest.results', 'ngRoute']) function($routeProvider) { $routeProvider. when('/', { - templateUrl: '/TestMe_NG-master/testForm.html', + templateUrl: '/testForm.html', controller: 'CheckBoxController' }). when('/results', { - templateUrl: '/TestMe_NG-master/results.html', + templateUrl: '/results.html', controller: 'ResultsController' }). otherwise({ @@ -17,7 +17,7 @@ angular.module('TestMe', ['ngTest.cbSelector', 'ngTest.results', 'ngRoute']) ]); angular.module('ngTest.cbSelector', []) -.controller('CheckBoxController', ['$scope', '$rootScope', function($scope, $rootScope){ +.controller('CheckBoxController', ['$scope', '$rootScope','$location', function($scope, $rootScope, $location){ $scope.cbSelectedByVal = { abstract: false, publication: false, @@ -28,6 +28,29 @@ angular.module('ngTest.cbSelector', []) }; $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 - - - - TestMe_lite results! - - - - - - - -
-
-

You made it to the results page!

-
-
-

Selected Items:

-
    -
  • {{item}}
  • -
-
- - +
+
+

You made it to the results page!

+
+
+

Selected Items:

+
    +
  • {{item}}
  • +
+ Return to Form +
+
diff --git a/testForm.html b/testForm.html index 9a90cb8..94ed948 100644 --- a/testForm.html +++ b/testForm.html @@ -1,48 +1,35 @@
-
-

The User Interface Developer Test

-
-
-
    -
  • This Page and results.html should be converted to AngularJS templates.
  • -
  • Add a select-all toggle for the checkbox list.
  • -
  • Select-all should be checked if all fields are checked, unchecked if all fields are unchecked and indeterminate if some are checked.
  • -
  • Sor the checkboxes by name
  • -
  • When submitting the form, if only "Language" is checked, then an error should appear stating " Please choose more items! "
  • -
  • Successfully submitting the form takes us to results.html and shows what the user submitted.
  • -
  • Maybe the page can look a little better?
  • -

    Read the README.md

    -
-
-
-
- Select All -
-
- - - - - - -
- -
- - - - - +
+

The User Interface Developer Test

+
+
+
    +
  • This Page and results.html should be converted to AngularJS templates.
  • +
  • Add a select-all toggle for the checkbox list.
  • +
  • Select-all should be checked if all fields are checked, unchecked if all fields are unchecked and indeterminate if some are checked.
  • +
  • Sor the checkboxes by name
  • +
  • When submitting the form, if only "Language" is checked, then an error should appear stating " Please choose more items! "
  • +
  • Successfully submitting the form takes us to results.html and shows what the user submitted.
  • +
  • Maybe the page can look a little better?
  • +

    Read the README.md

    +
+
+
+
+ Select All +
+
+
+ + +
+
+ +
+
+
From d461c3fc6718565215c0ce56c1ddc333647c8287 Mon Sep 17 00:00:00 2001 From: Pragadeeswar Date: Tue, 16 Dec 2014 00:46:07 -0600 Subject: [PATCH 6/6] v2 --- testForm.html | 1 - 1 file changed, 1 deletion(-) diff --git a/testForm.html b/testForm.html index 94ed948..56d458b 100644 --- a/testForm.html +++ b/testForm.html @@ -30,6 +30,5 @@

The User Interface Developer Test