Commit 6987d3c5 authored by gergely-ujvari's avatar gergely-ujvari

Make page search play nice with focus

As for the sort the page search works with threads instead of annotations so the directive should look for either annotation or thread.message in the scope
Page search focuses annotations when it opens them.

Thx @csillag for the help
parent 6c6ca67f
...@@ -963,6 +963,8 @@ class Search ...@@ -963,6 +963,8 @@ class Search
$rootScope.search_annotations = threads $rootScope.search_annotations = threads
$scope.threads = threads $scope.threads = threads
for thread in threads
$rootScope.focus thread.message, true
$scope.$on 'ReRenderPageSearch', refresh $scope.$on 'ReRenderPageSearch', refresh
$scope.$on '$routeUpdate', refresh $scope.$on '$routeUpdate', refresh
......
...@@ -230,21 +230,25 @@ thread = ['$rootScope', '$window', ($rootScope, $window) -> ...@@ -230,21 +230,25 @@ thread = ['$rootScope', '$window', ($rootScope, $window) ->
scope.collapsed = false scope.collapsed = false
scope.$on "focusChange", -> scope.$on "focusChange", ->
if scope.annotation in $rootScope.focused # XXX: This not needed to be done when the viewer and search will be unified
ann = scope.annotation ? scope.thread.message
if ann in $rootScope.focused
scope.collapsed = false scope.collapsed = false
else else
unless scope.annotation.references?.length unless ann.references?.length
scope.collapsed = true scope.collapsed = true
scope.toggleCollapsed = (event) -> scope.toggleCollapsed = (event) ->
event.stopPropagation() event.stopPropagation()
return if (ignoreClick event) or Object.keys(childrenEditing).length return if (ignoreClick event) or Object.keys(childrenEditing).length
scope.collapsed = !scope.collapsed scope.collapsed = !scope.collapsed
# XXX: This not needed to be done when the viewer and search will be unified
ann = scope.annotation ? scope.thread.message
if scope.collapsed if scope.collapsed
$rootScope.unFocus scope.annotation, true $rootScope.unFocus ann, true
else else
scope.openDetails scope.annotation scope.openDetails ann
$rootScope.focus scope.annotation, true $rootScope.focus ann, true
scope.$on 'toggleEditing', (event) -> scope.$on 'toggleEditing', (event) ->
{$id, editing} = event.targetScope {$id, editing} = event.targetScope
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment