[DE] Bookmarks: get link to bookmark

This commit is contained in:
Julia Radzhabova 2019-03-18 16:03:26 +03:00
parent cee89671b6
commit b66389da09
3 changed files with 33 additions and 4 deletions

View file

@ -79,8 +79,15 @@ define([
prcontrolsdisable:undefined prcontrolsdisable:undefined
}; };
Common.Gateway.on('setactionlink', function (url) { Common.Gateway.on('setactionlink', function (url) {
console.log('url with actions: ' + url); var copytext = document.createElement('input');
}.bind(this)); copytext.value = url;
document.body.appendChild(copytext);
copytext.select();
try {
document.execCommand("copy");
} catch (err) {}
document.body.removeChild(copytext);
});
}, },
setApi: function (api) { setApi: function (api) {
@ -328,6 +335,7 @@ define([
var me = this; var me = this;
(new DE.Views.BookmarksDialog({ (new DE.Views.BookmarksDialog({
api: me.api, api: me.api,
appOptions: me.toolbar.appOptions,
props: me.api.asc_GetBookmarksManager(), props: me.api.asc_GetBookmarksManager(),
handler: function (result, settings) { handler: function (result, settings) {
if (settings) { if (settings) {

View file

@ -90,7 +90,8 @@ define([
'<tr>', '<tr>',
'<td class="padding-large">', '<td class="padding-large">',
'<button type="button" class="btn btn-text-default" id="bookmarks-btn-goto" style="margin-right: 10px;">', me.textGoto,'</button>', '<button type="button" class="btn btn-text-default" id="bookmarks-btn-goto" style="margin-right: 10px;">', me.textGoto,'</button>',
'<button type="button" class="btn btn-text-default" id="bookmarks-btn-delete" style="">', me.textDelete,'</button>', '<button type="button" class="btn btn-text-default" id="bookmarks-btn-delete" style="margin-right: 10px;">', me.textDelete,'</button>',
'<button type="button" class="btn btn-text-default" id="bookmarks-btn-link" style="">', me.textGetLink,'</button>',
'</td>', '</td>',
'</tr>', '</tr>',
'<tr>', '<tr>',
@ -111,6 +112,7 @@ define([
this.api = options.api; this.api = options.api;
this.handler = options.handler; this.handler = options.handler;
this.props = options.props; this.props = options.props;
this.appOptions = options.appOptions;
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
}, },
@ -137,6 +139,7 @@ define([
me.btnAdd.setDisabled(!check && !exist); me.btnAdd.setDisabled(!check && !exist);
me.btnGoto.setDisabled(!exist); me.btnGoto.setDisabled(!exist);
me.btnDelete.setDisabled(!exist); me.btnDelete.setDisabled(!exist);
me.btnGetLink.setDisabled(!exist);
return (check || _.isEmpty(value)) ? true : me.txtInvalidName; return (check || _.isEmpty(value)) ? true : me.txtInvalidName;
} }
@ -187,6 +190,12 @@ define([
}); });
this.btnDelete.on('click', _.bind(this.deleteBookmark, this)); this.btnDelete.on('click', _.bind(this.deleteBookmark, this));
this.btnGetLink = new Common.UI.Button({
el: $('#bookmarks-btn-link'),
disabled: true
});
this.btnGetLink.on('click', _.bind(this.getBookmarkLink, this));
this.chHidden = new Common.UI.CheckBox({ this.chHidden = new Common.UI.CheckBox({
el: $('#bookmarks-checkbox-hidden'), el: $('#bookmarks-checkbox-hidden'),
labelText: this.textHidden, labelText: this.textHidden,
@ -220,6 +229,7 @@ define([
_setDefaults: function (props) { _setDefaults: function (props) {
this.refreshBookmarks(); this.refreshBookmarks();
this.bookmarksList.scrollToRecord(this.bookmarksList.selectByIndex(0)); this.bookmarksList.scrollToRecord(this.bookmarksList.selectByIndex(0));
this.btnGetLink.setVisible(this.appOptions.canMakeActionLink);
}, },
getSettings: function () { getSettings: function () {
@ -266,6 +276,7 @@ define([
this.btnAdd.setDisabled(false); this.btnAdd.setDisabled(false);
this.btnGoto.setDisabled(false); this.btnGoto.setDisabled(false);
this.btnDelete.setDisabled(false); this.btnDelete.setDisabled(false);
this.btnGetLink.setDisabled(false);
}, },
gotoBookmark: function(btn, eOpts){ gotoBookmark: function(btn, eOpts){
@ -290,6 +301,14 @@ define([
this.btnAdd.setDisabled(true); this.btnAdd.setDisabled(true);
this.btnGoto.setDisabled(true); this.btnGoto.setDisabled(true);
this.btnDelete.setDisabled(true); this.btnDelete.setDisabled(true);
this.btnGetLink.setDisabled(true);
}
},
getBookmarkLink: function() {
var rec = this.bookmarksList.getSelectedRec();
if (rec.length>0) {
Common.Gateway.requestMakeActionLink({action: "bookmark", data: rec[0].get('value')});
} }
}, },
@ -314,7 +333,8 @@ define([
textDelete: 'Delete', textDelete: 'Delete',
textClose: 'Close', textClose: 'Close',
textHidden: 'Hidden bookmarks', textHidden: 'Hidden bookmarks',
txtInvalidName: 'Bookmark name can only contain letters, digits and underscores, and should begin with the letter' txtInvalidName: 'Bookmark name can only contain letters, digits and underscores, and should begin with the letter',
textGetLink: 'Get link'
}, DE.Views.BookmarksDialog || {})) }, DE.Views.BookmarksDialog || {}))
}); });

View file

@ -1009,6 +1009,7 @@
"DE.Views.BookmarksDialog.textName": "Name", "DE.Views.BookmarksDialog.textName": "Name",
"DE.Views.BookmarksDialog.textSort": "Sort by", "DE.Views.BookmarksDialog.textSort": "Sort by",
"DE.Views.BookmarksDialog.textTitle": "Bookmarks", "DE.Views.BookmarksDialog.textTitle": "Bookmarks",
"DE.Views.BookmarksDialog.textGetLink": "Get link",
"DE.Views.BookmarksDialog.txtInvalidName": "Bookmark name can only contain letters, digits and underscores, and should begin with the letter", "DE.Views.BookmarksDialog.txtInvalidName": "Bookmark name can only contain letters, digits and underscores, and should begin with the letter",
"DE.Views.ChartSettings.textAdvanced": "Show advanced settings", "DE.Views.ChartSettings.textAdvanced": "Show advanced settings",
"DE.Views.ChartSettings.textArea": "Area", "DE.Views.ChartSettings.textArea": "Area",