mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Highlight the changed files in the file list view
This commit is contained in:
parent
9145a1c9ba
commit
6c77ee4861
7 changed files with 80 additions and 9 deletions
|
@ -68,6 +68,7 @@
|
|||
input.rename.js-rename
|
||||
.dropdown-caret
|
||||
i.icon-chevron-down
|
||||
.entity-label.label.label-success
|
||||
|
||||
script(type="text/template")#folderTemplate
|
||||
.entity-list-item(class="entity-{{ type }}", entity-type="{{ type }}", id="{{ id }}")
|
||||
|
@ -80,6 +81,7 @@
|
|||
input.rename.js-rename
|
||||
.dropdown-caret
|
||||
i.icon-chevron-down
|
||||
.entity-label.label.label-success
|
||||
|
||||
script(type="text/template")#entityListTemplate
|
||||
.contents
|
||||
|
|
|
@ -15,6 +15,7 @@ define [
|
|||
events: () ->
|
||||
events = {}
|
||||
events["click ##{@model.id} > .js-clickable"] = "parentOnClick"
|
||||
events["click ##{@model.id} > .entity-label"] = "parentOnClick"
|
||||
events["click .dropdown-caret"] = "showContextMenuFromCaret"
|
||||
events["contextmenu"] = "showContextMenuFromRightClick"
|
||||
return events
|
||||
|
@ -29,6 +30,7 @@ define [
|
|||
@$nameEl = @$(".name")
|
||||
@$inputEl = @$("input.js-rename")
|
||||
@$entityListItemEl = @$el.children(".entity-list-item")
|
||||
@$labelEl = @$entityListItemEl.children(".entity-label")
|
||||
|
||||
_makeEditable: () ->
|
||||
if @ide.isAllowedToDoIt "readAndWrite"
|
||||
|
@ -48,6 +50,17 @@ define [
|
|||
@$nameEl.hide()
|
||||
@$inputEl.show()
|
||||
|
||||
setLabels: (labels) ->
|
||||
label = labels[@model.get("id")]
|
||||
if label?
|
||||
@$entityListItemEl.addClass("show-label")
|
||||
@$labelEl.text("±")
|
||||
return true
|
||||
else
|
||||
@$entityListItemEl.removeClass("show-label")
|
||||
@$labelEl.text("")
|
||||
return false
|
||||
|
||||
select: () ->
|
||||
@selected = true
|
||||
@$entityListItemEl.addClass("selected")
|
||||
|
|
|
@ -277,6 +277,5 @@ define [
|
|||
entity.collection?.remove(entity)
|
||||
delete @views[entity_id]
|
||||
|
||||
|
||||
|
||||
|
||||
setLabels: (labels) ->
|
||||
@view.setLabels(labels)
|
||||
|
|
|
@ -20,3 +20,6 @@ define [
|
|||
entities.append(@rootFolderView.$el)
|
||||
@rootFolderView.render()
|
||||
|
||||
setLabels: (labels) ->
|
||||
@rootFolderView.setLabels(labels)
|
||||
|
||||
|
|
|
@ -107,11 +107,13 @@ define [
|
|||
@$contents.hide()
|
||||
@$toggle.find(".js-open").hide()
|
||||
@$toggle.find(".js-closed").show()
|
||||
@$entityListItemEl.removeClass("folder-open")
|
||||
|
||||
showEntries: () ->
|
||||
@$contents.show()
|
||||
@$toggle.find(".js-open").show()
|
||||
@$toggle.find(".js-closed").hide()
|
||||
@$entityListItemEl.addClass("folder-open")
|
||||
|
||||
onToggle: (e) ->
|
||||
e.preventDefault()
|
||||
|
@ -146,3 +148,17 @@ define [
|
|||
@manager.showUploadFileModal(@model)
|
||||
}]
|
||||
|
||||
setLabels: (labels) ->
|
||||
showLabel = false
|
||||
for entity in @views
|
||||
if entity.setLabels(labels)
|
||||
showLabel = true
|
||||
|
||||
if showLabel
|
||||
@$entityListItemEl.addClass("show-label")
|
||||
@$labelEl.text("±")
|
||||
return true
|
||||
else
|
||||
@$entityListItemEl.removeClass("show-label")
|
||||
@$labelEl.text("")
|
||||
return false
|
||||
|
|
|
@ -59,7 +59,9 @@ define [
|
|||
@autoSelectDiff()
|
||||
|
||||
@changeListView.on "change_diff", (fromIndex, toIndex) =>
|
||||
@selectDocAndUpdateDiff(fromIndex, toIndex)
|
||||
@findDocsInChange(fromIndex, toIndex)
|
||||
@updateLabels()
|
||||
@updateDiff()
|
||||
|
||||
@showUpgradeView()
|
||||
|
||||
|
@ -97,6 +99,7 @@ define [
|
|||
@disable()
|
||||
@ide.fileTreeManager.openDoc(@doc_id)
|
||||
@ide.tabManager.show "code"
|
||||
@resetLabels()
|
||||
|
||||
autoSelectDiff: () ->
|
||||
if @changes.models.length == 0
|
||||
|
@ -118,17 +121,27 @@ define [
|
|||
@changeListView.setSelectionRange(fromIndex, 0)
|
||||
@updateDiff()
|
||||
|
||||
selectDocAndUpdateDiff: (fromIndex, toIndex) ->
|
||||
doc_ids = []
|
||||
findDocsInChange: (fromIndex, toIndex) ->
|
||||
@changed_doc_ids = []
|
||||
for change in @changes.models.slice(toIndex, fromIndex + 1)
|
||||
for doc in change.get("docs") or []
|
||||
doc_ids.push doc.id if doc.id not in doc_ids
|
||||
@changed_doc_ids.push doc.id if doc.id not in @changed_doc_ids
|
||||
|
||||
if !@doc_id? or @doc_id not in doc_ids
|
||||
@doc_id = doc_ids[0]
|
||||
if !@doc_id? or @doc_id not in @changed_doc_ids
|
||||
@doc_id = @changed_doc_ids[0]
|
||||
|
||||
@updateDiff()
|
||||
|
||||
updateLabels: () ->
|
||||
labels = {}
|
||||
for doc_id in @changed_doc_ids
|
||||
labels[doc_id] = true
|
||||
@ide.fileTreeManager.setLabels(labels)
|
||||
|
||||
resetLabels: () ->
|
||||
@ide.fileTreeManager.setLabels({})
|
||||
|
||||
|
||||
updateDiff: () ->
|
||||
fromIndex = @changeListView.selectedFromIndex
|
||||
toIndex = @changeListView.selectedToIndex
|
||||
|
|
|
@ -467,6 +467,9 @@ body.editor {
|
|||
.dropdown-caret {
|
||||
display: none;
|
||||
}
|
||||
.entity-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.entity-folder {
|
||||
|
@ -528,6 +531,28 @@ body.editor {
|
|||
}
|
||||
}
|
||||
|
||||
.entity-list-item.show-label {
|
||||
.dropdown-caret {
|
||||
display: none;
|
||||
}
|
||||
.entity-label {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
font-size: 12px;
|
||||
line-height: 12px;
|
||||
padding: 3px 6px;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.entity-list-item.folder-open.show-label {
|
||||
.entity-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
li img, .entity-list-item i {
|
||||
margin: 4px;
|
||||
vertical-align: -7px;
|
||||
|
|
Loading…
Reference in a new issue