mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Show deleted documents when viewing history
This commit is contained in:
parent
22c467c231
commit
cabaf1ae1a
8 changed files with 50 additions and 8 deletions
|
@ -15,6 +15,7 @@ module.exports = ProjectEditorHandler =
|
|||
description: project.description
|
||||
spellCheckLanguage: project.spellCheckLanguage
|
||||
deletedByExternalDataSource : project.deletedByExternalDataSource || false
|
||||
deletedDocs: project.deletedDocs
|
||||
|
||||
if options.includeUsers
|
||||
result.features =
|
||||
|
|
|
@ -3,11 +3,12 @@ define [
|
|||
"models/File"
|
||||
"models/Folder"
|
||||
"file-tree/FileTreeView"
|
||||
"file-tree/FolderView"
|
||||
"utils/Effects"
|
||||
"utils/Modal"
|
||||
"libs/backbone"
|
||||
"libs/jquery.storage"
|
||||
], (Doc, File, Folder, FileTreeView, Effects, Modal) ->
|
||||
], (Doc, File, Folder, FileTreeView, FolderView, Effects, Modal) ->
|
||||
class FileTreeManager
|
||||
constructor: (@ide) ->
|
||||
_.extend(@, Backbone.Events)
|
||||
|
@ -37,6 +38,10 @@ define [
|
|||
|
||||
populateFileTree: () ->
|
||||
@view.bindToRootFolder(@project.get("rootFolder"))
|
||||
@deletedDocsView = new FolderView(model: @project.get("deletedDocs"), manager: @)
|
||||
@deletedDocsView.render()
|
||||
$("#sections").append(@deletedDocsView.$el)
|
||||
@hideDeletedDocs()
|
||||
|
||||
listenForUpdates: () ->
|
||||
@ide.socket.on 'reciveNewDoc', (folder_id, doc) =>
|
||||
|
@ -100,8 +105,12 @@ define [
|
|||
@ide.sideBarView.deselectAll()
|
||||
@views[entity_id]?.select()
|
||||
|
||||
getEntity: (entity_id) ->
|
||||
@views[entity_id]?.model
|
||||
getEntity: (entity_id, options = {include_deleted: false}) ->
|
||||
model = @views[entity_id]?.model
|
||||
if !model? or (model.get("deleted") and !options.include_deleted)
|
||||
return
|
||||
else
|
||||
return model
|
||||
|
||||
getSelectedEntity: () -> @getEntity(@selected_entity_id)
|
||||
getSelectedEntityId: () -> @getSelectedEntity()?.id
|
||||
|
@ -275,6 +284,8 @@ define [
|
|||
|
||||
_doDelete: (entity) ->
|
||||
@ide.socket.emit 'deleteEntity', entity.id, entity.get("type")
|
||||
if entity.get("type") == "doc"
|
||||
@project.get("deletedDocs").get("children").add entity
|
||||
@onDeleteEntity entity.id
|
||||
|
||||
onDeleteEntity: (entity_id) ->
|
||||
|
@ -286,3 +297,10 @@ define [
|
|||
|
||||
setLabels: (labels) ->
|
||||
@view.setLabels(labels)
|
||||
@deletedDocsView.setLabels(labels)
|
||||
|
||||
showDeletedDocs: () ->
|
||||
@deletedDocsView.$el.show()
|
||||
|
||||
hideDeletedDocs: () ->
|
||||
@deletedDocsView.$el.hide()
|
||||
|
|
|
@ -9,3 +9,4 @@ define [
|
|||
attributes =
|
||||
id: rawAttributes._id
|
||||
name: rawAttributes.name
|
||||
deleted: !!rawAttributes.deleted
|
||||
|
|
|
@ -20,11 +20,11 @@ define [
|
|||
id: rawAttributes._id
|
||||
name: rawAttributes.name
|
||||
children = []
|
||||
for childFolder in rawAttributes.folders
|
||||
for childFolder in rawAttributes.folders or []
|
||||
children.push new Folder(childFolder, parse: true)
|
||||
for file in rawAttributes.fileRefs
|
||||
for file in rawAttributes.fileRefs or []
|
||||
children.push new File(file, parse: true)
|
||||
for doc in rawAttributes.docs
|
||||
for doc in rawAttributes.docs or []
|
||||
children.push new Doc(doc, parse: true)
|
||||
attributes.children = new FolderChildren(children)
|
||||
return attributes
|
||||
|
|
|
@ -2,8 +2,9 @@ define [
|
|||
"models/User"
|
||||
"models/ProjectMemberList"
|
||||
"models/Folder"
|
||||
"models/Doc"
|
||||
"libs/backbone"
|
||||
], (User, ProjectMemberList, Folder) ->
|
||||
], (User, ProjectMemberList, Folder, Doc) ->
|
||||
Project = Backbone.Model.extend
|
||||
initialize: ->
|
||||
@on "change:ide", (project, ide) =>
|
||||
|
@ -39,6 +40,15 @@ define [
|
|||
member = User.findOrBuild rawMember._id, rawMember
|
||||
members.add member
|
||||
|
||||
for doc in rawAttributes.deletedDocs
|
||||
doc.deleted = true
|
||||
|
||||
attributes.deletedDocs = new Folder({
|
||||
_id: "deleted-docs-folder"
|
||||
name: "Deleted documents"
|
||||
docs: rawAttributes.deletedDocs
|
||||
}, parse: true)
|
||||
|
||||
return attributes
|
||||
|
||||
bindToRootDocId: ->
|
||||
|
|
|
@ -71,6 +71,9 @@ define [
|
|||
@ide.mainAreaManager.change "trackChanges"
|
||||
@ide.editor.disable()
|
||||
@ide.fileViewManager.disable()
|
||||
|
||||
@ide.fileTreeManager.showDeletedDocs()
|
||||
|
||||
@enable()
|
||||
|
||||
showUpgradeView: () ->
|
||||
|
@ -93,6 +96,7 @@ define [
|
|||
@ide.fileTreeManager.openDoc(@doc_id)
|
||||
@ide.tabManager.show "code"
|
||||
@resetLabels()
|
||||
@ide.fileTreeManager.hideDeletedDocs()
|
||||
|
||||
autoSelectDiff: () ->
|
||||
if @changes.models.length == 0
|
||||
|
|
|
@ -21,6 +21,6 @@ define [
|
|||
toV: data.toV
|
||||
# TODO: We should not use a global reference here, but
|
||||
# it's hard to get @ide into Backbone at this point.
|
||||
entity: ide.fileTreeManager.getEntity(doc_id)
|
||||
entity: ide.fileTreeManager.getEntity(doc_id, include_deleted: true)
|
||||
|
||||
return model
|
|
@ -55,6 +55,10 @@ describe "ProjectEditorHandler", ->
|
|||
last_name : "Write"
|
||||
email : "read-write@sharelatex.com"
|
||||
}]
|
||||
deletedDocs: [{
|
||||
_id: "deleted-doc-id"
|
||||
name: "main.tex"
|
||||
}]
|
||||
@handler = SandboxedModule.require modulePath
|
||||
|
||||
describe "buildProjectModelView", ->
|
||||
|
@ -85,6 +89,10 @@ describe "ProjectEditorHandler", ->
|
|||
@result.owner.first_name.should.equal "Owner"
|
||||
@result.owner.last_name.should.equal "ShareLaTeX"
|
||||
@result.owner.privileges.should.equal "owner"
|
||||
|
||||
it "should include the deletedDocs", ->
|
||||
should.exist @result.deletedDocs
|
||||
@result.deletedDocs.should.equal @project.deletedDocs
|
||||
|
||||
it "should gather readOnly_refs and collaberators_refs into a list of members", ->
|
||||
findMember = (id) =>
|
||||
|
|
Loading…
Reference in a new issue