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

View file

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