From 105b85e37bd82654baf9c8ccf252ca2c197112d9 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Tue, 16 Dec 2014 21:17:11 +0100 Subject: [PATCH 01/28] Fixed some urls in reqbazservice.js. The requirements list now shows developers, followers, creator and leadDeveloper name. The layout is not yet organized. --- app/scripts/controllers/main.js | 75 +++++++++++++++++++-------- app/scripts/services/reqbazservice.js | 58 +++++++++++---------- app/styles/main.css | 12 +---- app/views/main.html | 32 ++++++++---- 4 files changed, 110 insertions(+), 67 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 8b8c1b41..2f2ed22c 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -13,7 +13,7 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.projects = null; $scope.components = null; $scope.requirements = null; - $scope.activeUser = {id : '1', firstname : 'Kristjan', lastname : 'Liiva', email : 'liiva@web.com', admin : 'true', Las2PeerId :'000', username : 'KristjanLiiva'}; + $scope.activeUser = {id : '2', firstname : 'Max2', lastname : 'Mustermann2', email : 'Max@Mustermann2.de', admin : 'true', Las2PeerId :'2'}; $scope.projectLeader = null; $scope.componentLeader = null; @@ -62,6 +62,17 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.getRequirementsByComponent($scope.activeProject.id,$scope.activeComponent.id) .success(function (reqs) { $scope.requirements = reqs; + for(var i = 0; i<$scope.requirements.length;i++){ + //TODO see if I can come up with something better + $scope.requirements[i].creator = {firstName : 'loading'}; + $scope.requirements[i].leadDeveloper = {firstName : 'loading'}; + $scope.requirements[i].followers = []; + $scope.requirements[i].developers = []; + $scope.requirements[i].contributors = []; + $scope.requirements[i].attachments = []; + $scope.requirements[i].comments = []; + $scope.requirements[i].components = []; + } console.log($scope.requirements); }) .error(function (error) { @@ -90,16 +101,28 @@ angular.module('requirementsBazaarWebFrontendApp') //Call the init functions getProjects(); - $scope.toggle = function(clickEvent,index) { - console.log(index); + $scope.toggleComponent = function(clickEvent,req) { + //console.log(req); var collapse = clickEvent.target.nextElementSibling; - if(collapse.getAttribute('data-visible') === 'false'){ console.log('opened requirement'); collapse.setAttribute('data-visible', 'true'); - //Get all the missing pieces of information, like leader, follower, votes - + //Get leader + reqBazService.getRequirement(req.id) + .success(function (requirement) { + req.creator = requirement.creator; + req.attachments = requirement.attachments; + req.components = requirement.components; + req.leadDeveloper = requirement.leadDeveloper; + req.followers = requirement.followers; + req.developers = requirement.developers; + req.contributors = requirement.contributors; + }) + .error(function (error) { + console.log(error.message); + alert('Something went wrong, please try again'); + }); }else{ collapse.setAttribute('data-visible', 'false'); } @@ -116,6 +139,7 @@ angular.module('requirementsBazaarWebFrontendApp') }; + //Creates a new component $scope.showCreateCompDiv = false; $scope.newCompName = ''; @@ -149,14 +173,13 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.warningText = 'Confirm deleting the component !'; $scope.warningVisible = true; }; - $scope.cancelDeleteComponent = function(){ + $scope.resetDeleteComponent = function(){ $scope.warningText = 'Confirm deletion !'; $scope.warningVisible = false; }; $scope.deleteComponent = function(){ - $scope.warningText = 'Confirm deletion !'; - $scope.warningVisible = false; - reqBazService.deleteComponent($scope.activeProject.id,$scope.activeComponent.id) + $scope.resetDeleteComponent(); + reqBazService.deleteComponent($scope.activeComponent.id) .success(function (message) { console.log(message); for(var i = 0; i<$scope.components.length;i++){ @@ -184,12 +207,9 @@ angular.module('requirementsBazaarWebFrontendApp') if($scope.newReqName !== '' && $scope.newReqDesc !== ''){ console.log('submit requirement'); var requirement = {title: $scope.newReqName, description: $scope.newReqDesc, projectId: $scope.activeProject.id, leadDeveloperId : 1, creatorId : 1}; - - console.log($scope.activeProject.id); - console.log($scope.activeComponent.id); - console.log(requirement); reqBazService.createRequirement($scope.activeProject.id,$scope.activeComponent.id,requirement) .success(function (message) { + //TODO add the requirement to the list console.log(message); }) .error(function (error) { @@ -197,11 +217,6 @@ angular.module('requirementsBazaarWebFrontendApp') }); $scope.showCreateReqDiv = false; - //this.createRequirement = function(projectId, componentId, requirement){ - // var reqUrl = url + 'projects/' + projectId + '/components/' + componentId + '/requirements'; - // return $http.post(reqUrl, requirement); - //}; - }else{ console.log('Input field empty'); //TODO Show toast @@ -214,6 +229,26 @@ angular.module('requirementsBazaarWebFrontendApp') }; + /** + * + * Function calls that currently don't do anything or don't work + * + */ + + + + //Become a follower of a requirement + $scope.followRequirement = function(clickEvent,req){ + console.log('become follower'); + reqBazService.addUserToFollowers(req.id) + .success(function (message) { + console.log(message); + }) + .error(function (error) { + console.log(error.message); + alert('Something went wrong, please try again'); + }); + }; $scope.signOut = function(){ @@ -223,8 +258,6 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.editProfile = function(){ window.alert('TODO'); }; - - }); diff --git a/app/scripts/services/reqbazservice.js b/app/scripts/services/reqbazservice.js index 3e879060..36c11e3b 100644 --- a/app/scripts/services/reqbazservice.js +++ b/app/scripts/services/reqbazservice.js @@ -52,17 +52,18 @@ angular.module('requirementsBazaarWebFrontendApp') return $http.get(componentUrl + '/' + componentId); }; - this.deleteComponent = function(projectId,componentId){ - var componentUrl = url + 'projects/' + projectId + '/components'; + this.deleteComponent = function(componentId){ + var componentUrl = url + 'projects/' + 0 + '/components'; return $http.delete(componentUrl + '/' + componentId); }; ///REQUIREMENTS - this.getRequirementsByProject = function(projectId, page, per_page){ - var reqUrl = url + 'projects/' + projectId + '/components/' + 0 + '/requirements'; - return $http.get(paginate(reqUrl,page,per_page)); - }; + //Currently not used + //this.getRequirementsByProject = function(projectId, page, per_page){ + // var reqUrl = url + 'projects/' + projectId + '/components/' + 0 + '/requirements'; + // return $http.get(paginate(reqUrl,page,per_page)); + //}; this.getRequirementsByComponent = function(projectId,componentId,page,per_page){ var reqUrl = url + 'projects/' + projectId + '/components/' + componentId + '/requirements'; @@ -76,41 +77,42 @@ angular.module('requirementsBazaarWebFrontendApp') this.getRequirement = function(requirementId){ var reqUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements'; - return $http.get(componentUrl + '/' + requirementId); + return $http.get(reqUrl + '/' + requirementId); }; this.deleteRequirement = function(requirementId) { var reqUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements'; - return $http.delete(componentUrl + '/' + requirementId); + return $http.delete(reqUrl + '/' + requirementId); }; //DEV LIST this.addUserToDevelopers = function(requirementId){ var devUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + requirementId + '/developers'; - return $http.post(reqUrl); + return $http.post(devUrl); }; this.removeUserFromDevelopers = function(requirementId){ - var devUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/developers'; - return $http.delete(reqUrl); + var devUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + requirementId + '/developers'; + return $http.delete(devUrl); }; ///FOLLOWER LIST - this.addUserToDevelopers = function(requirementId){ - var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/followers'; - return $http.post(reqUrl); + // + this.addUserToFollowers = function(requirementId){ + var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + requirementId + '/followers'; + return $http.post(followUrl); }; - this.removeUserFromDevelopers = function(requirementId){ - var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/followers'; - return $http.delete(reqUrl); + this.removeUserFromFollowers = function(requirementId){ + var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + requirementId + '/followers'; + return $http.delete(followUrl); }; ///VOTE this.addVote = function(requirementId, isDownvote){ - var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/vote'; + var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + requirementId + '/vote'; if (isDownvote){ followUrl += '?direction=down'; } else { @@ -120,32 +122,34 @@ angular.module('requirementsBazaarWebFrontendApp') return $http.post(reqUrl); }; - this.removeUserFromDevelopers = function(requirementId){ - var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/vote'; - return $http.delete(reqUrl); - }; + + //TODO naming is wrong + //this.removeUserFromDevelopers = function(requirementId){ + // var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/vote'; + // return $http.delete(reqUrl); + //}; /// COMMENTS this.getComments = function(requirementId, page, per_page){ - var commentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/comments'; + var commentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + requirementId + '/comments'; return $http.get(paginate(commentUrl,page,per_page)); }; this.createComment = function(requirementId,comment){ - var commentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/comments'; + var commentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + requirementId + '/comments'; return $http.post(commentUrl, comment); }; this.deleteComment = function(commentId){ - var commentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + 0 + '/comments'; + var commentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + 0 + '/comments'; return $http.delete(commentUrl + '/' + commentId); }; ///ATTACHMENTS //TODO Attachment Type? I think it is not implemented on backend this.createAttachment = function(attachmentType, attachment){ - var attachmentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + 0 + '/attachments'; + var attachmentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + 0 + '/attachments'; attachmentUrl+= '?attachmentType' + attachmentType; @@ -153,7 +157,7 @@ angular.module('requirementsBazaarWebFrontendApp') }; this.deleteComment = function(attachmentId){ - var attachmentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + 0 + '/attachments'; + var attachmentUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements/' + 0 + '/attachments'; return $http.delete(attachmentUrl + '/' + attachmentId); }; diff --git a/app/styles/main.css b/app/styles/main.css index cfa8fa2e..f4222216 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -1,13 +1,4 @@ -/*html /deep/ paper-dialog {*/ - /*color: green;*/ -/*}*/ - -/*html /deep/ paper-dialog::shadow #scroller {*/ - /*height: 300px;*/ - /*width: 300px;*/ -/*}*/ - #deleteSomething{ position: fixed; z-index: 12; @@ -73,7 +64,7 @@ body { } #profileDivFooter paper-button{ - background-color: #669900; + /*background-color: #669900;*/ color: white; } @@ -119,4 +110,5 @@ paper-dropdown-menu::shadow #label, paper-dropdown-menu::shadow #arrow{ paper-button { margin: 10px; + background-color: #669900;; } diff --git a/app/views/main.html b/app/views/main.html index f06ebcb4..1c958afe 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -100,31 +100,45 @@

-
- {{req.title}} +
+ {{req.title}}

{{req.description}}

-

Leader : {{leader}}

-

Followers : {{followers}}

-

Developers : {{developers}}

- Attachments +

Leader : {{req.leadDeveloper.firstName}} {{req.leadDeveloper.lastName}}

+
+

People who follow the project are

+

+ {{follower.firstName}} +

+
+
+

Developers for the project

+

+ {{dev.firstName}} +

+
+

Created by : {{req.creator.firstName}} {{req.creator.lastName}}

+ Attachments Here be attachments + {{req.attachments}}
- Comments + Comments Here be comments + {{req.comments}}
+
Become Lead - + @@ -145,7 +159,7 @@

{{warningText}}

- Decline + Decline Accept
From 6e662b4fd95124482b14eecba292028582c0519b Mon Sep 17 00:00:00 2001 From: Kristjan Date: Wed, 24 Dec 2014 00:58:50 +0200 Subject: [PATCH 02/28] Improved the layout of the requirements and changed the button positions. Added Material Design Icons to the project, not through bower, but as a standalone html, for better use with polymer elements. --- app/index.html | 3 ++ app/scripts/controllers/main.js | 18 ++++---- app/scripts/services/reqbazservice.js | 10 ++--- app/styles/main.css | 3 +- app/styles/mdi.html | 1 + app/views/main.html | 63 ++++++++++++--------------- 6 files changed, 47 insertions(+), 51 deletions(-) create mode 100644 app/styles/mdi.html diff --git a/app/index.html b/app/index.html index 5769bbc4..db30ccc3 100644 --- a/app/index.html +++ b/app/index.html @@ -49,6 +49,9 @@ + + +
- {{req.title}} +
+ {{req.title}} +
+
+ + + + + + +
+ +
+

{{req.description}}

-

Leader : {{req.leadDeveloper.firstName}} {{req.leadDeveloper.lastName}}

-
-

People who follow the project are

-

+

+ + +
+

Leader

+

{{req.leadDeveloper.firstName}} {{req.leadDeveloper.lastName}}

+
+

Followers

+

{{follower.firstName}}

-
-

Developers for the project

-

+

+

Developers

+

{{dev.firstName}}

-

Created by : {{req.creator.firstName}} {{req.creator.lastName}}

- Attachments - - Here be attachments - {{req.attachments}} - -
- Comments - - Here be comments - {{req.comments}} - -
- - -
- -
- Become Lead - - - - - -
+

Created by

+

{{req.creator.firstName}} {{req.creator.lastName}}

@@ -153,8 +148,6 @@

- - From c15e386d2ce0a9df8fe276cea6c00b2e4bfe09d4 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Fri, 9 Jan 2015 16:25:02 +0100 Subject: [PATCH 03/28] The layout for the requirements list is mostly finished. Added pieces of code from a CSS library to provide grid layout, looks better with less code now. This also fixed some layout problems for firefox. --- app/scripts/controllers/main.js | 10 +++ app/styles/main.css | 126 ++++++++++++++++++++++++++++++++ app/views/main.html | 26 +++---- 3 files changed, 149 insertions(+), 13 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 315cfd3a..1eba3af9 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -10,6 +10,9 @@ angular.module('requirementsBazaarWebFrontendApp') .controller('MainCtrl', function ($scope, reqBazService) { + //Index which requirement in the list is selected + $scope.selectedIndex = -1; + $scope.projects = null; $scope.components = null; $scope.requirements = null; @@ -230,6 +233,13 @@ angular.module('requirementsBazaarWebFrontendApp') + $scope.showMoreClicked = function ($index) { + if($scope.selectedIndex == $index){ + $scope.selectedIndex = -1; + }else{ + $scope.selectedIndex = $index; + } + }; /** diff --git a/app/styles/main.css b/app/styles/main.css index 089ac9fa..0c1f9857 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -40,6 +40,7 @@ body { .collapse-content { padding: 15px; border: 1px solid #dedede; + background-color: white; } #profileDiv, #NotificationDiv{ @@ -113,3 +114,128 @@ paper-button { background-color: #669900; } + + + + + + + +/* + + GRID CSS + + http://www.responsivegridsystem.com/ - Graham Miller + + Offered under + http://creativecommons.org/licenses/by/3.0/ +*/ + + +/* SECTIONS ============================================================================= */ + +.section { + clear: both; + padding: 0; + margin: 0; +} + +/* GROUPING ============================================================================= */ + + +.group:before, +.group:after { + content:""; + display:table; +} +.group:after { + clear:both; +} +.group { + zoom:1; /* For IE 6/7 (trigger hasLayout) */ +} + +/* GRID COLUMN SETUP ==================================================================== */ + +.col { + display: block; + float:left; +} + +.col:first-child { margin-left: 0; } /* all browsers except IE6 and lower */ + + +/* REMOVE MARGINS AS ALL GO FULL WIDTH AT 480 PIXELS */ + +@media only screen and (max-width: 480px) { + .col { + + } +} + + + +/* GRID OF EIGHT ============================================================================= */ + + +.span_8_of_8 { + width: 100%; +} + +.span_7_of_8 { + width: 87.3%; +} + +.span_6_of_8 { + width: 74.6%; +} + +.span_5_of_8 { + width: 61.9%; +} + +.span_4_of_8 { + width: 49.2%; +} + +.span_3_of_8 { + width: 36.5%; +} + +.span_2_of_8 { + width: 23.8%; +} + +.span_1_of_8 { + width: 11.1%; +} + + +/* GO FULL WIDTH AT LESS THAN 480 PIXELS */ + +@media only screen and (max-width: 480px) { + .span_8_of_8 { + width: 100%; + } + .span_7_of_8 { + width: 100%; + } + .span_6_of_8 { + width: 100%; + } + .span_5_of_8 { + width: 100%; + } + .span_4_of_8 { + width: 100%; + } + .span_3_of_8 { + width: 100%; + } + .span_2_of_8 { + width: 100%; + } + .span_1_of_8 { + width: 100%; + } +} diff --git a/app/views/main.html b/app/views/main.html index 167143d9..4220c68a 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -66,13 +66,12 @@
- -
-
+
+

-
+

Component lead:

@@ -101,28 +100,29 @@

-
- {{req.title}} -
-
- +
+ {{req.title}} +
+ +
+ Become Lead
-
-
-
+ +
+

{{req.description}}

-
+

Leader

{{req.leadDeveloper.firstName}} {{req.leadDeveloper.lastName}}

From 954d8842eed286550b86a4c34de406ea83791bb6 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Fri, 9 Jan 2015 17:29:15 +0100 Subject: [PATCH 04/28] Created a new floating button (google inbox style) to create new requirements. --- app/index.html | 1 + app/styles/main.css | 24 ++++++++++++++++++++++++ app/views/main.html | 34 ++++++++++++++++++---------------- bower.json | 3 ++- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/app/index.html b/app/index.html index db30ccc3..b72199a4 100644 --- a/app/index.html +++ b/app/index.html @@ -39,6 +39,7 @@ + diff --git a/app/styles/main.css b/app/styles/main.css index 0c1f9857..5a2d29e1 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -69,6 +69,30 @@ body { color: white; } +#addRequirementFab{ + color: white; + cursor: pointer; + z-index: 1; + position: fixed; + right: 40px; + bottom: 30px; + width: 56px; + height: 56px; + border-radius: 50%; + background: #db4437; +} +#addRequirementDiv{ + width: 400px; + right: 130px; + position: fixed; + background-color: white; + z-index: 2; + bottom: 0; + padding: 10px; + border: 1px solid #ccc; + border-color: rgba(0,0,0,.2); + box-shadow: 0 2px 10px rgba(0,0,0,.2); +} /* diff --git a/app/views/main.html b/app/views/main.html index 4220c68a..5bdbfbb0 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -77,26 +77,10 @@

-
-
-

Add requirement

- - - - - - - - - - - - -
@@ -157,4 +141,22 @@

+ +
+

Add requirement

+ + + + + + + + + + + + +
+ + diff --git a/bower.json b/bower.json index f9eaa537..94e9aa35 100644 --- a/bower.json +++ b/bower.json @@ -32,7 +32,8 @@ "core-list": "Polymer/core-list#~0.5.1", "paper-input": "Polymer/paper-input#~0.5.1", "paper-toast": "Polymer/paper-toast#~0.5.2", - "paper-dialog": "Polymer/paper-dialog#~0.5.2" + "paper-dialog": "Polymer/paper-dialog#~0.5.2", + "paper-fab": "Polymer/paper-fab#~0.5.2" }, "devDependencies": { "angular-mocks": "~1.2.0", From 7e44f126b971c6e11bd4f9e006a93669242e5213 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Sat, 10 Jan 2015 18:49:32 +0100 Subject: [PATCH 05/28] Added Oauth component to the project --- app/scripts/app.js | 3 ++- app/views/main.html | 12 ++++++++++++ bower.json | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/scripts/app.js b/app/scripts/app.js index cefab8df..7ca3248a 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -16,7 +16,8 @@ angular 'ngRoute', 'ngSanitize', 'ngTouch', - 'ng-polymer-elements' + 'ng-polymer-elements', + 'oauth' ]) .config(function ($routeProvider) { $routeProvider diff --git a/app/views/main.html b/app/views/main.html index 5bdbfbb0..ac59dc2a 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -32,6 +32,18 @@ Sign Out
+ + + + + +
diff --git a/bower.json b/bower.json index 94e9aa35..1bba552b 100644 --- a/bower.json +++ b/bower.json @@ -33,7 +33,8 @@ "paper-input": "Polymer/paper-input#~0.5.1", "paper-toast": "Polymer/paper-toast#~0.5.2", "paper-dialog": "Polymer/paper-dialog#~0.5.2", - "paper-fab": "Polymer/paper-fab#~0.5.2" + "paper-fab": "Polymer/paper-fab#~0.5.2", + "oauth-ng": "~0.3.6" }, "devDependencies": { "angular-mocks": "~1.2.0", From c8056ea8d0ef0a72b476a3061309136f8ca178de Mon Sep 17 00:00:00 2001 From: Kristjan Date: Sat, 10 Jan 2015 18:55:16 +0100 Subject: [PATCH 06/28] Fixes to the Oauth config and fixed the project URL. --- app/index.html | 4 ++++ app/scripts/app.js | 6 ++++-- app/scripts/controllers/main.js | 10 +++++++--- app/views/main.html | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/index.html b/app/index.html index b72199a4..1016d118 100644 --- a/app/index.html +++ b/app/index.html @@ -11,6 +11,8 @@ + + @@ -90,6 +92,8 @@ + + diff --git a/app/scripts/app.js b/app/scripts/app.js index 7ca3248a..2abce56b 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -19,7 +19,7 @@ angular 'ng-polymer-elements', 'oauth' ]) - .config(function ($routeProvider) { + .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { $routeProvider .when('/', { templateUrl: 'views/main.html', @@ -32,4 +32,6 @@ angular .otherwise({ redirectTo: '/' }); - }); + + $locationProvider.html5Mode(true).hashPrefix('!'); + }]); diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 1eba3af9..a216e8db 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -99,9 +99,6 @@ angular.module('requirementsBazaarWebFrontendApp') }); } - //Call the init functions - getProjects(); - $scope.toggleRequirement = function(clickEvent,req) { var collapse = clickEvent.target.parentNode.nextElementSibling; if(collapse.getAttribute('data-visible') === 'false'){ @@ -268,6 +265,13 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.editProfile = function(){ window.alert('TODO'); }; + + + + + //Call the init functions + getProjects(); + }); diff --git a/app/views/main.html b/app/views/main.html index ac59dc2a..7f68c9c6 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -20,7 +20,7 @@
- +

{{activeUser.firstname}} {{activeUser.lastname}}

From e10bd4df358a348f7bc952226727187507f1678c Mon Sep 17 00:00:00 2001 From: Kristjan Date: Fri, 16 Jan 2015 16:55:53 +0100 Subject: [PATCH 07/28] Bug fixes to adding new requirements. New requirements are now shown as the first element in the list. The panel can now be closed again with X button. Components can be deleted again. --- app/scripts/controllers/main.js | 32 ++++++++++++++++++++++----- app/scripts/services/reqbazservice.js | 4 ++-- app/views/main.html | 4 ++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index a216e8db..89f5fa0a 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -136,6 +136,10 @@ angular.module('requirementsBazaarWebFrontendApp') }; + /* + * Everything related to creating or deleting a new component + * + * */ //Creates a new component $scope.showCreateCompDiv = false; @@ -149,10 +153,10 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.createComponent($scope.activeProject.id,component) .success(function (message) { console.log(message); - //TODO add the new component to the $scope.component and then set everything to default + //The component is added to be the first element component.id = message.id; $scope.activeComponent = component; - $scope.components.push($scope.activeComponent); + $scope.components.splice(0, 0, $scope.activeComponent); $scope.clearComponentSubmit(); }) .error(function (error) { @@ -179,7 +183,7 @@ angular.module('requirementsBazaarWebFrontendApp') }; $scope.deleteComponent = function(){ $scope.resetDeleteComponent(); - reqBazService.deleteComponent($scope.activeComponent.id) + reqBazService.deleteComponent($scope.activeProject.id,$scope.activeComponent.id) .success(function (message) { console.log(message); for(var i = 0; i<$scope.components.length;i++){ @@ -199,6 +203,12 @@ angular.module('requirementsBazaarWebFrontendApp') }); }; + + /* + * Everything related to creating or deleting a new requirement + * + * */ + //Creating a requirement $scope.showCreateReqDiv = false; $scope.newReqName = ''; @@ -209,8 +219,20 @@ angular.module('requirementsBazaarWebFrontendApp') var requirement = {title: $scope.newReqName, description: $scope.newReqDesc, projectId: $scope.activeProject.id, leadDeveloperId : 1, creatorId : 1}; reqBazService.createRequirement($scope.activeProject.id,$scope.activeComponent.id,requirement) .success(function (message) { - //TODO add the requirement to the list - console.log(message); + //Add missing values to the newly created requirement + requirement.id = message.id; + requirement.creator = {firstName : 'loading'}; + requirement.leadDeveloper = {firstName : 'loading'}; + requirement.followers = []; + requirement.developers = []; + requirement.contributors = []; + requirement.attachments = []; + requirement.comments = []; + requirement.components = []; + + //Add the requirement to the first position + $scope.requirements.splice(0, 0, requirement); + $scope.clearReqSubmit(); }) .error(function (error) { console.log(error.message); diff --git a/app/scripts/services/reqbazservice.js b/app/scripts/services/reqbazservice.js index bc1198ae..a4d34616 100644 --- a/app/scripts/services/reqbazservice.js +++ b/app/scripts/services/reqbazservice.js @@ -52,8 +52,8 @@ angular.module('requirementsBazaarWebFrontendApp') return $http.get(componentUrl + '/' + componentId); }; - this.deleteComponent = function(componentId){ - var componentUrl = url + 'projects/' + 0 + '/components'; + this.deleteComponent = function(projectId,componentId){ + var componentUrl = url + 'projects/' + projectId + '/components'; return $http.delete(componentUrl + '/' + componentId); }; diff --git a/app/views/main.html b/app/views/main.html index 7f68c9c6..e84e3d96 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -153,8 +153,8 @@

