-
+
-
diff --git a/src/main/webapp/script/person.js b/src/main/webapp/script/issue.js
similarity index 63%
rename from src/main/webapp/script/person.js
rename to src/main/webapp/script/issue.js
index 58ecbaa..6b50401 100644
--- a/src/main/webapp/script/person.js
+++ b/src/main/webapp/script/issue.js
@@ -1,20 +1,22 @@
-var app = angular.module('persons', ['ngResource', 'ngGrid', 'ui.bootstrap']);
+var app = angular.module('issues', ['ngResource', 'ngGrid', 'ui.bootstrap']);
-// Create a controller with name personsListController to bind to the grid section.
-app.controller('personsListController', function ($scope, $rootScope, personService) {
+// Create a controller with name issuesListController to bind to the grid section.
+app.controller('issuesListController', function ($scope, $rootScope, issueService) {
// Initialize required information: sorting, the first page to show and the grid options.
$scope.sortInfo = {fields: ['id'], directions: ['asc']};
- $scope.persons = {currentPage: 1};
+ $scope.issues = {currentPage: 1};
$scope.gridOptions = {
- data: 'persons.list',
+ data: 'issues.list',
useExternalSorting: true,
sortInfo: $scope.sortInfo,
columnDefs: [
{ field: 'id', displayName: 'Id' },
- { field: 'name', displayName: 'Name' },
- { field: 'description', displayName: 'Description' },
+ { field: 'issueNum', displayName: 'Issue Number' },
+ { field: 'p1Rate', displayName: 'Party 1 Rate' },
+ { field: 'p2Rate', displayName: 'Party 2 Rate' },
+ { field: 'belongs', displayName: 'Won by party #' },
{ field: '', width: 30, cellTemplate: '
' }
],
@@ -23,33 +25,33 @@ app.controller('personsListController', function ($scope, $rootScope, personServ
// Broadcasts an event when a row is selected, to signal the form that it needs to load the row data.
afterSelectionChange: function (rowItem) {
if (rowItem.selected) {
- $rootScope.$broadcast('personSelected', $scope.gridOptions.selectedItems[0].id);
+ $rootScope.$broadcast('issueSelected', $scope.gridOptions.selectedItems[0].id);
}
}
};
// Refresh the grid, calling the appropriate rest method.
$scope.refreshGrid = function () {
- var listPersonsArgs = {
- page: $scope.persons.currentPage,
+ var listIssuesArgs = {
+ page: $scope.issues.currentPage,
sortFields: $scope.sortInfo.fields[0],
sortDirections: $scope.sortInfo.directions[0]
};
- personService.get(listPersonsArgs, function (data) {
- $scope.persons = data;
+ issueService.get(listIssuesArgs, function (data) {
+ $scope.issues = data;
})
};
// Broadcast an event when an element in the grid is deleted. No real deletion is perfomed at this point.
$scope.deleteRow = function (row) {
- $rootScope.$broadcast('deletePerson', row.entity.id);
+ $rootScope.$broadcast('deleteIssue', row.entity.id);
};
// Watch the sortInfo variable. If changes are detected than we need to refresh the grid.
// This also works for the first page access, since we assign the initial sorting in the initialize section.
$scope.$watch('sortInfo', function () {
- $scope.persons = {currentPage: 1};
+ $scope.issues = {currentPage: 1};
$scope.refreshGrid();
}, true);
@@ -60,7 +62,7 @@ app.controller('personsListController', function ($scope, $rootScope, personServ
$scope.sortInfo = sortInfo;
});
- // Picks the event broadcasted when a person is saved or deleted to refresh the grid elements with the most
+ // Picks the event broadcasted when a issue is saved or deleted to refresh the grid elements with the most
// updated information.
$scope.$on('refreshGrid', function () {
$scope.refreshGrid();
@@ -72,28 +74,25 @@ app.controller('personsListController', function ($scope, $rootScope, personServ
});
});
-// Create a controller with name personsFormController to bind to the form section.
-app.controller('personsFormController', function ($scope, $rootScope, personService) {
+// Create a controller with name issuesFormController to bind to the form section.
+app.controller('issuesFormController', function ($scope, $rootScope, issueService) {
// Clears the form. Either by clicking the 'Clear' button in the form, or when a successfull save is performed.
$scope.clearForm = function () {
- $scope.person = null;
- // For some reason, I was unable to clear field values with type 'url' if the value is invalid.
- // This is a workaroud. Needs proper investigation.
- document.getElementById('imageUrl').value = null;
+ $scope.issue = null;
// Resets the form validation state.
- $scope.personForm.$setPristine();
+ $scope.issueForm.$setPristine();
// Broadcast the event to also clear the grid selection.
$rootScope.$broadcast('clear');
};
- // Calls the rest method to save a person.
- $scope.updatePerson = function () {
- personService.save($scope.person).$promise.then(
+ // Calls the rest method to save a issue.
+ $scope.updateIssue = function () {
+ issueService.save($scope.issue).$promise.then(
function () {
// Broadcast the event to refresh the grid.
$rootScope.$broadcast('refreshGrid');
// Broadcast the event to display a save message.
- $rootScope.$broadcast('personSaved');
+ $rootScope.$broadcast('issueSaved');
$scope.clearForm();
},
function () {
@@ -102,21 +101,21 @@ app.controller('personsFormController', function ($scope, $rootScope, personServ
});
};
- // Picks up the event broadcasted when the person is selected from the grid and perform the person load by calling
+ // Picks up the event broadcasted when the issue is selected from the grid and perform the issue load by calling
// the appropiate rest service.
- $scope.$on('personSelected', function (event, id) {
- $scope.person = personService.get({id: id});
+ $scope.$on('issueSelected', function (event, id) {
+ $scope.issue = issueService.get({id: id});
});
- // Picks us the event broadcasted when the person is deleted from the grid and perform the actual person delete by
+ // Picks us the event broadcasted when the issue is deleted from the grid and perform the actual issue delete by
// calling the appropiate rest service.
- $scope.$on('deletePerson', function (event, id) {
- personService.delete({id: id}).$promise.then(
+ $scope.$on('deleteIssue', function (event, id) {
+ issueService.delete({id: id}).$promise.then(
function () {
// Broadcast the event to refresh the grid.
$rootScope.$broadcast('refreshGrid');
// Broadcast the event to display a delete message.
- $rootScope.$broadcast('personDeleted');
+ $rootScope.$broadcast('issueDeleted');
$scope.clearForm();
},
function () {
@@ -124,19 +123,25 @@ app.controller('personsFormController', function ($scope, $rootScope, personServ
$rootScope.$broadcast('error');
});
});
+
+
+ // Clears the form. Either by clicking the 'Clear' button in the form, or when a successfull save is performed.
+ $scope.resolve = function () {
+ issueService.get({id: -1});
+ };
});
// Create a controller with name alertMessagesController to bind to the feedback messages section.
app.controller('alertMessagesController', function ($scope) {
// Picks up the event to display a saved message.
- $scope.$on('personSaved', function () {
+ $scope.$on('issueSaved', function () {
$scope.alerts = [
{ type: 'success', msg: 'Record saved successfully!' }
];
});
// Picks up the event to display a deleted message.
- $scope.$on('personDeleted', function () {
+ $scope.$on('issueDeleted', function () {
$scope.alerts = [
{ type: 'success', msg: 'Record deleted successfully!' }
];
@@ -154,7 +159,7 @@ app.controller('alertMessagesController', function ($scope) {
};
});
-// Service that provides persons operations
-app.factory('personService', function ($resource) {
- return $resource('resources/persons/:id');
+// Service that provides issues operations
+app.factory('issueService', function ($resource) {
+ return $resource('resources/issues/:id');
});