Link to a support ticket

pull/1/head
yflory 5 years ago
parent 093816cbb2
commit 5d1e1c975c

@ -172,6 +172,12 @@ define([
if (!supportKey || !APP.privateKey) { return; }
var $container = makeBlock('support-list');
var $div = $(h('div.cp-support-container')).appendTo($container);
var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
var cat = privateData.category || '';
var linkedId = cat.indexOf('-') !== -1 && cat.slice(8);
var hashesById = {};
var reorder = function () {
@ -200,6 +206,8 @@ define([
});
};
var to;
// Register to the "support" mailbox
common.mailbox.subscribe(['supportadmin'], {
onMessage: function (data) {
@ -246,6 +254,15 @@ define([
}
$ticket.append(APP.support.makeMessage(content, hash));
reorder();
if (linkedId) {
clearTimeout(to);
to = setTimeout(function () {
var $ticket = $div.find('.cp-support-list-ticket[data-id="'+linkedId+'"]');
$ticket[0].scrollIntoView();
linkedId = undefined;
}, 100);
}
}
});
return $container;
@ -312,6 +329,9 @@ define([
var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
var active = privateData.category || 'general';
if (active.indexOf('-') !== -1) {
active = active.split('-')[0];
}
common.setHash(active);
Object.keys(categories).forEach(function (key) {
var $category = $('<div>', {'class': 'cp-sidebarlayout-category'}).appendTo($categories);

@ -5,8 +5,9 @@ define([
'/common/common-interface.js',
'/common/common-hash.js',
'/common/common-util.js',
'/common/clipboard.js',
'/customize/messages.js',
], function ($, ApiConfig, h, UI, Hash, Util, Messages) {
], function ($, ApiConfig, h, UI, Hash, Util, Clipboard, Messages) {
var send = function (ctx, id, type, data, dest) {
var common = ctx.common;
@ -119,6 +120,10 @@ define([
};
var makeTicket = function (ctx, $div, content, onHide) {
var common = ctx.common;
var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
var ticketTitle = content.title + ' (#' + content.id + ')';
var answer = h('button.btn.btn-primary.cp-support-answer', Messages.support_answer);
var close = h('button.btn.btn-danger.cp-support-close', Messages.support_close);
@ -130,10 +135,20 @@ define([
hide
]);
var url;
if (ctx.isAdmin) {
url = h('button.btn.btn-primary.fa.fa-clipboard');
$(url).click(function () {
var link = privateData.origin + privateData.pathname + '#' + 'support-' + content.id;
var success = Clipboard.copy(link);
if (success) { UI.log(Messages.shareSuccess); }
});
}
var $ticket = $(h('div.cp-support-list-ticket', {
'data-id': content.id
}, [
h('h2', ticketTitle),
h('h2', [ticketTitle, url]),
actions
]));

Loading…
Cancel
Save