loleaflet/src/layer/AnnotationManager.js    |   13 ++++
 loleaflet/src/layer/tile/TileLayer.js       |   78 ++++++++++++++--------------
 loleaflet/src/layer/tile/WriterTileLayer.js |    4 +
 3 files changed, 58 insertions(+), 37 deletions(-)

New commits:
commit ff86f5240e15039840fcebb3709d12fca25121e8
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Tue Sep 15 16:33:50 2020 +0530
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Sep 16 06:39:51 2020 +0200

    leaflet: made annotation context menu dynamic
    
    now annotation context menu options will be toggled
    between resolved and unresolved according to its state
    
    Change-Id: I477fdf4b77a940a458d320478801283b71ccb73b
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102783
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/loleaflet/src/layer/AnnotationManager.js 
b/loleaflet/src/layer/AnnotationManager.js
index 3c1198c7a..6d71cd107 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -735,6 +735,19 @@ L.AnnotationManager = L.Class.extend({
                this._map.focus();
        },
 
+       _isThreadResolved: function(annotation) {
+               var lastChild = this.getLastChildIndexOf(annotation._data.id);
+
+               while (this._items[lastChild]._data.parent !== '0') {
+                       if (this._items[lastChild]._data.resolved === 'false')
+                               return false;
+                       lastChild = 
this.getIndexOf(this._items[lastChild]._data.parent);
+               }
+               if (this._items[lastChild]._data.resolved === 'false')
+                       return false;
+               return true;
+       },
+
        // Adjust parent-child relationship, if required, after `comment` is 
added
        adjustParentAdd: function(comment) {
                if (comment.parent && comment.parent > '0') {
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 0a5cd72b7..bb8b905de 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -232,43 +232,47 @@ L.TileLayer = L.GridLayer.extend({
                        selector: '.loleaflet-annotation-menu',
                        trigger: 'none',
                        className: 'loleaflet-font',
-                       items: {
-                               modify: {
-                                       name: _('Modify'),
-                                       callback: function (key, options) {
-                                               
that.onAnnotationModify.call(that, options.$trigger.get(0).annotation);
-                                       }
-                               },
-                               reply: (this._docType !== 'text' && 
this._docType !== 'presentation') ? undefined : {
-                                       name: _('Reply'),
-                                       callback: function (key, options) {
-                                               
that.onAnnotationReply.call(that, options.$trigger.get(0).annotation);
-                                       }
-                               },
-                               remove: {
-                                       name: _('Remove'),
-                                       callback: function (key, options) {
-                                               
that.onAnnotationRemove.call(that, options.$trigger.get(0).annotation._data.id);
-                                       }
-                               },
-                               removeThread: {
-                                       name: _('Remove Thread'),
-                                       callback: function (key, options) {
-                                               
that.onAnnotationRemoveThread.call(that, 
options.$trigger.get(0).annotation._data.id);
-                                       }
-                               },
-                               resolve: this._docType !== 'text' ? undefined : 
{
-                                       name: _('Resolve'),
-                                       callback: function (key, options) {
-                                               
that.onAnnotationResolve.call(that, options.$trigger.get(0).annotation);
-                                       }
-                               },
-                               resolveThread: this._docType !== 'text' ? 
undefined : {
-                                       name: _('Resolve Thread'),
-                                       callback: function (key, options) {
-                                               
that.onAnnotationResolveThread.call(that, options.$trigger.get(0).annotation);
-                                       }
-                               }
+                       build: function($trigger) {
+                               return {
+                                       items: {
+                                               modify: {
+                                                       name: _('Modify'),
+                                                       callback: function 
(key, options) {
+                                                               
that.onAnnotationModify.call(that, options.$trigger.get(0).annotation);
+                                                       }
+                                               },
+                                               reply: (that._docType !== 
'text' && that._docType !== 'presentation') ? undefined : {
+                                                       name: _('Reply'),
+                                                       callback: function 
(key, options) {
+                                                               
that.onAnnotationReply.call(that, options.$trigger.get(0).annotation);
+                                                       }
+                                               },
+                                               remove: {
+                                                       name: _('Remove'),
+                                                       callback: function 
(key, options) {
+                                                               
that.onAnnotationRemove.call(that, options.$trigger.get(0).annotation._data.id);
+                                                       }
+                                               },
+                                               removeThread: {
+                                                       name: _('Remove 
Thread'),
+                                                       callback: function 
(key, options) {
+                                                               
that.onAnnotationRemoveThread.call(that, 
options.$trigger.get(0).annotation._data.id);
+                                                       }
+                                               },
+                                               resolve: that._docType !== 
'text' ? undefined : {
+                                                       name: 
$trigger.get(0).annotation._data.resolved === 'false' ? _('Resolve') : 
_('Unresolve'),
+                                                       callback: function 
(key, options) {
+                                                               
that.onAnnotationResolve.call(that, options.$trigger.get(0).annotation);
+                                                       }
+                                               },
+                                               resolveThread: that._docType 
!== 'text' ? undefined : {
+                                                       name: 
that.isThreadResolved($trigger.get(0).annotation) ? _('Unresolve Thread') : 
_('Resolve Thread'),
+                                                       callback: function 
(key, options) {
+                                                               
that.onAnnotationResolveThread.call(that, options.$trigger.get(0).annotation);
+                                                       }
+                                               }
+                                       },
+                               };
                        },
                        events: {
                                show: function (options) {
diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js 
b/loleaflet/src/layer/tile/WriterTileLayer.js
index f32ea37ab..1a0526b6c 100644
--- a/loleaflet/src/layer/tile/WriterTileLayer.js
+++ b/loleaflet/src/layer/tile/WriterTileLayer.js
@@ -78,6 +78,10 @@ L.WriterTileLayer = L.TileLayer.extend({
                this._annotations.resolveThread(annotation);
        },
 
+       isThreadResolved: function(annotation) {
+               return this._annotations._isThreadResolved(annotation);
+       },
+
        onChangeAccept: function(id) {
                this._annotations.acceptChange(id);
        },
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to