mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge remote-tracking branch 'origin/ns-new-file-modal-error-handling'
GitOrigin-RevId: 4eadc159d779c10918e045e080e3b8be12e807a2
This commit is contained in:
parent
15061047a3
commit
59d4bd6182
3 changed files with 17 additions and 15 deletions
|
@ -149,7 +149,10 @@ script(type='text/ng-template', id='newFileModalTemplate')
|
|||
ng-model="data.name"
|
||||
name="name"
|
||||
)
|
||||
div.alert.alert-danger.row-spaced-small(ng-if="state.error") Error, something went wrong!
|
||||
div.alert.alert-danger.row-spaced-small(ng-if="error")
|
||||
div(ng-switch="error")
|
||||
span(ng-switch-when="already exists") #{translate("file_already_exists")}
|
||||
span(ng-switch-default) Error, something went wrong!
|
||||
div(ng-if="type == 'url'", ng-controller="UrlLinkedFileModalController")
|
||||
form(novalidate, name="newLinkedFileForm")
|
||||
label(for="url") URL to fetch the file from
|
||||
|
|
|
@ -80,9 +80,8 @@ define(['base'], function(App) {
|
|||
}
|
||||
}))
|
||||
|
||||
return (selectName = function(element) {
|
||||
// Select up to last '.'. I.e. everything
|
||||
// except the file extension
|
||||
selectName = function(element) {
|
||||
// Select up to last '.'. I.e. everything except the file extension
|
||||
element.focus()
|
||||
const name = element.val()
|
||||
if (element[0].setSelectionRange != null) {
|
||||
|
@ -92,5 +91,5 @@ define(['base'], function(App) {
|
|||
}
|
||||
return element[0].setSelectionRange(0, selectionEnd)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -148,7 +148,7 @@ define(['base'], function(App) {
|
|||
|
||||
const validate = function() {
|
||||
const { name } = $scope.inputs
|
||||
return ($scope.state.valid = name != null && name.length > 0)
|
||||
$scope.state.valid = name != null && name.length > 0
|
||||
}
|
||||
$scope.$watch('inputs.name', validate)
|
||||
|
||||
|
@ -169,7 +169,7 @@ define(['base'], function(App) {
|
|||
.catch(function(response) {
|
||||
const { data } = response
|
||||
$scope.error = data
|
||||
return ($scope.state.inflight = false)
|
||||
$scope.state.inflight = false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ define(['base'], function(App) {
|
|||
}
|
||||
const fileName = newVal.split('/').reverse()[0]
|
||||
if (fileName) {
|
||||
return ($scope.data.name = fileName)
|
||||
$scope.data.name = fileName
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -352,14 +352,14 @@ define(['base'], function(App) {
|
|||
$scope.data.projects,
|
||||
p => p._id === $scope.data.selectedProjectId
|
||||
)
|
||||
return ($scope.data.name =
|
||||
$scope.data.name =
|
||||
(project != null ? project.name : undefined) != null
|
||||
? `${project.name}.pdf`
|
||||
: 'output.pdf')
|
||||
: 'output.pdf'
|
||||
} else {
|
||||
const fileName = newVal.split('/').reverse()[0]
|
||||
if (fileName) {
|
||||
return ($scope.data.name = fileName)
|
||||
$scope.data.name = fileName
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -418,7 +418,7 @@ define(['base'], function(App) {
|
|||
const validate = function() {
|
||||
const { state } = $scope
|
||||
const { data } = $scope
|
||||
return ($scope.state.valid =
|
||||
$scope.state.valid =
|
||||
!state.inFlight.projects &&
|
||||
!state.inFlight.entities &&
|
||||
data.projects &&
|
||||
|
@ -429,7 +429,7 @@ define(['base'], function(App) {
|
|||
($scope.state.isOutputFilesMode &&
|
||||
data.projectOutputFiles &&
|
||||
data.selectedProjectOutputFile)) &&
|
||||
data.name)
|
||||
data.name
|
||||
}
|
||||
$scope.$watch('state', validate, true)
|
||||
$scope.$watch('data', validate, true)
|
||||
|
@ -519,7 +519,7 @@ define(['base'], function(App) {
|
|||
}
|
||||
}
|
||||
_setInFlight('create')
|
||||
return ide.fileTreeManager
|
||||
ide.fileTreeManager
|
||||
.createLinkedFile(name, $scope.parent_folder, provider, payload)
|
||||
.then(function() {
|
||||
_reset({ err: false })
|
||||
|
@ -527,7 +527,7 @@ define(['base'], function(App) {
|
|||
})
|
||||
.catch(function(response) {
|
||||
const { data } = response
|
||||
return _reset({ err: true })
|
||||
$scope.error = data
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue