[DE] Load and sort bookmarks.
This commit is contained in:
parent
f307c90ae8
commit
0808629f4a
|
@ -316,12 +316,13 @@ define([
|
||||||
onBookmarksClick: function(btn) {
|
onBookmarksClick: function(btn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
(new DE.Views.BookmarksDialog({
|
(new DE.Views.BookmarksDialog({
|
||||||
|
api: me.api,
|
||||||
|
props: me.api.asc_GetBookmarksManager(),
|
||||||
handler: function (result, settings) {
|
handler: function (result, settings) {
|
||||||
if (settings) {
|
if (settings) {
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||||
},
|
}
|
||||||
props: {}
|
|
||||||
})).show();
|
})).show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -130,21 +130,21 @@ define([
|
||||||
name: 'asc-radio-bookmark-sort',
|
name: 'asc-radio-bookmark-sort',
|
||||||
checked: true
|
checked: true
|
||||||
});
|
});
|
||||||
// this.radioName.on('change', _.bind(this.onRadioNameChange, this));
|
this.radioName.on('change', _.bind(this.onRadioSort, this));
|
||||||
|
|
||||||
this.radioLocation = new Common.UI.RadioBox({
|
this.radioLocation = new Common.UI.RadioBox({
|
||||||
el: $('#bookmarks-radio-location'),
|
el: $('#bookmarks-radio-location'),
|
||||||
labelText: this.textLocation,
|
labelText: this.textLocation,
|
||||||
name: 'asc-radio-bookmark-sort'
|
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({
|
this.bookmarksList = new Common.UI.ListView({
|
||||||
el: $('#bookmarks-list', this.$window),
|
el: $('#bookmarks-list', this.$window),
|
||||||
store: new Common.UI.DataViewStore()
|
store: new Common.UI.DataViewStore()
|
||||||
});
|
});
|
||||||
this.bookmarksList.store.comparator = function(rec) {
|
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('item:dblclick', _.bind(this.onDblClickFunction, this));
|
||||||
// this.bookmarksList.on('entervalue', _.bind(this.onPrimary, this));
|
// this.bookmarksList.on('entervalue', _.bind(this.onPrimary, this));
|
||||||
|
@ -158,10 +158,12 @@ define([
|
||||||
this.btnGoto = new Common.UI.Button({
|
this.btnGoto = new Common.UI.Button({
|
||||||
el: $('#bookmarks-btn-goto')
|
el: $('#bookmarks-btn-goto')
|
||||||
});
|
});
|
||||||
|
this.btnGoto.on('click', _.bind(this.gotoBookmark, this));
|
||||||
|
|
||||||
this.btnDelete = new Common.UI.Button({
|
this.btnDelete = new Common.UI.Button({
|
||||||
el: $('#bookmarks-btn-delete')
|
el: $('#bookmarks-btn-delete')
|
||||||
});
|
});
|
||||||
|
this.btnDelete.on('click', _.bind(this.deleteBookmark, this));
|
||||||
|
|
||||||
this.afterRender();
|
this.afterRender();
|
||||||
},
|
},
|
||||||
|
@ -176,6 +178,19 @@ define([
|
||||||
|
|
||||||
_setDefaults: function (props) {
|
_setDefaults: function (props) {
|
||||||
if (props) {
|
if (props) {
|
||||||
|
var store = this.bookmarksList.store,
|
||||||
|
count = props.get_Count(),
|
||||||
|
arr = [];
|
||||||
|
for (var i=0; i<count; i++) {
|
||||||
|
var rec = new Common.UI.DataViewModel();
|
||||||
|
rec.set({
|
||||||
|
value: props.get_Name(i),
|
||||||
|
location: i
|
||||||
|
});
|
||||||
|
arr.push(rec);
|
||||||
|
}
|
||||||
|
store.reset(arr, {silent: false});
|
||||||
|
this.bookmarksList.selectByIndex(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -196,6 +211,30 @@ define([
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
gotoBookmark: function(btn, eOpts){
|
||||||
|
var rec = this.bookmarksList.getSelectedRec();
|
||||||
|
if (rec.length>0) {
|
||||||
|
// 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',
|
textTitle: 'Bookmarks',
|
||||||
textLocation: 'Location',
|
textLocation: 'Location',
|
||||||
textBookmarkName: 'Bookmark name',
|
textBookmarkName: 'Bookmark name',
|
||||||
|
|
Loading…
Reference in a new issue