2014-07-08 07:02:26 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2016-08-03 07:36:42 -04:00
|
|
|
App.controller "TrackChangesDiffController", ($scope, $modal, ide, event_tracking) ->
|
2014-07-08 07:02:26 -04:00
|
|
|
$scope.restoreDeletedDoc = () ->
|
2016-08-10 12:29:43 -04:00
|
|
|
event_tracking.sendMB "track-changes-restore-deleted"
|
2016-08-03 11:05:19 -04:00
|
|
|
$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
|
2014-07-11 08:55:14 -04:00
|
|
|
|
|
|
|
$scope.openRestoreDiffModal = () ->
|
2016-08-10 12:29:43 -04:00
|
|
|
event_tracking.sendMB "track-changes-restore-modal"
|
2014-07-11 08:55:14 -04:00
|
|
|
$modal.open {
|
|
|
|
templateUrl: "trackChangesRestoreDiffModalTemplate"
|
|
|
|
controller: "TrackChangesRestoreDiffModalController"
|
|
|
|
resolve:
|
|
|
|
diff: () -> $scope.trackChanges.diff
|
|
|
|
}
|
|
|
|
|
2016-08-03 11:05:19 -04:00
|
|
|
$scope.backToEditorAfterRestore = () ->
|
|
|
|
ide.editorManager.openDoc({ id: $scope.trackChanges.diff.restoredDocNewId })
|
|
|
|
|
2016-08-03 07:36:42 -04:00
|
|
|
App.controller "TrackChangesRestoreDiffModalController", ($scope, $modalInstance, diff, ide, event_tracking) ->
|
2014-07-11 08:55:14 -04:00
|
|
|
$scope.state =
|
|
|
|
inflight: false
|
|
|
|
|
|
|
|
$scope.diff = diff
|
|
|
|
|
|
|
|
$scope.restore = () ->
|
2016-08-10 12:29:43 -04:00
|
|
|
event_tracking.sendMB "track-changes-restored"
|
2014-07-11 08:55:14 -04:00
|
|
|
$scope.state.inflight = true
|
|
|
|
ide.trackChangesManager
|
|
|
|
.restoreDiff(diff)
|
|
|
|
.success () ->
|
|
|
|
$scope.state.inflight = false
|
|
|
|
$modalInstance.close()
|
|
|
|
ide.editorManager.openDoc(diff.doc)
|
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss()
|