Make track changes file view read only

This commit is contained in:
James Allen 2014-06-11 10:46:45 +01:00
parent 560288348a
commit e91d4d61e9
6 changed files with 44 additions and 12 deletions

View file

@ -24,6 +24,10 @@ define [
hideToggle: () ->
@$(".js-toggle").hide()
makeReadOnly: () ->
makeReadWrite: () ->

View file

@ -23,7 +23,8 @@ define [
render: () ->
@$el.append(Mustache.to_html @entityTemplate, @model.attributes)
@_bindToDomElements()
@_makeEditable()
@_initializeRenameBox()
@_initializeDrag()
return @
_bindToDomElements: () ->
@ -32,12 +33,6 @@ define [
@$entityListItemEl = @$el.children(".entity-list-item")
@$labelEl = @$entityListItemEl.children(".entity-label")
_makeEditable: () ->
if @ide.isAllowedToDoIt "readAndWrite"
@_initializeRenameBox()
@_initializeDrag()
@hideRenameBox()
bindToModel: () ->
@model.on "change:name", (model) =>
@$nameEl.text(model.get("name"))
@ -84,7 +79,7 @@ define [
onDoubleClick: (e) ->
e.preventDefault()
e.stopPropagation()
if @ide.isAllowedToDoIt "readAndWrite"
if !@readonly
@startRename()
showContextMenuFromCaret: (e) ->
@ -121,6 +116,7 @@ define [
delete @contextMenu
getContextMenuEntries: () ->
return null if @readonly
return [{
text: "Rename"
onClick: () =>
@ -171,5 +167,14 @@ define [
@manager.renameEntity(@model, name)
@hideRenameBox()
makeReadOnly: () ->
console.log @
@$entityListItemEl.draggable("disable")
@readonly = true
makeReadWrite: () ->
@$entityListItemEl.draggable("enable")
delete @readonly

View file

@ -17,6 +17,7 @@ define [
@multiSelectedEntities = []
@ide.on "afterJoinProject", (@project) =>
@populateFileTree()
@makeReadWriteIfAllowed()
@project_id = @project.id
if @ide.editor?.current_doc_id?
@openDoc(@ide.editor.current_doc_id)
@ -312,3 +313,17 @@ define [
hideDeletedDocs: () ->
@deletedDocsView.$el.hide()
makeReadOnly: () ->
for id, view of @views or []
view.makeReadOnly?()
makeReadWrite: () ->
for id, view of @views or []
view.makeReadWrite?()
makeReadWriteIfAllowed: () ->
if @ide.isAllowedToDoIt("readAndWrite")
@makeReadWrite()
else
@makeReadOnly()

View file

@ -123,6 +123,7 @@ define [
@showEntries()
getContextMenuEntries: (args...) ->
return null if @readonly
entries = EntityView::getContextMenuEntries.apply(this, args)
entries.push {
divider: true

View file

@ -36,8 +36,7 @@ define [
type: "project"
})
@_bindToDomElements()
if @ide.isAllowedToDoIt("readAndWrite")
@renderActions()
@renderActions()
@hideRenameBox()
@hideToggle()
@renderEntries()
@ -45,8 +44,8 @@ define [
return @
renderActions: () ->
actions = $(@actionsTemplate)
actions.insertAfter(@$entityListItemEl)
@$actions = $(@actionsTemplate)
@$actions.insertAfter(@$entityListItemEl)
@$(".js-new-entity-menu > a").dropdown()
onClick: () ->
@ -61,6 +60,12 @@ define [
hideToggle: () ->
@$(".js-toggle").hide()
makeReadOnly: () ->
@$actions.hide()
makeReadWrite: () ->
@$actions.show()

View file

@ -72,6 +72,7 @@ define [
@ide.editor.disable()
@ide.fileViewManager.disable()
@ide.fileTreeManager.makeReadOnly()
@ide.fileTreeManager.showDeletedDocs()
@enable()
@ -96,6 +97,7 @@ define [
@ide.fileTreeManager.openDoc(@doc_id)
@ide.tabManager.show "code"
@resetLabels()
@ide.fileTreeManager.makeReadWriteIfAllowed()
@ide.fileTreeManager.hideDeletedDocs()
autoSelectDiff: () ->