Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/abstractIdeaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ app.controller('AbstractIdeaController', function ($controller, $scope, FeatureP

$scope.clearOverallCheckbox = function () {
var overallCheckbox = angular.element('#overallCheckbox')[0];
overallCheckbox.indeterminate = false;
overallCheckbox.checked = false;
if(overallCheckbox) {
overallCheckbox.indeterminate = false;
overallCheckbox.checked = false;
}
};

$scope.createFeatureProposal = function () {
Expand Down
56 changes: 29 additions & 27 deletions app/controllers/featureProposalController.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
app.controller('FeatureProposalController', function ($controller, $scope, Idea, FeatureProposal, FeatureProposalRepo, ProjectService) {
app.controller('FeatureProposalController', function($controller, $scope, Idea, FeatureProposal, ProjectService) {

angular.extend(this, $controller('AbstractIdeaController', {
$scope: $scope
}));

$scope.repo = FeatureProposalRepo;

$scope.fpToDelete = {};

$scope.ideaToAdd = {};

$scope.tableConfig = {
properties: [
{
$scope.weaverTable = {
repo: $scope.fpRepo,
columns: [{
gloss: 'Service',
property: 'service.name',
filterable: true,
Expand All @@ -28,6 +26,12 @@ app.controller('FeatureProposalController', function ($controller, $scope, Idea,
gloss: 'Description',
property: 'description',
filterable: true,
sortable: false
},
{
gloss: 'Last Modified',
property: 'lastModified',
filterable: true,
sortable: true
},
{
Expand All @@ -37,14 +41,12 @@ app.controller('FeatureProposalController', function ($controller, $scope, Idea,
sortable: true
},
{
gloss: 'Last Modified',
property: 'lastModified',
filterable: true,
sortable: true
gloss: 'Actions',
filterable: false,
sortable: false
}
],
activeSort: [
{
activeSort: [{
property: 'service.name',
direction: 'ASC'
},
Expand All @@ -57,29 +59,29 @@ app.controller('FeatureProposalController', function ($controller, $scope, Idea,

$scope.removedIdeas = [];

$scope.tableParams = FeatureProposalRepo.getTableParams();
$scope.tableParams = $scope.fpRepo.getTableParams();

$scope.editFeatureProposal = function (fp) {
$scope.editFeatureProposal = function(fp) {
$scope.fpData = fp;
$scope.openModal('#editFpModal');
};

$scope.removeIdea = function (idea) {
if ($scope.fpData.ideas.some(function (i) {
return i.id === idea.id;
})) {
$scope.removeIdea = function(idea) {
if ($scope.fpData.ideas.some(function(i) {
return i.id === idea.id;
})) {
$scope.removedIdeas.push(new Idea(idea));
$scope.forms.updateFp.$setDirty();
$scope.fpData.dirty(true);
$scope.fpData.ideas.splice($scope.fpData.ideas.indexOf(idea), 1);
}
};

$scope.updateFeatureProposal = function (fp) {
FeatureProposalRepo.update($scope.fpData).then(function (res) {
$scope.updateFeatureProposal = function(fp) {
$scope.fpRepo.update($scope.fpData).then(function(res) {
if (angular.fromJson(res.body).meta.status === 'SUCCESS') {
$scope.resetFeatureProposals();
for(var i in $scope.removedIdeas) {
for (var i in $scope.removedIdeas) {
var idea = $scope.removedIdeas[i];
idea.elevated = false;
idea.save();
Expand All @@ -89,27 +91,27 @@ app.controller('FeatureProposalController', function ($controller, $scope, Idea,
});
};

$scope.select = function (fp, modal) {
$scope.select = function(fp, modal) {
$scope.fpData = fp;
$scope.openModal(modal);
};

$scope.submitFeatureProposal = function (fp) {
$scope.submitFeatureProposal = function(fp) {
$scope.submitting = true;
ProjectService.submitFeatureProposal(fp).then(function () {
ProjectService.submitFeatureProposal(fp).then(function() {
$scope.submitting = false;
$scope.resetFeatureProposals();
});
};

$scope.confirmDeleteFp = function (fp) {
$scope.confirmDeleteFp = function(fp) {
$scope.openModal('#deleteFpModal');
$scope.fpToDelete = fp;
};

$scope.deleteFp = function () {
$scope.deleteFp = function() {
$scope.deleting = true;
$scope.fpToDelete.delete().then(function () {
$scope.fpToDelete.delete().then(function() {
$scope.closeModal();
$scope.deleting = false;
$scope.fpToDelete = {};
Expand Down
65 changes: 34 additions & 31 deletions app/controllers/ideaController.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
app.controller('IdeaController', function ($controller, $scope, $timeout, FeatureProposalRepo, Idea, IdeaRepo, ServiceRepo) {
app.controller('IdeaController', function($controller, $scope, $timeout, FeatureProposalRepo, Idea, ServiceRepo) {

angular.extend(this, $controller('AbstractIdeaController', {
$scope: $scope
}));

$scope.repo = IdeaRepo;

$scope.ideaToDelete = {};

$scope.tableConfig = {
properties: [
{
$scope.weaverTable = {
repo: $scope.ideaRepo,
columns: [{
gloss: 'Service',
property: 'service.name',
filterable: true,
Expand All @@ -22,6 +20,12 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
filterable: true,
sortable: true
},
{
gloss: 'Description',
property: 'description',
filterable: true,
sortable: false
},
{
gloss: 'Last Modified',
property: 'lastModified',
Expand All @@ -35,8 +39,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
sortable: true
}
],
activeSort: [
{
activeSort: [{
property: 'service.name',
direction: 'ASC'
},
Expand All @@ -47,11 +50,11 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
]
};

ServiceRepo.ready().then(function () {
ServiceRepo.ready().then(function() {

$scope.tableParams = IdeaRepo.getTableParams();
$scope.tableParams = $scope.ideaRepo.getTableParams();

$scope.resetIdeas = function () {
$scope.resetIdeas = function() {
$scope.resetForms($scope.ideaData);
$scope.ideaData = new Idea({
title: '',
Expand All @@ -65,48 +68,48 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur

});

$scope.createIdea = function () {
$scope.createIdea = function() {
$scope.creating = true;
IdeaRepo.create($scope.ideaData).then(function (res) {
$scope.ideaRepo.create($scope.ideaData).then(function(res) {
if (angular.fromJson(res.body).meta.status === 'SUCCESS') {
$scope.creating = false;
$scope.resetIdeas();
}
});
};

$scope.editIdea = function (idea) {
$scope.editIdea = function(idea) {
$scope.ideaData = idea;
$scope.openModal('#editIdeaModal');
};

$scope.updateIdea = function () {
$scope.updateIdea = function() {
$scope.updating = true;
IdeaRepo.update($scope.ideaData).then(function (res) {
$scope.ideaRepo.update($scope.ideaData).then(function(res) {
if (angular.fromJson(res.body).meta.status === 'SUCCESS') {
$scope.updating = false;
$scope.resetIdeas();
}
});
};

$scope.confirmDelete = function (idea) {
$scope.confirmDelete = function(idea) {
$scope.openModal('#deleteIdeaModal');
$scope.ideaToDelete = idea;
};

$scope.deleteIdea = function () {
$scope.deleteIdea = function() {
$scope.deleting = true;
$scope.ideaToDelete.delete().then(function () {
$scope.ideaToDelete.delete().then(function() {
$scope.closeModal();
$scope.deleting = false;
$scope.ideaToDelete = {};
});
};

$scope.elevateIdea = function (idea) {
$scope.elevateIdea = function(idea) {
$scope.elevating = true;
FeatureProposalRepo.elevate(idea).then(function (res) {
FeatureProposalRepo.elevate(idea).then(function(res) {
var apiRes = angular.fromJson(res.body);
if (apiRes.meta.status === 'SUCCESS') {
$scope.elevating = false;
Expand All @@ -115,7 +118,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
});
};

$scope.setOverallCheckbox = function () {
$scope.setOverallCheckbox = function() {
var overallCheckbox = angular.element('#overallCheckbox')[0];
if ($scope.selectedIdeas.length === 0) {
overallCheckbox.indeterminate = false;
Expand All @@ -129,7 +132,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
}
};

$scope.toggleSelectIdea = function (idea) {
$scope.toggleSelectIdea = function(idea) {
if ($scope.isSelectedIdea(idea)) {
$scope.removeIdeaFromSelected(idea);
} else {
Expand All @@ -138,7 +141,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
$scope.setOverallCheckbox();
};

$scope.toggleAll = function () {
$scope.toggleAll = function() {
if ($scope.overallCheckboxValue || $scope.anyOnPageSelected()) {
for (var i in $scope.ideasTableParams.data) {
var ii = $scope.ideasTableParams.data[i];
Expand All @@ -157,7 +160,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
$scope.setOverallCheckbox();
};

$scope.anyOnPageSelected = function () {
$scope.anyOnPageSelected = function() {
var anySelected = false;
for (var i in $scope.ideasTableParams.data) {
var idea = $scope.ideasTableParams.data[i];
Expand All @@ -169,7 +172,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
return anySelected;
};

$scope.isSelectedIdea = function (idea) {
$scope.isSelectedIdea = function(idea) {
var selected = false;
for (var i in $scope.selectedIdeas) {
if (idea.id === $scope.selectedIdeas[i].id) {
Expand All @@ -180,7 +183,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
return selected;
};

$scope.removeIdeaFromSelected = function (idea) {
$scope.removeIdeaFromSelected = function(idea) {
for (var i in $scope.selectedIdeas) {
if (idea.id === $scope.selectedIdeas[i].id) {
$scope.selectedIdeas.splice(i, 1);
Expand All @@ -189,20 +192,20 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
}
};

$scope.confirmElevateMultiple = function (ideas) {
$scope.confirmElevateMultiple = function(ideas) {
$scope.fpData.ideas = ideas;
$scope.fpData.title = ideas[0].title;
$scope.fpData.description = ideas[0].description;
$scope.fpData.service = ideas[0].service;
$scope.openModal('#elevateMultipleModal');
};

$scope.confirmAddIdea = function (idea) {
$scope.confirmAddIdea = function(idea) {
$scope.ideaToAdd = idea;
$scope.openModal('#confirmAddIdeaModal');
};

$scope.addIdea = function (fp) {
$scope.addIdea = function(fp) {
fp.ideas.push($scope.ideaToAdd);
fp.dirty(true);
$scope.updateFeatureProposal(fp);
Expand All @@ -211,7 +214,7 @@ app.controller('IdeaController', function ($controller, $scope, $timeout, Featur
$scope.ideaToAdd = {};
};

$scope.setSelectedFp = function (fp) {
$scope.setSelectedFp = function(fp) {
$scope.selectedFp = fp;
};

Expand Down
Loading