UI fix - do not allow multiple clicks to restore a deleted file.

This commit is contained in:
Paulo Reis 2016-08-03 16:05:19 +01:00
parent 216779fafe
commit cf5c8e27e1
5 changed files with 36 additions and 8 deletions

View file

@ -143,15 +143,27 @@ div#trackChanges(ng-show="ui.view == 'track-changes'")
navigate-highlights="true"
)
.diff-deleted.text-centered(
ng-show="trackChanges.diff.deleted"
ng-show="trackChanges.diff.deleted && !trackChanges.diff.restoreDeletedSuccess"
)
p.text-serif #{translate("file_has_been_deleted", {filename:"{{ trackChanges.diff.doc.name }} "})}
p
a.btn.btn-primary.btn-lg(
href,
ng-click="restoreDeletedDoc()"
ng-click="restoreDeletedDoc()",
ng-disabled="trackChanges.diff.restoreInProgress"
) #{translate("restore")}
.diff-deleted.text-centered(
ng-show="trackChanges.diff.deleted && trackChanges.diff.restoreDeletedSuccess"
)
p.text-serif Your file ({{ trackChanges.diff.doc.name }}) has been recovered.
p.text-serif You can go back to the editor and work on it again.
p
a.btn.btn-default(
href,
ng-click="backToEditorAfterRestore()",
) Back to editor
.loading-panel(ng-show="trackChanges.diff.loading")
i.fa.fa-spin.fa-refresh
|   #{translate("loading")}...

View file

@ -117,6 +117,9 @@ define [
diff.error = true
else
diff.deleted = true
diff.restoreInProgress = false
diff.restoreDeletedSuccess = false
diff.restoredDocNewId = null
restoreDeletedDoc: (doc) ->
url = "/project/#{@$scope.project_id}/doc/#{doc.id}/restore"

View file

@ -4,9 +4,15 @@ define [
App.controller "TrackChangesDiffController", ($scope, $modal, ide, event_tracking) ->
$scope.restoreDeletedDoc = () ->
event_tracking.sendCountly "track-changes-restore-deleted"
ide.trackChangesManager.restoreDeletedDoc(
$scope.trackChanges.diff.restoreInProgress = true
ide.trackChangesManager
.restoreDeletedDoc(
$scope.trackChanges.diff.doc
)
.success (response) ->
$scope.trackChanges.diff.restoredDocNewId = response.doc_id
$scope.trackChanges.diff.restoreInProgress = false
$scope.trackChanges.diff.restoreDeletedSuccess = true
$scope.openRestoreDiffModal = () ->
event_tracking.sendCountly "track-changes-restore-modal"
@ -17,6 +23,9 @@ define [
diff: () -> $scope.trackChanges.diff
}
$scope.backToEditorAfterRestore = () ->
ide.editorManager.openDoc({ id: $scope.trackChanges.diff.restoredDocNewId })
App.controller "TrackChangesRestoreDiffModalController", ($scope, $modalInstance, diff, ide, event_tracking) ->
$scope.state =
inflight: false

View file

@ -2,7 +2,7 @@ define [
"base"
], (App) ->
App.controller "TrackChangesPremiumPopup", ($scope, ide, sixpack, event_tracking)->
App.controller "TrackChangesPremiumPopup", ($scope, ide, sixpack)->
$scope.$watch "ui.view", ->
if $scope.ui.view == "track-changes"
if $scope.project?.features?.versioning
@ -78,7 +78,7 @@ define [
$scope.recalculateSelectedUpdates()
]
App.controller "TrackChangesListItemController", ["$scope", ($scope) ->
App.controller "TrackChangesListItemController", ["$scope", "event_tracking", ($scope, event_tracking) ->
$scope.$watch "update.selectedFrom", (selectedFrom, oldSelectedFrom) ->
if selectedFrom
for update in $scope.trackChanges.updates

View file

@ -267,6 +267,10 @@
}
}
.diff-deleted {
padding-top: 15px;
}
.editor-dark {
#trackChanges {
aside.change-list {