mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-06 08:31:45 +00:00
Show confirmation if upload will overwrite files
This commit is contained in:
parent
c6dcb64b18
commit
71ca358e0e
4 changed files with 66 additions and 6 deletions
|
@ -360,6 +360,17 @@ script(type="text/ng-template", id="uploadFileModalTemplate")
|
||||||
.alert.alert-warning.small.modal-alert(ng-if="tooManyFiles") #{translate("maximum_files_uploaded_together", {max:"{{max_files}}"})}
|
.alert.alert-warning.small.modal-alert(ng-if="tooManyFiles") #{translate("maximum_files_uploaded_together", {max:"{{max_files}}"})}
|
||||||
.alert.alert-warning.small.modal-alert(ng-if="rateLimitHit") #{translate("too_many_files_uploaded_throttled_short_period")}
|
.alert.alert-warning.small.modal-alert(ng-if="rateLimitHit") #{translate("too_many_files_uploaded_throttled_short_period")}
|
||||||
.alert.alert-warning.small.modal-alert(ng-if="notLoggedIn") #{translate("session_expired_redirecting_to_login", {seconds:"{{secondsToRedirect}}"})}
|
.alert.alert-warning.small.modal-alert(ng-if="notLoggedIn") #{translate("session_expired_redirecting_to_login", {seconds:"{{secondsToRedirect}}"})}
|
||||||
|
.alert.alert-warning.small.modal-alert(ng-if="conflicts.length > 0")
|
||||||
|
p.text-center
|
||||||
|
| The following files already exist in this project:
|
||||||
|
ul.text-center.list-unstyled.row-spaced-small
|
||||||
|
li(ng-repeat="conflict in conflicts"): strong {{ conflict }}
|
||||||
|
p.text-center.row-spaced-small
|
||||||
|
| Do you want to overwrite them?
|
||||||
|
p.text-center
|
||||||
|
a(href, ng-click="doUpload()").btn.btn-primary Overwrite
|
||||||
|
|
|
||||||
|
a(href, ng-click="cancel()").btn.btn-default Cancel
|
||||||
|
|
||||||
.modal-body(
|
.modal-body(
|
||||||
fine-upload
|
fine-upload
|
||||||
|
@ -370,10 +381,14 @@ script(type="text/ng-template", id="uploadFileModalTemplate")
|
||||||
drag-area-text="{{drag_files}}"
|
drag-area-text="{{drag_files}}"
|
||||||
hint-text="{{hint_press_and_hold_control_key}}"
|
hint-text="{{hint_press_and_hold_control_key}}"
|
||||||
multiple="true"
|
multiple="true"
|
||||||
|
auto-upload="false"
|
||||||
on-complete-callback="onComplete"
|
on-complete-callback="onComplete"
|
||||||
on-upload-callback="onUpload"
|
on-upload-callback="onUpload"
|
||||||
on-validate-batch="onValidateBatch"
|
on-validate-batch="onValidateBatch"
|
||||||
on-error-callback="onError"
|
on-error-callback="onError"
|
||||||
|
on-submit-callback="onSubmit"
|
||||||
|
on-cancel-callback="onCancel"
|
||||||
|
control="control"
|
||||||
params="{'folder_id': parent_folder_id}"
|
params="{'folder_id': parent_folder_id}"
|
||||||
)
|
)
|
||||||
span #{translate("upload_files")}
|
span #{translate("upload_files")}
|
||||||
|
|
|
@ -16,7 +16,11 @@ define [
|
||||||
onUploadCallback: "="
|
onUploadCallback: "="
|
||||||
onValidateBatch: "="
|
onValidateBatch: "="
|
||||||
onErrorCallback: "="
|
onErrorCallback: "="
|
||||||
|
onSubmitCallback: "="
|
||||||
|
onCancelCallback: "="
|
||||||
|
autoUpload: "="
|
||||||
params: "="
|
params: "="
|
||||||
|
control: "="
|
||||||
}
|
}
|
||||||
link: (scope, element, attrs) ->
|
link: (scope, element, attrs) ->
|
||||||
multiple = scope.multiple or false
|
multiple = scope.multiple or false
|
||||||
|
@ -37,12 +41,19 @@ define [
|
||||||
onUpload = scope.onUploadCallback or () ->
|
onUpload = scope.onUploadCallback or () ->
|
||||||
onError = scope.onErrorCallback or () ->
|
onError = scope.onErrorCallback or () ->
|
||||||
onValidateBatch = scope.onValidateBatch or () ->
|
onValidateBatch = scope.onValidateBatch or () ->
|
||||||
|
onSubmit = scope.onSubmitCallback or () ->
|
||||||
|
onCancel = scope.onCancelCallback or () ->
|
||||||
|
if !scope.autoUpload?
|
||||||
|
autoUpload = true
|
||||||
|
else
|
||||||
|
autoUpload = scope.autoUpload
|
||||||
params = scope.params or {}
|
params = scope.params or {}
|
||||||
params._csrf = window.csrfToken
|
params._csrf = window.csrfToken
|
||||||
|
|
||||||
q = new qq.FineUploader
|
q = new qq.FineUploader
|
||||||
element: element[0]
|
element: element[0]
|
||||||
multiple: multiple
|
multiple: multiple
|
||||||
|
autoUpload: autoUpload
|
||||||
disabledCancelForFormUploads: true
|
disabledCancelForFormUploads: true
|
||||||
validation: validation
|
validation: validation
|
||||||
maxConnections: maxConnections
|
maxConnections: maxConnections
|
||||||
|
@ -56,6 +67,8 @@ define [
|
||||||
onUpload: onUpload
|
onUpload: onUpload
|
||||||
onValidateBatch: onValidateBatch
|
onValidateBatch: onValidateBatch
|
||||||
onError: onError
|
onError: onError
|
||||||
|
onSubmit: onSubmit
|
||||||
|
onCancel: onCancel
|
||||||
text: text
|
text: text
|
||||||
template: """
|
template: """
|
||||||
<div class="qq-uploader">
|
<div class="qq-uploader">
|
||||||
|
@ -70,5 +83,7 @@ define [
|
||||||
<ul class="qq-upload-list"></ul>
|
<ul class="qq-upload-list"></ul>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
window.q = q
|
||||||
|
scope.control?.q = q
|
||||||
return q
|
return q
|
||||||
}
|
}
|
|
@ -135,6 +135,12 @@ define [
|
||||||
multiSelectSelectedEntity: () ->
|
multiSelectSelectedEntity: () ->
|
||||||
@findSelectedEntity()?.multiSelected = true
|
@findSelectedEntity()?.multiSelected = true
|
||||||
|
|
||||||
|
existsInFolder: (folder_id, name) ->
|
||||||
|
folder = @findEntityById(folder_id)
|
||||||
|
return false if !folder?
|
||||||
|
entity = @_findEntityByPathInFolder(folder, name)
|
||||||
|
return entity?
|
||||||
|
|
||||||
findSelectedEntity: () ->
|
findSelectedEntity: () ->
|
||||||
selected = null
|
selected = null
|
||||||
@forEachEntity (entity) ->
|
@forEachEntity (entity) ->
|
||||||
|
|
|
@ -106,7 +106,8 @@ define [
|
||||||
$scope.rateLimitHit = false
|
$scope.rateLimitHit = false
|
||||||
$scope.secondsToRedirect = 10
|
$scope.secondsToRedirect = 10
|
||||||
$scope.notLoggedIn = false
|
$scope.notLoggedIn = false
|
||||||
|
$scope.conflicts = []
|
||||||
|
$scope.control = {}
|
||||||
|
|
||||||
needToLogBackIn = ->
|
needToLogBackIn = ->
|
||||||
$scope.notLoggedIn = true
|
$scope.notLoggedIn = true
|
||||||
|
@ -121,11 +122,6 @@ define [
|
||||||
|
|
||||||
decreseTimeout()
|
decreseTimeout()
|
||||||
|
|
||||||
|
|
||||||
uploadCount = 0
|
|
||||||
$scope.onUpload = () ->
|
|
||||||
uploadCount++
|
|
||||||
|
|
||||||
$scope.max_files = 40
|
$scope.max_files = 40
|
||||||
$scope.onComplete = (error, name, response) ->
|
$scope.onComplete = (error, name, response) ->
|
||||||
$timeout (() ->
|
$timeout (() ->
|
||||||
|
@ -150,6 +146,34 @@ define [
|
||||||
else if reason.indexOf("403") != -1
|
else if reason.indexOf("403") != -1
|
||||||
needToLogBackIn()
|
needToLogBackIn()
|
||||||
|
|
||||||
|
_uploadTimer = null
|
||||||
|
uploadIfNoConflicts = () ->
|
||||||
|
if $scope.conflicts.length == 0
|
||||||
|
$scope.doUpload()
|
||||||
|
|
||||||
|
uploadCount = 0
|
||||||
|
$scope.onSubmit = (id, name) ->
|
||||||
|
uploadCount++
|
||||||
|
if ide.fileTreeManager.existsInFolder($scope.parent_folder_id, name)
|
||||||
|
$scope.conflicts.push name
|
||||||
|
$scope.$apply()
|
||||||
|
if !_uploadTimer?
|
||||||
|
_uploadTimer = setTimeout () ->
|
||||||
|
_uploadTimer = null
|
||||||
|
uploadIfNoConflicts()
|
||||||
|
, 0
|
||||||
|
return true
|
||||||
|
|
||||||
|
$scope.onCancel = (id, name) ->
|
||||||
|
uploadCount--
|
||||||
|
index = $scope.conflicts.indexOf(name)
|
||||||
|
if index > -1
|
||||||
|
$scope.conflicts.splice(index, 1)
|
||||||
|
$scope.$apply()
|
||||||
|
uploadIfNoConflicts()
|
||||||
|
|
||||||
|
$scope.doUpload = () ->
|
||||||
|
$scope.control?.q?.uploadStoredFiles()
|
||||||
|
|
||||||
$scope.cancel = () ->
|
$scope.cancel = () ->
|
||||||
$modalInstance.dismiss('cancel')
|
$modalInstance.dismiss('cancel')
|
||||||
|
|
Loading…
Reference in a new issue