<commit_before>define [
	"base"
], (App) ->

	App.controller "TagListController", ($scope, $modal) ->
		$scope.filterProjects = (filter = "all") ->
			$scope._clearTags()
			$scope.setFilter(filter)

		$scope._clearTags = () ->
			for tag in $scope.tags
				tag.selected = false
			
		$scope.selectTag = (tag) ->
			$scope._clearTags()
			tag.selected = true
			$scope.setFilter("tag")
		
		$scope.deleteTag = (tag) ->
			modalInstance = $modal.open(
				templateUrl: "deleteTagModalTemplate"
				controller: "DeleteTagModalController"
				resolve:
					tag: () -> tag
			)
			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<commit_msg>Remove tag from projects when deleted<commit_after>define [
	"base"
], (App) ->

	App.controller "TagListController", ($scope, $modal) ->
		$scope.filterProjects = (filter = "all") ->
			$scope._clearTags()
			$scope.setFilter(filter)

		$scope._clearTags = () ->
			for tag in $scope.tags
				tag.selected = false
			
		$scope.selectTag = (tag) ->
			$scope._clearTags()
			tag.selected = true
			$scope.setFilter("tag")
		
		$scope.deleteTag = (tag) ->
			modalInstance = $modal.open(
				templateUrl: "deleteTagModalTemplate"
				controller: "DeleteTagModalController"
				resolve:
					tag: () -> tag
			)
			modalInstance.result.then () ->
				# Remove tag from projects
				for project in $scope.projects
					project.tags ||= []
					index = project.tags.indexOf tag
					if index > -1
						project.tags.splice(index, 1)
				# Remove tag
				$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
{'fraction_non_alphanumeric': 0.1502086230876217, 'fraction_numerical': 0.0009272137227630969, 'mean_word_length': 2.902350813743219, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7059958', 'n_tokens_mistral': 882, 'n_tokens_neox': 700, 'n_words': 141}