- -
+ +

Add requirement

From 85423eae78b050b52429fa8b8b5d9f41e8a25a59 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Fri, 16 Jan 2015 17:26:19 +0100 Subject: [PATCH 08/28] Bug fix. Requirements can be deleted and modified the error handling when a request fails. --- app/scripts/controllers/main.js | 43 ++++++++++++++++++++++----- app/scripts/services/reqbazservice.js | 2 +- app/views/main.html | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 89f5fa0a..6aeb81a3 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -186,15 +186,19 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.deleteComponent($scope.activeProject.id,$scope.activeComponent.id) .success(function (message) { console.log(message); - for(var i = 0; i<$scope.components.length;i++){ - if($scope.components[i].id === $scope.activeComponent.id){ - $scope.components.splice(i, 1); - break; + if(message.success !== "true"){ + alert('Could not delete, please try again'); + }else { + for (var i = 0; i < $scope.components.length; i++) { + if ($scope.components[i].id === $scope.activeComponent.id) { + $scope.components.splice(i, 1); + break; + } + } + $scope.activeComponent = null; + if ($scope.components !== null) { + $scope.activeComponent = $scope.components[0]; } - } - $scope.activeComponent = null; - if($scope.components !== null){ - $scope.activeComponent = $scope.components[0]; } }) .error(function (error) { @@ -249,6 +253,29 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.newReqDesc = ''; $scope.showCreateReqDiv = false; }; + $scope.deleteRequirement = function(req){ + console.log('delete requirement'); + reqBazService.deleteRequirement(req.id) + .success(function (message) { + if(message.success !== "true"){ + alert('Could not delete, please try again'); + }else{ + // Delete the removed requirement from the list + for(var i = 0; i<$scope.requirements.length;i++){ + if($scope.requirements[i].id === req.id){ + $scope.requirements.splice(i, 1); + break; + } + } + } + }) + // The error function is not used + .error(function (error) { + console.log(error.message); + alert('Could not delete, please try again'); + }); + }; + diff --git a/app/scripts/services/reqbazservice.js b/app/scripts/services/reqbazservice.js index a4d34616..2aaa441f 100644 --- a/app/scripts/services/reqbazservice.js +++ b/app/scripts/services/reqbazservice.js @@ -121,7 +121,7 @@ angular.module('requirementsBazaarWebFrontendApp') }; - //TODO naming is wrong + //naming is wrong //this.removeUserFromDevelopers = function(requirementId){ // var followUrl = url + 'projects/' + 0 + '/components/' + 0 + '/requirements' + requirementId + '/vote'; // return $http.delete(reqUrl); diff --git a/app/views/main.html b/app/views/main.html index e84e3d96..0b200d9e 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -106,7 +106,7 @@

- +
From 02f6e919d7c2888e229a199915e2ae3751aeba52 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Fri, 16 Jan 2015 18:36:50 +0100 Subject: [PATCH 09/28] Added a toast element, that provides user feedback when something is created or deleted. --- app/scripts/controllers/main.js | 102 +++++++++++++++++++------------- app/views/main.html | 1 + 2 files changed, 63 insertions(+), 40 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 6aeb81a3..285be5f5 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -27,6 +27,8 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.warningText = 'Confirm deletion !'; $scope.warningVisible = false; + $scope.toastText = ''; + //init functions that need to be run when the user enters the page function getProjects(){ reqBazService.getProjects() @@ -34,7 +36,6 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.projects = projs; $scope.activeProject = $scope.projects[0]; $scope.selectProj($scope.activeProject); - }) .error(function (error) { $scope.status = 'Unable to load customer data: ' + error.message; @@ -64,7 +65,8 @@ angular.module('requirementsBazaarWebFrontendApp') .success(function (reqs) { $scope.requirements = reqs; for(var i = 0; i<$scope.requirements.length;i++){ - //TODO see if I can come up with something better + + //This adds the missing attributes to the requirements $scope.requirements[i].creator = {firstName : 'loading'}; $scope.requirements[i].leadDeveloper = {firstName : 'loading'}; $scope.requirements[i].followers = []; @@ -128,12 +130,6 @@ angular.module('requirementsBazaarWebFrontendApp') collapse.toggle(); }; - $scope.toggleAttachments = function(clickEvent) { - console.log('toggle attachments'); - }; - $scope.toggleComments = function(clickEvent) { - console.log('toggle comments'); - }; /* @@ -153,19 +149,28 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.createComponent($scope.activeProject.id,component) .success(function (message) { console.log(message); - //The component is added to be the first element - component.id = message.id; - $scope.activeComponent = component; - $scope.components.splice(0, 0, $scope.activeComponent); - $scope.clearComponentSubmit(); + if(message.id === 'undefined'){ + $scope.toastText = 'Warning: Component was not created !'; + document.getElementById("feedbackToast").show(); + }else { + $scope.toastText = 'Component was created'; + document.getElementById("feedbackToast").show(); + + //The component is added to be the first element + component.id = message.id; + $scope.activeComponent = component; + $scope.components.splice(0, 0, $scope.activeComponent); + $scope.clearComponentSubmit(); + } }) .error(function (error) { console.log(error.message); - alert('Something went wrong, please try again'); + $scope.toastText = 'Warning: Component was not created !'; + document.getElementById("feedbackToast").show(); }); }else{ - console.log('Input field empty'); - //TODO Show toast + $scope.toastText = 'Provide a name & description for the component'; + document.getElementById("feedbackToast").show(); } }; $scope.clearComponentSubmit = function(){ @@ -187,7 +192,8 @@ angular.module('requirementsBazaarWebFrontendApp') .success(function (message) { console.log(message); if(message.success !== "true"){ - alert('Could not delete, please try again'); + $scope.toastText = 'Warning: Component was not deleted !'; + document.getElementById("feedbackToast").show(); }else { for (var i = 0; i < $scope.components.length; i++) { if ($scope.components[i].id === $scope.activeComponent.id) { @@ -199,11 +205,14 @@ angular.module('requirementsBazaarWebFrontendApp') if ($scope.components !== null) { $scope.activeComponent = $scope.components[0]; } + $scope.toastText = 'Component deleted'; + document.getElementById("feedbackToast").show(); } }) .error(function (error) { console.log(error.message); - alert('Could not delete, please try again'); + $scope.toastText = 'Warning: Component was not deleted !'; + document.getElementById("feedbackToast").show(); }); }; @@ -223,29 +232,41 @@ angular.module('requirementsBazaarWebFrontendApp') var requirement = {title: $scope.newReqName, description: $scope.newReqDesc, projectId: $scope.activeProject.id, leadDeveloperId : 1, creatorId : 1}; reqBazService.createRequirement($scope.activeProject.id,$scope.activeComponent.id,requirement) .success(function (message) { - //Add missing values to the newly created requirement - requirement.id = message.id; - requirement.creator = {firstName : 'loading'}; - requirement.leadDeveloper = {firstName : 'loading'}; - requirement.followers = []; - requirement.developers = []; - requirement.contributors = []; - requirement.attachments = []; - requirement.comments = []; - requirement.components = []; - - //Add the requirement to the first position - $scope.requirements.splice(0, 0, requirement); - $scope.clearReqSubmit(); + console.log(message); + if(message.id === 'undefined'){ + $scope.toastText = 'Warning: Requirement was not created !'; + document.getElementById("feedbackToast").show(); + }else{ + $scope.toastText = 'Requirement was created'; + document.getElementById("feedbackToast").show(); + + //Add missing values to the newly created requirement + requirement.id = message.id; + requirement.creator = {firstName : 'loading'}; + requirement.leadDeveloper = {firstName : 'loading'}; + requirement.followers = []; + requirement.developers = []; + requirement.contributors = []; + requirement.attachments = []; + requirement.comments = []; + requirement.components = []; + + //Add the requirement to the first position + $scope.requirements.splice(0, 0, requirement); + $scope.clearReqSubmit(); + } }) .error(function (error) { + //This method only catches network errors console.log(error.message); + $scope.toastText = 'Warning: Requirement was not created !'; + document.getElementById("feedbackToast").show(); }); $scope.showCreateReqDiv = false; }else{ - console.log('Input field empty'); - //TODO Show toast + $scope.toastText = 'Provide a name & description for the requirement'; + document.getElementById("feedbackToast").show(); } }; $scope.clearReqSubmit = function(){ @@ -258,7 +279,8 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.deleteRequirement(req.id) .success(function (message) { if(message.success !== "true"){ - alert('Could not delete, please try again'); + $scope.toastText = 'Warning: Requirement was not deleted'; + document.getElementById("feedbackToast").show(); }else{ // Delete the removed requirement from the list for(var i = 0; i<$scope.requirements.length;i++){ @@ -267,12 +289,15 @@ angular.module('requirementsBazaarWebFrontendApp') break; } } + $scope.toastText = 'Requirement deleted'; + document.getElementById("feedbackToast").show(); } }) - // The error function is not used .error(function (error) { + //This error only catches network errors console.log(error.message); - alert('Could not delete, please try again'); + $scope.toastText = 'Warning: Requirement was not deleted'; + document.getElementById("feedbackToast").show(); }); }; @@ -315,9 +340,6 @@ angular.module('requirementsBazaarWebFrontendApp') window.alert('TODO'); }; - - - //Call the init functions getProjects(); diff --git a/app/views/main.html b/app/views/main.html index 0b200d9e..59d79e32 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -170,5 +170,6 @@

+ From 1fd7c45238f7e2035665eb160b3a8bd453a38259 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Sun, 18 Jan 2015 14:48:14 +0100 Subject: [PATCH 10/28] Added further messages for the user. Added buttons to reload requirements or components should the http calls fail. Documented code. --- app/scripts/controllers/main.js | 191 ++++++++++++++++++++------------ app/styles/main.css | 12 ++ app/views/main.html | 9 +- 3 files changed, 139 insertions(+), 73 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 285be5f5..11159f5e 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -24,83 +24,142 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.activeProject = null; $scope.activeComponent = null; + //Variables for confirming deleting a object $scope.warningText = 'Confirm deletion !'; $scope.warningVisible = false; + //In case loading requirements/components fails, show a reload button + $scope.reloadRequirements = false; + $scope.reloadComponents = false; + + + //Only one toast is used for feedback, toastText holds the description $scope.toastText = ''; - //init functions that need to be run when the user enters the page - function getProjects(){ + + + /* + * Loads projects and then components ... + * Called: only when the page loads + * */ + (function(){ reqBazService.getProjects() .success(function (projs) { $scope.projects = projs; - $scope.activeProject = $scope.projects[0]; - $scope.selectProj($scope.activeProject); + if($scope.projects.length !== 0){ + $scope.activeProject = $scope.projects[0]; + $scope.selectProj($scope.activeProject); + }else{ + //TODO somehow gracefully handle the fact that there are no projects + } }) - .error(function (error) { - $scope.status = 'Unable to load customer data: ' + error.message; + .error(function () { + $scope.toastText = 'Could not load projects, please reload !'; + document.getElementById('feedbackToast').show(); }); - } + })(); - //Is called when the user selects a new project + /* + * Switches the active project and loads components belonging to it + * Called: User selects a new project or reloads components + * */ $scope.selectProj = function (project) { + $scope.reloadComponents = false; $scope.activeProject = project; - reqBazService.getComponents($scope.activeProject.id,'0','30') .success(function (comps) { $scope.components = comps; $scope.activeComponent = $scope.components[0]; $scope.selectComp($scope.activeComponent); }) - .error(function (error) { - $scope.status = 'ERROR: ' + error.message; + .error(function () { + //Null the lists, otherwise user will see wrong components/requirements + $scope.components = null; + $scope.activeComponent = null; + $scope.requirements = null; + $scope.selectedIndex = -1; + $scope.toastText = 'Could not load components'; + document.getElementById('feedbackToast').show(); + + //Show the reload requirements button + $scope.reloadComponents = true; }); }; - //Is called when the user has selected a different component + /* + * Switches the active component and loads requirements belonging to it + * Called: User selects a new component/project or reloads requirements + * */ $scope.selectComp = function (component) { + $scope.reloadRequirements = false; $scope.activeComponent = component; getUser($scope.activeComponent.leaderId,'component'); + + //Load the requirements reqBazService.getRequirementsByComponent($scope.activeProject.id,$scope.activeComponent.id) .success(function (reqs) { $scope.requirements = reqs; - for(var i = 0; i<$scope.requirements.length;i++){ - - //This adds the missing attributes to the requirements - $scope.requirements[i].creator = {firstName : 'loading'}; - $scope.requirements[i].leadDeveloper = {firstName : 'loading'}; - $scope.requirements[i].followers = []; - $scope.requirements[i].developers = []; - $scope.requirements[i].contributors = []; - $scope.requirements[i].attachments = []; - $scope.requirements[i].comments = []; - $scope.requirements[i].components = []; - } - console.log($scope.requirements); + if($scope.requirements.length === 0){ + //Since there are none, offer user to create new one + $scope.toastText = 'This component has no requirements, feel free to create'; + document.getElementById('feedbackToast').show(); + }else{ + //Show the requirements + for(var i = 0; i<$scope.requirements.length;i++){ + //This adds the missing attributes to the requirements + $scope.requirements[i].creator = {firstName : 'loading'}; + $scope.requirements[i].leadDeveloper = {firstName : 'loading'}; + $scope.requirements[i].followers = []; + $scope.requirements[i].developers = []; + $scope.requirements[i].contributors = []; + $scope.requirements[i].attachments = []; + $scope.requirements[i].comments = []; + $scope.requirements[i].components = []; + } + } }) - .error(function (error) { - $scope.status = 'ERROR: ' + error.message; + .error(function () { + //Null the list, otherwise user will see wrong requirements + $scope.requirements = null; + $scope.selectedIndex = -1; + $scope.toastText = 'Could not load requirements'; + document.getElementById('feedbackToast').show(); + + //Show the reload requirements button + $scope.reloadRequirements = true; }); }; - //Queries for users + /* + * Loads user information + * Called: automatically, when a component/requirement etc is shown + * */ function getUser(id,purpose){ reqBazService.getUser(id) .success(function (user) { if(purpose === 'component'){ $scope.componentLeader = user; - }else if(purpose === 'project'){ + } + if(purpose === 'project'){ $scope.projectLeader = user; - }else{ - } }) - .error(function (error) { - console.log(error.message); - $scope.status = 'ERROR: ' + error.message; + .error(function () { + if(purpose === 'component'){ + $scope.componentLeader = null; + } + if(purpose === 'project'){ + $scope.projectLeader = null; + } + $scope.toastText = 'Could not load user for: '+purpose; + document.getElementById('feedbackToast').show(); }); } + /* + * Toggles the visibility of a requirements + * Called: user clicks on the requirement + * */ $scope.toggleRequirement = function(clickEvent,req) { var collapse = clickEvent.target.parentNode.nextElementSibling; if(collapse.getAttribute('data-visible') === 'false'){ @@ -118,9 +177,9 @@ angular.module('requirementsBazaarWebFrontendApp') req.developers = requirement.developers; req.contributors = requirement.contributors; }) - .error(function (error) { - console.log(error.message); - alert('Something went wrong, please try again'); + .error(function () { + $scope.toastText = 'Warning: the requirement was not loaded !'; + document.getElementById('feedbackToast').show(); }); }else{ collapse.setAttribute('data-visible', 'false'); @@ -151,26 +210,27 @@ angular.module('requirementsBazaarWebFrontendApp') console.log(message); if(message.id === 'undefined'){ $scope.toastText = 'Warning: Component was not created !'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }else { $scope.toastText = 'Component was created'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); - //The component is added to be the first element + //The component is added to be the first element and will be active component.id = message.id; $scope.activeComponent = component; $scope.components.splice(0, 0, $scope.activeComponent); + $scope.selectComp($scope.activeComponent); $scope.clearComponentSubmit(); } }) .error(function (error) { console.log(error.message); $scope.toastText = 'Warning: Component was not created !'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }); }else{ $scope.toastText = 'Provide a name & description for the component'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); } }; $scope.clearComponentSubmit = function(){ @@ -191,9 +251,9 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.deleteComponent($scope.activeProject.id,$scope.activeComponent.id) .success(function (message) { console.log(message); - if(message.success !== "true"){ + if(message.success !== 'true'){ $scope.toastText = 'Warning: Component was not deleted !'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }else { for (var i = 0; i < $scope.components.length; i++) { if ($scope.components[i].id === $scope.activeComponent.id) { @@ -206,13 +266,13 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.activeComponent = $scope.components[0]; } $scope.toastText = 'Component deleted'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); } }) .error(function (error) { console.log(error.message); $scope.toastText = 'Warning: Component was not deleted !'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }); }; @@ -235,10 +295,10 @@ angular.module('requirementsBazaarWebFrontendApp') console.log(message); if(message.id === 'undefined'){ $scope.toastText = 'Warning: Requirement was not created !'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }else{ $scope.toastText = 'Requirement was created'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); //Add missing values to the newly created requirement requirement.id = message.id; @@ -260,13 +320,13 @@ angular.module('requirementsBazaarWebFrontendApp') //This method only catches network errors console.log(error.message); $scope.toastText = 'Warning: Requirement was not created !'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }); $scope.showCreateReqDiv = false; }else{ $scope.toastText = 'Provide a name & description for the requirement'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); } }; $scope.clearReqSubmit = function(){ @@ -278,9 +338,9 @@ angular.module('requirementsBazaarWebFrontendApp') console.log('delete requirement'); reqBazService.deleteRequirement(req.id) .success(function (message) { - if(message.success !== "true"){ + if(message.success !== 'true'){ $scope.toastText = 'Warning: Requirement was not deleted'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }else{ // Delete the removed requirement from the list for(var i = 0; i<$scope.requirements.length;i++){ @@ -290,22 +350,25 @@ angular.module('requirementsBazaarWebFrontendApp') } } $scope.toastText = 'Requirement deleted'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); } }) .error(function (error) { - //This error only catches network errors + //This error only catches unknown server errors, usual errorCodes are sent with success message console.log(error.message); $scope.toastText = 'Warning: Requirement was not deleted'; - document.getElementById("feedbackToast").show(); + document.getElementById('feedbackToast').show(); }); }; - + /* + * Shows or hides additional requirement functions + * Called: User clicks more-vert on requirement + * */ $scope.showMoreClicked = function ($index) { - if($scope.selectedIndex == $index){ + if($scope.selectedIndex === $index){ $scope.selectedIndex = -1; }else{ $scope.selectedIndex = $index; @@ -327,22 +390,12 @@ angular.module('requirementsBazaarWebFrontendApp') }) .error(function (error) { console.log(error.message); - alert('Something went wrong, please try again'); + $scope.toastText = 'Warning: could not register as a follower'; + document.getElementById('feedbackToast').show(); }); }; - $scope.signOut = function(){ - window.alert('TODO sign out'); - }; - - $scope.editProfile = function(){ - window.alert('TODO'); - }; - - //Call the init functions - getProjects(); - }); diff --git a/app/styles/main.css b/app/styles/main.css index 5a2d29e1..4cbc7638 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -94,6 +94,18 @@ body { box-shadow: 0 2px 10px rgba(0,0,0,.2); } +#loadRequirements{ + display: block; + margin-left: auto; + margin-right: auto; + width: 40%; +} + +#loadComponents{ + display: block; +} + + /* CSS rules that apply to all core-elements diff --git a/app/views/main.html b/app/views/main.html index 59d79e32..4f3cc557 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -27,10 +27,6 @@

{{activeUser.email}}

Is admin : {{activeUser.admin}}

-
- Edit - Sign Out -
@@ -72,6 +68,9 @@ {{component.name}} + + Reload +
@@ -94,6 +93,8 @@

+ Reload +
From d443a0c2e01797b84e362673256aef9bf23dc3cd Mon Sep 17 00:00:00 2001 From: Kristjan Date: Sun, 18 Jan 2015 18:32:26 +0100 Subject: [PATCH 11/28] User can now add new Projects. Refactored the user feedback. --- app/scripts/controllers/main.js | 118 ++++++++++++++++++++------------ app/styles/main.css | 19 +++-- app/views/main.html | 49 +++++++++---- 3 files changed, 121 insertions(+), 65 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 11159f5e..01f855ff 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -54,8 +54,7 @@ angular.module('requirementsBazaarWebFrontendApp') } }) .error(function () { - $scope.toastText = 'Could not load projects, please reload !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Could not load projects, please reload !'); }); })(); @@ -78,8 +77,7 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.activeComponent = null; $scope.requirements = null; $scope.selectedIndex = -1; - $scope.toastText = 'Could not load components'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Could not load components'); //Show the reload requirements button $scope.reloadComponents = true; @@ -100,9 +98,7 @@ angular.module('requirementsBazaarWebFrontendApp') .success(function (reqs) { $scope.requirements = reqs; if($scope.requirements.length === 0){ - //Since there are none, offer user to create new one - $scope.toastText = 'This component has no requirements, feel free to create'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback( 'This component has no requirements, feel free to create'); }else{ //Show the requirements for(var i = 0; i<$scope.requirements.length;i++){ @@ -122,8 +118,7 @@ angular.module('requirementsBazaarWebFrontendApp') //Null the list, otherwise user will see wrong requirements $scope.requirements = null; $scope.selectedIndex = -1; - $scope.toastText = 'Could not load requirements'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Could not load requirements'); //Show the reload requirements button $scope.reloadRequirements = true; @@ -151,8 +146,7 @@ angular.module('requirementsBazaarWebFrontendApp') if(purpose === 'project'){ $scope.projectLeader = null; } - $scope.toastText = 'Could not load user for: '+purpose; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Could not load user for: '+purpose); }); } @@ -178,8 +172,7 @@ angular.module('requirementsBazaarWebFrontendApp') req.contributors = requirement.contributors; }) .error(function () { - $scope.toastText = 'Warning: the requirement was not loaded !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: the requirement was not loaded !'); }); }else{ collapse.setAttribute('data-visible', 'false'); @@ -190,6 +183,48 @@ angular.module('requirementsBazaarWebFrontendApp') }; + /* + * Everything related to creating or deleting a project + * + * */ + + $scope.showCreateProjectDiv = false; + $scope.newProjectName = ''; + $scope.newProjectDesc = ''; + $scope.submitProject = function(){ + if($scope.newProjectName !== '' && $scope.newProjectDesc !== ''){ + console.log('submit new project'); + var project = {description: $scope.newProjectDesc, name: $scope.newProjectName, visibility: 'PUBLIC', leaderId: 1}; + reqBazService.createProject(project) + .success(function (message) { + console.log(message); + if(message.id === 'undefined'){ + $scope.showFeedback('Warning: Project was not created !'); + }else { + $scope.showFeedback('Project was created'); + + //The project is added to be the first element and will be active + project.id = message.id; + $scope.activeProject = project; + $scope.projects.splice(0, 0, $scope.activeProject); + $scope.selectProj($scope.activeComponent); + $scope.clearProjectSubmit(); + } + }) + .error(function (error) { + console.log(error.message); + $scope.showFeedback('Warning: Project was not created !'); + }); + }else{ + $scope.showFeedback('Provide a name & description for the Project'); + } + }; + $scope.clearProjectSubmit = function(){ + $scope.newProjectName = ''; + $scope.newProjectDesc = ''; + $scope.showCreateProjectDiv = false; + }; + /* * Everything related to creating or deleting a new component @@ -209,11 +244,9 @@ angular.module('requirementsBazaarWebFrontendApp') .success(function (message) { console.log(message); if(message.id === 'undefined'){ - $scope.toastText = 'Warning: Component was not created !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: Component was not created !'); }else { - $scope.toastText = 'Component was created'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Component was created'); //The component is added to be the first element and will be active component.id = message.id; @@ -225,12 +258,10 @@ angular.module('requirementsBazaarWebFrontendApp') }) .error(function (error) { console.log(error.message); - $scope.toastText = 'Warning: Component was not created !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: Component was not created !'); }); }else{ - $scope.toastText = 'Provide a name & description for the component'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Provide a name & description for the component'); } }; $scope.clearComponentSubmit = function(){ @@ -252,8 +283,7 @@ angular.module('requirementsBazaarWebFrontendApp') .success(function (message) { console.log(message); if(message.success !== 'true'){ - $scope.toastText = 'Warning: Component was not deleted !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: Component was not deleted !'); }else { for (var i = 0; i < $scope.components.length; i++) { if ($scope.components[i].id === $scope.activeComponent.id) { @@ -265,14 +295,12 @@ angular.module('requirementsBazaarWebFrontendApp') if ($scope.components !== null) { $scope.activeComponent = $scope.components[0]; } - $scope.toastText = 'Component deleted'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Component deleted'); } }) .error(function (error) { console.log(error.message); - $scope.toastText = 'Warning: Component was not deleted !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: Component was not deleted !'); }); }; @@ -286,7 +314,7 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.showCreateReqDiv = false; $scope.newReqName = ''; $scope.newReqDesc = ''; - $scope.submitNewReq = function(){ + $scope.submitReq = function(){ if($scope.newReqName !== '' && $scope.newReqDesc !== ''){ console.log('submit requirement'); var requirement = {title: $scope.newReqName, description: $scope.newReqDesc, projectId: $scope.activeProject.id, leadDeveloperId : 1, creatorId : 1}; @@ -294,11 +322,9 @@ angular.module('requirementsBazaarWebFrontendApp') .success(function (message) { console.log(message); if(message.id === 'undefined'){ - $scope.toastText = 'Warning: Requirement was not created !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: Requirement was not created !'); }else{ - $scope.toastText = 'Requirement was created'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Requirement was created'); //Add missing values to the newly created requirement requirement.id = message.id; @@ -317,16 +343,14 @@ angular.module('requirementsBazaarWebFrontendApp') } }) .error(function (error) { - //This method only catches network errors + //This error only catches unknown server errors, usual errorCodes are sent with success message console.log(error.message); - $scope.toastText = 'Warning: Requirement was not created !'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: Requirement was not created !'); }); $scope.showCreateReqDiv = false; }else{ - $scope.toastText = 'Provide a name & description for the requirement'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Provide a name & description for the requirement'); } }; $scope.clearReqSubmit = function(){ @@ -339,8 +363,7 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.deleteRequirement(req.id) .success(function (message) { if(message.success !== 'true'){ - $scope.toastText = 'Warning: Requirement was not deleted'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Warning: Requirement was not deleted'); }else{ // Delete the removed requirement from the list for(var i = 0; i<$scope.requirements.length;i++){ @@ -349,15 +372,13 @@ angular.module('requirementsBazaarWebFrontendApp') break; } } - $scope.toastText = 'Requirement deleted'; - document.getElementById('feedbackToast').show(); + $scope.showFeedback('Requirement deleted'); } }) .error(function (error) { //This error only catches unknown server errors, usual errorCodes are sent with success message - console.log(error.message); - $scope.toastText = 'Warning: Requirement was not deleted'; - document.getElementById('feedbackToast').show(); + console.log(error); + $scope.showFeedback('Warning: Requirement was not deleted'); }); }; @@ -376,6 +397,15 @@ angular.module('requirementsBazaarWebFrontendApp') }; + /* + * Shows feedback to the user + * Called: automatic + * */ + $scope.showFeedback = function(text){ + $scope.toastText = text; + document.getElementById('feedbackToast').show(); + }; + /** * * Function calls that currently don't do anything or don't work diff --git a/app/styles/main.css b/app/styles/main.css index 4cbc7638..e97ea857 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -81,18 +81,24 @@ body { border-radius: 50%; background: #db4437; } -#addRequirementDiv{ - width: 400px; - right: 130px; - position: fixed; +.addItemDiv{ background-color: white; - z-index: 2; - bottom: 0; + width: 400px; padding: 10px; + margin-left: 5px; border: 1px solid #ccc; border-color: rgba(0,0,0,.2); box-shadow: 0 2px 10px rgba(0,0,0,.2); } +#createContainer{ + z-index: 2; + width: 900px; + right: 130px; + bottom: 0; + position: fixed; + display: flex; + flex-direction: row-reverse; +} #loadRequirements{ display: block; @@ -106,6 +112,7 @@ body { } + /* CSS rules that apply to all core-elements diff --git a/app/views/main.html b/app/views/main.html index 4f3cc557..f58bb655 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -11,7 +11,9 @@ + + New project @@ -155,22 +157,39 @@

