mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
New support: delete user ticket
This commit is contained in:
parent
0900216d57
commit
e26ed382fa
@ -241,6 +241,7 @@ define([
|
||||
else { t.messages = messages; }
|
||||
|
||||
if (messages[messages.length -1].close) {
|
||||
ctx.supportData[ticket].closed = true;
|
||||
t.closed = true;
|
||||
}
|
||||
|
||||
@ -273,6 +274,13 @@ define([
|
||||
cb({closed: true});
|
||||
});
|
||||
};
|
||||
var deleteMyTicket = function (ctx, data, cId, cb) {
|
||||
let support = ctx.supportData;
|
||||
let channel = data.channel;
|
||||
if (!support[channel] || !support[channel].closed) { return void cb({error: 'ENOTCLOSED'}); }
|
||||
delete support[channel];
|
||||
cb({deleted: true});
|
||||
};
|
||||
|
||||
// ADMIN COMMANDS
|
||||
|
||||
@ -422,6 +430,11 @@ define([
|
||||
};
|
||||
var updateUserTicket = function (ctx, data) {
|
||||
notifyClient(ctx, false, 'UPDATE_TICKET', data.channel);
|
||||
if (data.isClose) {
|
||||
let ticket = ctx.supportData[data.channel];
|
||||
if (!ticket) { return; }
|
||||
ticket.closed = true;
|
||||
}
|
||||
};
|
||||
|
||||
// INITIALIZE ADMIN
|
||||
@ -558,6 +571,9 @@ define([
|
||||
if (cmd === 'CLOSE_TICKET') {
|
||||
return void closeMyTicket(ctx, data, clientId, cb);
|
||||
}
|
||||
if (cmd === 'DELETE_TICKET') {
|
||||
return void deleteMyTicket(ctx, data, clientId, cb);
|
||||
}
|
||||
cb({error: 'NOT_SUPPORTED'});
|
||||
};
|
||||
|
||||
|
||||
@ -187,6 +187,15 @@ define([
|
||||
refresh();
|
||||
});
|
||||
};
|
||||
const onDelete = function (ticket, channel, data) {
|
||||
APP.supportModule.execCommand('DELETE_TICKET', {
|
||||
channel: channel
|
||||
}, function (obj) {
|
||||
console.error(obj);
|
||||
if (obj && obj.error) { return void UI.warn(Messages.error); }
|
||||
refresh();
|
||||
});
|
||||
};
|
||||
|
||||
APP.supportModule.execCommand('GET_MY_TICKETS', {}, function (obj) {
|
||||
if (obj && obj.error) {
|
||||
@ -213,7 +222,7 @@ define([
|
||||
id: data.id,
|
||||
content: data,
|
||||
form: activeForms[data.id],
|
||||
onClose, onReply
|
||||
onClose, onReply, onDelete
|
||||
});
|
||||
$list.append(ticket);
|
||||
let $ticket = $(ticket);
|
||||
|
||||
@ -319,14 +319,21 @@ define([
|
||||
};
|
||||
|
||||
var makeTicket = function (ctx, opts) {
|
||||
let { id, content, form, onShow, onHide, onClose, onReply, onForm } = opts;
|
||||
let { id, content, form, onShow, onHide, onClose, onReply, onForm, onDelete } = opts;
|
||||
var common = ctx.common;
|
||||
var metadataMgr = common.getMetadataMgr();
|
||||
var privateData = metadataMgr.getPrivateData();
|
||||
|
||||
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);
|
||||
var actions = h('div.cp-support-list-actions', [ answer, close ]);
|
||||
var remove = h('button.btn.btn-danger.cp-support-hide', Messages.support_remove);
|
||||
var _actions = [answer, close];
|
||||
|
||||
if (content.closed && !ctx.isAdmin) {
|
||||
_actions = [remove]; // XXX update key to "Delete permanently" ?
|
||||
}
|
||||
|
||||
var actions = h('div.cp-support-list-actions', _actions);
|
||||
|
||||
var adminActions;
|
||||
var adminClasses = '';
|
||||
@ -397,6 +404,13 @@ define([
|
||||
onClose(ticket, id, content);
|
||||
});
|
||||
|
||||
UI.confirmButton(remove, {
|
||||
classes: 'btn-danger'
|
||||
}, function() {
|
||||
$(remove).remove();
|
||||
onDelete(ticket, id, content);
|
||||
});
|
||||
|
||||
var addForm = function () {
|
||||
$ticket.find('.cp-support-form-container').remove();
|
||||
$(actions).hide();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user