From 0808629f4a41b7983ec79434d8047762ea58ae5b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 27 Mar 2018 15:21:15 +0300 Subject: [PATCH] [DE] Load and sort bookmarks. --- .../main/app/controller/Links.js | 5 ++- .../main/app/view/BookmarksDialog.js | 45 +++++++++++++++++-- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 148632a4a..cadc512f2 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -316,12 +316,13 @@ define([ onBookmarksClick: function(btn) { var me = this; (new DE.Views.BookmarksDialog({ + api: me.api, + props: me.api.asc_GetBookmarksManager(), handler: function (result, settings) { if (settings) { } Common.NotificationCenter.trigger('edit:complete', me.toolbar); - }, - props: {} + } })).show(); }, diff --git a/apps/documenteditor/main/app/view/BookmarksDialog.js b/apps/documenteditor/main/app/view/BookmarksDialog.js index d2169905c..3a41364c6 100644 --- a/apps/documenteditor/main/app/view/BookmarksDialog.js +++ b/apps/documenteditor/main/app/view/BookmarksDialog.js @@ -130,21 +130,21 @@ define([ name: 'asc-radio-bookmark-sort', checked: true }); - // this.radioName.on('change', _.bind(this.onRadioNameChange, this)); + this.radioName.on('change', _.bind(this.onRadioSort, this)); this.radioLocation = new Common.UI.RadioBox({ el: $('#bookmarks-radio-location'), labelText: this.textLocation, name: 'asc-radio-bookmark-sort' }); - // this.radioName.on('change', _.bind(this.onRadioNameChange, this)); + this.radioLocation.on('change', _.bind(this.onRadioSort, this)); this.bookmarksList = new Common.UI.ListView({ el: $('#bookmarks-list', this.$window), store: new Common.UI.DataViewStore() }); this.bookmarksList.store.comparator = function(rec) { - return (me.radioName.getValue() ? rec.get("name") : rec.get("location")); + return (me.radioName.getValue() ? rec.get("value") : rec.get("location")); }; // this.bookmarksList.on('item:dblclick', _.bind(this.onDblClickFunction, this)); // this.bookmarksList.on('entervalue', _.bind(this.onPrimary, this)); @@ -158,10 +158,12 @@ define([ this.btnGoto = new Common.UI.Button({ el: $('#bookmarks-btn-goto') }); + this.btnGoto.on('click', _.bind(this.gotoBookmark, this)); this.btnDelete = new Common.UI.Button({ el: $('#bookmarks-btn-delete') }); + this.btnDelete.on('click', _.bind(this.deleteBookmark, this)); this.afterRender(); }, @@ -176,6 +178,19 @@ define([ _setDefaults: function (props) { if (props) { + var store = this.bookmarksList.store, + count = props.get_Count(), + arr = []; + for (var i=0; i0) { + // this.api.gotoBookmark(rec.get('value')); + } + }, + + deleteBookmark: function(btn, eOpts){ + var rec = this.bookmarksList.getSelectedRec(); + if (rec.length>0) { + // this.api.deleteBookmark(rec.get('value')); + var store = this.bookmarksList.store; + var idx = _.indexOf(store.models, rec[0]); + store.remove(rec[0]); + } + }, + + onRadioSort: function(field, newValue, eOpts) { + if (newValue) { + this.bookmarksList.store.sort(); + this.bookmarksList.onResetItems(); + } + }, + textTitle: 'Bookmarks', textLocation: 'Location', textBookmarkName: 'Bookmark name',