-
-

Add requirement

- - - - - - - - - - - - -
+
+
+

Add requirement

+ + + + + + + + + + + + +
+
+

Create Project

+ + + + + + + + + + + + +
+
From a5cc7df027c263f364230b5b6fbb08de45915936 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Mon, 19 Jan 2015 01:37:22 +0100 Subject: [PATCH 12/28] New confirmation dialog. Added a button to delete projects. Deletion of projects and components is now under the same function. --- app/index.html | 1 + app/scripts/controllers/main.js | 39 +++++++++++++++++++++++---------- app/styles/main.css | 10 --------- app/views/main.html | 11 +++++----- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/app/index.html b/app/index.html index 1016d118..a31dc89a 100644 --- a/app/index.html +++ b/app/index.html @@ -40,6 +40,7 @@ + diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 01f855ff..fe6c8a56 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -25,18 +25,17 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.activeComponent = null; //Variables for confirming deleting a object - $scope.warningText = 'Confirm deletion !'; - $scope.warningVisible = false; + $scope.confirmationDesc = 'The action cannot be undone !'; //In case loading requirements/components fails, show a reload button $scope.reloadRequirements = false; $scope.reloadComponents = false; - //Only one toast is used for feedback, toastText holds the description $scope.toastText = ''; - + //Is used to identify what needs to be deleted after used confirmed it. project, component etc + var confirmDeletionObject = ''; /* * Loads projects and then components ... @@ -224,6 +223,28 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.newProjectDesc = ''; $scope.showCreateProjectDiv = false; }; + $scope.initDeleteProject = function(){ + $scope.confirmationDesc = 'The action cannot be undone. Deleting a project also removes all components and requirements !'; + confirmDeletionObject = 'project'; + document.getElementById('confirmationDialog').toggle(); + }; + $scope.deleteProject = function(){ + console.log('delete project confirmed'); + //TODO delete the project + }; + + //TODO move this and write doc + $scope.confirmDelete = function(){ + if(confirmDeletionObject === 'project'){ + confirmDeletionObject = ''; + $scope.deleteProject(); + } + if(confirmDeletionObject === 'component'){ + confirmDeletionObject = ''; + $scope.deleteComponent(); + } + }; + /* @@ -270,15 +291,11 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.showCreateCompDiv = false; }; $scope.initDeleteComponent = function () { - $scope.warningText = 'Confirm deleting the component !'; - $scope.warningVisible = true; - }; - $scope.resetDeleteComponent = function(){ - $scope.warningText = 'Confirm deletion !'; - $scope.warningVisible = false; + $scope.confirmationDesc = 'The action cannot be undone. The requirements will be accessible under the default component.'; + confirmDeletionObject = 'component'; + document.getElementById('confirmationDialog').toggle(); }; $scope.deleteComponent = function(){ - $scope.resetDeleteComponent(); reqBazService.deleteComponent($scope.activeProject.id,$scope.activeComponent.id) .success(function (message) { console.log(message); diff --git a/app/styles/main.css b/app/styles/main.css index e97ea857..53df4cc6 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -1,14 +1,4 @@ -#deleteSomething{ - position: fixed; - z-index: 12; - top: 0; - left: 8px; - right: 8px; - margin:32px; - background: white; -} - body { font-family: sans-serif; background-color: #ececec; diff --git a/app/views/main.html b/app/views/main.html index f58bb655..63556779 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -11,6 +11,7 @@ + New project @@ -148,12 +149,10 @@

