|
|
@@ -25,6 +25,17 @@ define [
|
|
|
)
|
|
|
modalInstance.result.then () ->
|
|
|
$scope.tags = $scope.tags.filter (t) -> t != tag
|
|
|
+
|
|
|
+ $scope.renameTag = (tag) ->
|
|
|
+ modalInstance = $modal.open(
|
|
|
+ templateUrl: "renameTagModalTemplate"
|
|
|
+ controller: "RenameTagModalController"
|
|
|
+ resolve:
|
|
|
+ tag: () -> tag
|
|
|
+ existing_tags: () -> $scope.tags
|
|
|
+ )
|
|
|
+ modalInstance.result.then (new_name) ->
|
|
|
+ tag.name = new_name
|
|
|
|
|
|
App.controller "TagDropdownItemController", ($scope) ->
|
|
|
$scope.recalculateProjectsInTag = () ->
|
|
|
@@ -49,3 +60,75 @@ define [
|
|
|
$scope.$watch "selectedProjects", () ->
|
|
|
$scope.recalculateProjectsInTag()
|
|
|
$scope.recalculateProjectsInTag()
|
|
|
+
|
|
|
+ App.controller 'NewTagModalController', ($scope, $modalInstance, $timeout) ->
|
|
|
+ $scope.inputs =
|
|
|
+ newTagName: ""
|
|
|
+
|
|
|
+ $modalInstance.opened.then () ->
|
|
|
+ $timeout () ->
|
|
|
+ $scope.$broadcast "open"
|
|
|
+ , 200
|
|
|
+
|
|
|
+ $scope.create = () ->
|
|
|
+ $modalInstance.close($scope.inputs.newTagName)
|
|
|
+
|
|
|
+ $scope.cancel = () ->
|
|
|
+ $modalInstance.dismiss('cancel')
|
|
|
+
|
|
|
+ App.controller 'RenameTagModalController', ($scope, $modalInstance, $timeout, $http, tag, existing_tags) ->
|
|
|
+ $scope.inputs =
|
|
|
+ tagName: tag.name
|
|
|
+
|
|
|
+ $scope.state =
|
|
|
+ inflight: false
|
|
|
+ error: false
|
|
|
+
|
|
|
+ $modalInstance.opened.then () ->
|
|
|
+ $timeout () ->
|
|
|
+ $scope.$broadcast "open"
|
|
|
+ , 200
|
|
|
+
|
|
|
+ $scope.rename = () ->
|
|
|
+ name = $scope.inputs.tagName
|
|
|
+ $scope.state.inflight = true
|
|
|
+ $scope.state.error = false
|
|
|
+ $http
|
|
|
+ .post "/tag/#{tag._id}/rename", {
|
|
|
+ _csrf: window.csrfToken,
|
|
|
+ name: name
|
|
|
+ }
|
|
|
+ .success () ->
|
|
|
+ $scope.state.inflight = false
|
|
|
+ $modalInstance.close(name)
|
|
|
+ .error () ->
|
|
|
+ $scope.state.inflight = false
|
|
|
+ $scope.state.error = true
|
|
|
+
|
|
|
+ $scope.cancel = () ->
|
|
|
+ $modalInstance.dismiss('cancel')
|
|
|
+
|
|
|
+ App.controller 'DeleteTagModalController', ($scope, $modalInstance, $http, tag) ->
|
|
|
+ $scope.tag = tag
|
|
|
+ $scope.state =
|
|
|
+ inflight: false
|
|
|
+ error: false
|
|
|
+
|
|
|
+ $scope.delete = () ->
|
|
|
+ $scope.state.inflight = true
|
|
|
+ $scope.state.error = false
|
|
|
+ $http({
|
|
|
+ method: "DELETE"
|
|
|
+ url: "/tag/#{tag._id}"
|
|
|
+ headers:
|
|
|
+ "X-CSRF-Token": window.csrfToken
|
|
|
+ })
|
|
|
+ .success () ->
|
|
|
+ $scope.state.inflight = false
|
|
|
+ $modalInstance.close()
|
|
|
+ .error () ->
|
|
|
+ $scope.state.inflight = false
|
|
|
+ $scope.state.error = true
|
|
|
+
|
|
|
+ $scope.cancel = () ->
|
|
|
+ $modalInstance.dismiss('cancel')
|