Don't allow project names to be blank

This commit is contained in:
James Allen 2016-02-23 15:00:04 +00:00
parent b504732733
commit f21aa0dd94
2 changed files with 10 additions and 6 deletions

View file

@ -1,6 +1,7 @@
define [
"base"
], (App) ->
MAX_PROJECT_NAME_LENGTH = 150
App.controller "ProjectNameController", ["$scope", "settings", "ide", ($scope, settings, ide) ->
$scope.state =
renaming: false
@ -12,11 +13,12 @@ define [
$scope.$emit "project:rename:start"
$scope.finishRenaming = () ->
$scope.state.renaming = false
newName = $scope.inputs.name
if newName.length < 150
if !newName? or newName.length == 0 or newName.length > MAX_PROJECT_NAME_LENGTH
return
$scope.project.name = newName
settings.saveProjectSettings({name: $scope.project.name})
$scope.state.renaming = false
ide.socket.on "projectNameUpdated", (name) ->
$scope.$apply () ->

View file

@ -257,8 +257,10 @@ define [
modalInstance.result.then (project_id) ->
window.location = "/project/#{project_id}"
MAX_PROJECT_NAME_LENGTH = 150
$scope.renameProject = (project, newName) ->
if newName.length < 150
if !newName? or newName.length == 0 or newName.length > MAX_PROJECT_NAME_LENGTH
return
project.name = newName
queuedHttp.post "/project/#{project.id}/rename", {
newProjectName: project.name