- - -

{{warningText}}

- Decline - Accept -
+ +

{{confirmationDesc}}

+ Decline + Accept
From c979f8d15579ef57f1488083e349e8f26eff1fc4 Mon Sep 17 00:00:00 2001 From: Kristjan Date: Tue, 20 Jan 2015 15:53:21 +0100 Subject: [PATCH 13/28] Bugfix - mistake in the UI and moved code. --- app/scripts/controllers/main.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index fe6c8a56..1f6f2525 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -206,7 +206,7 @@ angular.module('requirementsBazaarWebFrontendApp') project.id = message.id; $scope.activeProject = project; $scope.projects.splice(0, 0, $scope.activeProject); - $scope.selectProj($scope.activeComponent); + $scope.selectProj($scope.activeProject); $scope.clearProjectSubmit(); } }) @@ -231,21 +231,9 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.deleteProject = function(){ console.log('delete project confirmed'); //TODO delete the project + $scope.showFeedback('This feature is currently under discussion'); }; - //TODO move this and write doc - $scope.confirmDelete = function(){ - if(confirmDeletionObject === 'project'){ - confirmDeletionObject = ''; - $scope.deleteProject(); - } - if(confirmDeletionObject === 'component'){ - confirmDeletionObject = ''; - $scope.deleteComponent(); - } - }; - - /* * Everything related to creating or deleting a new component @@ -259,7 +247,6 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.submitNewComponent = function(){ if($scope.newCompName !== ''){ console.log('submit new component'); - //TODO leaderId is not used, as there is no user management yet var component = {description: $scope.newCompDesc, name: $scope.newCompName, leaderId: 1, projectId: $scope.activeProject.id}; reqBazService.createComponent($scope.activeProject.id,component) .success(function (message) { @@ -401,6 +388,21 @@ angular.module('requirementsBazaarWebFrontendApp') + /* + * Confirmation dialog switch. Only one is used so a variable manages what is currently being deleted + * Called: When the user confirms to delete an element + * */ + $scope.confirmDelete = function(){ + if(confirmDeletionObject === 'project'){ + confirmDeletionObject = ''; + $scope.deleteProject(); + } + if(confirmDeletionObject === 'component'){ + confirmDeletionObject = ''; + $scope.deleteComponent(); + } + }; + /* * Shows or hides additional requirement functions * Called: User clicks more-vert on requirement From cb8e313c39dadda1f6d9f0e3882b33902010e9bd Mon Sep 17 00:00:00 2001 From: Kristjan Date: Thu, 22 Jan 2015 14:54:59 +0100 Subject: [PATCH 14/28] Bugfix - fixed the error logs --- app/scripts/controllers/main.js | 10 +++++----- app/styles/main.css | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 1f6f2525..5893a680 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -211,7 +211,7 @@ angular.module('requirementsBazaarWebFrontendApp') } }) .error(function (error) { - console.log(error.message); + console.log(error); $scope.showFeedback('Warning: Project was not created !'); }); }else{ @@ -265,7 +265,7 @@ angular.module('requirementsBazaarWebFrontendApp') } }) .error(function (error) { - console.log(error.message); + console.log(error); $scope.showFeedback('Warning: Component was not created !'); }); }else{ @@ -303,7 +303,7 @@ angular.module('requirementsBazaarWebFrontendApp') } }) .error(function (error) { - console.log(error.message); + console.log(error); $scope.showFeedback('Warning: Component was not deleted !'); }); }; @@ -348,7 +348,7 @@ angular.module('requirementsBazaarWebFrontendApp') }) .error(function (error) { //This error only catches unknown server errors, usual errorCodes are sent with success message - console.log(error.message); + console.log(error); $scope.showFeedback('Warning: Requirement was not created !'); }); @@ -438,7 +438,7 @@ angular.module('requirementsBazaarWebFrontendApp') console.log(message); }) .error(function (error) { - console.log(error.message); + console.log(error); $scope.toastText = 'Warning: could not register as a follower'; document.getElementById('feedbackToast').show(); }); diff --git a/app/styles/main.css b/app/styles/main.css index 53df4cc6..a0621ff1 100644 --- a/app/styles/main.css +++ b/app/styles/main.css @@ -55,7 +55,6 @@ body { } #profileDivFooter paper-button{ - /*background-color: #669900;*/ color: white; } From 3753aa2683a5451bd2d5431eb2e36af46113b76f Mon Sep 17 00:00:00 2001 From: Kristjan Date: Fri, 23 Jan 2015 01:21:49 +0100 Subject: [PATCH 15/28] It is now possible to leave comment, but currently only as user 1. Fixed a layout issue with sidebar, and better error catching. --- app/scripts/controllers/main.js | 56 ++++++++++++++++++++++++++++++--- app/views/main.html | 53 +++++++++++++++++++++---------- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/app/scripts/controllers/main.js b/app/scripts/controllers/main.js index 5893a680..f2866167 100644 --- a/app/scripts/controllers/main.js +++ b/app/scripts/controllers/main.js @@ -17,6 +17,7 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.components = null; $scope.requirements = null; $scope.activeUser = {id : '2', firstname : 'Max2', lastname : 'Mustermann2', email : 'Max@Mustermann2.de', admin : 'true', Las2PeerId :'2'}; + $scope.myComments = []; $scope.projectLeader = null; $scope.componentLeader = null; @@ -108,7 +109,6 @@ angular.module('requirementsBazaarWebFrontendApp') $scope.requirements[i].developers = []; $scope.requirements[i].contributors = []; $scope.requirements[i].attachments = []; - $scope.requirements[i].comments = []; $scope.requirements[i].components = []; } } @@ -169,6 +169,9 @@ angular.module('requirementsBazaarWebFrontendApp') req.followers = requirement.followers; req.developers = requirement.developers; req.contributors = requirement.contributors; + + //Load comments + $scope.getComments(req.id); }) .error(function () { $scope.showFeedback('Warning: the requirement was not loaded !'); @@ -197,7 +200,7 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.createProject(project) .success(function (message) { console.log(message); - if(message.id === 'undefined'){ + if(message.hasOwnProperty('errorCode')){ $scope.showFeedback('Warning: Project was not created !'); }else { $scope.showFeedback('Project was created'); @@ -251,7 +254,7 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.createComponent($scope.activeProject.id,component) .success(function (message) { console.log(message); - if(message.id === 'undefined'){ + if(message.hasOwnProperty('errorCode')){ $scope.showFeedback('Warning: Component was not created !'); }else { $scope.showFeedback('Component was created'); @@ -325,7 +328,7 @@ angular.module('requirementsBazaarWebFrontendApp') reqBazService.createRequirement($scope.activeProject.id,$scope.activeComponent.id,requirement) .success(function (message) { console.log(message); - if(message.id === 'undefined'){ + if(message.hasOwnProperty('errorCode')){ $scope.showFeedback('Warning: Requirement was not created !'); }else{ $scope.showFeedback('Requirement was created'); @@ -338,7 +341,6 @@ angular.module('requirementsBazaarWebFrontendApp') requirement.developers = []; requirement.contributors = []; requirement.attachments = []; - requirement.comments = []; requirement.components = []; //Add the requirement to the first position @@ -416,6 +418,50 @@ angular.module('requirementsBazaarWebFrontendApp') }; + + /* + * Everything related to comments + * + * */ + $scope.getComments = function(id){ + reqBazService.getComments(id,0,30) + .success(function (comments) { + $scope.myComments = comments; + }) + .error(function (error) { + //This error only catches unknown server errors, usual errorCodes are sent with success message + console.log(error); + $scope.showFeedback('Warning: Could not get comments'); + }); + }; + $scope.submitComment = function(text,id){ + console.log('post comment: '+text); + if(text === undefined){ + $scope.showFeedback('Comment cannot be empty'); + }else{ + // user 1 is the current anon user + var comment = {requirementId: id, message: text, creatorId: 1}; + reqBazService.createComment(id,comment) + .success(function (message) { + console.log(message); + if(message.hasOwnProperty('errorCode')){ + $scope.showFeedback('Warning: Comment was not posted !'); + }else{ + comment.id = message.id; + //Instead of making a new server, I just approximate + comment.creation_time = Date(); + $scope.myComments.splice(0, 0, comment); + } + }) + .error(function (error) { + //This error only catches unknown server errors, usual errorCodes are sent with success message + console.log(error); + $scope.showFeedback('Warning: Comment was not posted'); + }); + } + }; + + /* * Shows feedback to the user * Called: automatic diff --git a/app/views/main.html b/app/views/main.html index 63556779..e86a143f 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -47,7 +47,7 @@
-