-
{{ lane.worklist.title }}
+
+ {{ lane.worklist.title }}
+
diff --git a/src/app/worklists/controller/add_worklist_controller.js b/src/app/worklists/controller/add_worklist_controller.js
index 63f26c27..0040c048 100644
--- a/src/app/worklists/controller/add_worklist_controller.js
+++ b/src/app/worklists/controller/add_worklist_controller.js
@@ -119,4 +119,5 @@ angular.module('sb.worklist').controller('AddWorklistController',
$scope.resourceTypes = ['Story'];
$scope.showAddFilter = true;
$scope.newFilter = angular.copy(blankFilter);
+ $scope.modalTitle = 'New Worklist';
});
diff --git a/src/app/worklists/controller/worklist_edit_controller.js b/src/app/worklists/controller/worklist_edit_controller.js
new file mode 100644
index 00000000..c2e79422
--- /dev/null
+++ b/src/app/worklists/controller/worklist_edit_controller.js
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2015-2016 Codethink Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Controller for the "new worklist" modal popup.
+ */
+angular.module('sb.worklist').controller('WorklistEditController',
+ function ($scope, $modalInstance, $state, worklist, board, Worklist) {
+ 'use strict';
+
+ var blankFilter = {
+ type: 'Story',
+ filter_criteria: [{
+ negative: false,
+ field: null,
+ value: null,
+ title: null
+ }]
+ };
+
+ /**
+ * Saves the worklist.
+ */
+ $scope.save = function () {
+ $scope.isSaving = true;
+ Worklist.update($scope.worklist, function () {
+ $scope.isSaving = false;
+ $modalInstance.dismiss('success');
+ });
+ };
+
+ /**
+ * Close this modal without saving.
+ */
+ $scope.close = function () {
+ $modalInstance.dismiss('cancel');
+ };
+
+ $scope.setType = function(type) {
+ $scope.newFilter.type = type;
+ $scope.resourceTypes = [type];
+ $scope.$broadcast('refresh-types');
+ };
+
+ $scope.setCriterion = function(criterion, tag) {
+ criterion.field = tag.type;
+ criterion.value = tag.value.toString();
+ criterion.title = tag.title;
+ };
+
+ $scope.addCriterion = function(filter) {
+ filter.filter_criteria.push({
+ negative: false,
+ field: null,
+ value: null,
+ title: null
+ });
+ };
+
+ $scope.removeTag = function(criterion) {
+ if ($scope.newFilter.filter_criteria.length > 1) {
+ var idx = $scope.newFilter.filter_criteria.indexOf(criterion);
+ $scope.newFilter.filter_criteria.splice(idx, 1);
+ } else {
+ criterion.field = null;
+ criterion.value = null;
+ criterion.title = null;
+ }
+ };
+
+ $scope.checkNewFilter = function() {
+ var valid = true;
+ angular.forEach(
+ $scope.newFilter.filter_criteria,
+ function(criterion) {
+ if (criterion.field == null ||
+ criterion.value == null ||
+ criterion.title == null) {
+ valid = false;
+ }
+ }
+ );
+ return valid;
+ };
+
+ $scope.remove = function(filter) {
+ var idx = $scope.worklist.filters.indexOf(filter);
+ Worklist.Filters.delete({
+ id: $scope.worklist.id,
+ filter_id: filter.id
+ });
+ $scope.worklist.filters.splice(idx, 1);
+ };
+
+ $scope.saveNewFilter = function() {
+ var added = angular.copy($scope.newFilter);
+ Worklist.Filters.create(
+ {id: $scope.worklist.id}, added, function(result) {
+ $scope.worklist.filters.push(result);
+ }
+ );
+ $scope.showAddFilter = false;
+ $scope.newFilter = angular.copy(blankFilter);
+ };
+
+ $scope.isSaving = false;
+ $scope.worklist = worklist;
+ $scope.resourceTypes = ['Story'];
+ $scope.showAddFilter = false;
+ $scope.newFilter = angular.copy(blankFilter);
+ $scope.modalTitle = 'Edit Worklist';
+ });
diff --git a/src/app/worklists/template/new.html b/src/app/worklists/template/new.html
index 45e8124c..e8ada232 100644
--- a/src/app/worklists/template/new.html
+++ b/src/app/worklists/template/new.html
@@ -17,7 +17,7 @@
-
New Worklist
+ {{ modalTitle }}