Add history file tree components.

This commit is contained in:
Paulo Reis 2018-05-21 15:12:03 +01:00
parent 2a52eab8d6
commit 6701b4413b
3 changed files with 57 additions and 0 deletions

View file

@ -13,6 +13,12 @@ define [
if projectOp.rename? then "#{ projectOp.rename.pathname}#{ projectOp.rename.newPathname }" if projectOp.rename? then "#{ projectOp.rename.pathname}#{ projectOp.rename.newPathname }"
else if projectOp.add? then "#{ projectOp.add.pathname}" else if projectOp.add? then "#{ projectOp.add.pathname}"
else if projectOp.remove? then "#{ projectOp.remove.pathname}" else if projectOp.remove? then "#{ projectOp.remove.pathname}"
ctrl.getUserCSSStyle = (user) ->
hue = user?.hue or 100
if ctrl.entry.inSelection
color : "#FFF"
else
color: "hsl(#{ hue }, 70%, 50%)"
return return
App.component "historyEntry", { App.component "historyEntry", {

View file

@ -0,0 +1,34 @@
define [
"base"
"ide/file-tree/util/iconTypeFromName"
], (App, iconTypeFromName) ->
# TODO Add arrows in folders
historyFileEntityController = ($scope, $element, $attrs) ->
ctrl = @
_handleFolderClick = () ->
ctrl.isOpen = !ctrl.isOpen
ctrl.iconClass = _getFolderIcon()
_handleFileClick = () ->
ctrl.historyFileTreeController.handleEntityClick ctrl.fileEntity
_getFolderIcon = () ->
if ctrl.isOpen then "fa-folder-open" else "fa-folder"
ctrl.$onInit = () ->
if ctrl.fileEntity.type == "folder"
ctrl.isOpen = true
ctrl.iconClass = _getFolderIcon()
ctrl.handleClick = _handleFolderClick
else
ctrl.iconClass = "fa-#{ iconTypeFromName(ctrl.fileEntity.name) }"
ctrl.handleClick = _handleFileClick
$scope.$watch (() -> ctrl.historyFileTreeController.selectedPathname), (newPathname) ->
ctrl.isSelected = ctrl.fileEntity.pathname == newPathname
return
App.component "historyFileEntity", {
require:
historyFileTreeController: "^historyFileTree"
bindings:
fileEntity: "<"
controller: historyFileEntityController
templateUrl: "historyFileEntityTpl"
}

View file

@ -0,0 +1,17 @@
define [
"base"
], (App) ->
historyFileTreeController = ($scope, $element, $attrs) ->
ctrl = @
ctrl.handleEntityClick = (file) ->
ctrl.onSelectedFileChange file: file
return
App.component "historyFileTree", {
bindings:
fileTree: "<"
selectedPathname: "<"
onSelectedFileChange: "&"
controller: historyFileTreeController
templateUrl: "historyFileTreeTpl"
}