Fix 'delete all' button in forms owned by a team

This commit is contained in:
yflory 2022-12-21 13:28:29 +01:00
parent f01e21eac7
commit d5fefb5946
4 changed files with 10 additions and 8 deletions

View File

@ -571,8 +571,8 @@ define([
}, todo);
};
common.clearOwnedChannel = function (channel, cb) {
postMessage("CLEAR_OWNED_CHANNEL", channel, cb);
common.clearOwnedChannel = function (data, cb) {
postMessage("CLEAR_OWNED_CHANNEL", data, cb);
};
// "force" allows you to delete your drive ID
common.removeOwnedChannel = function (data, cb) {

View File

@ -342,10 +342,11 @@ define([
cb(account);
};
// clearOwnedChannel is only used for private chat at the moment
// clearOwnedChannel is only used for private chat and forms
Store.clearOwnedChannel = function (clientId, data, cb) {
if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
store.rpc.clearOwnedChannel(data, function (err) {
var s = getStore(data && data.teamId);
if (!s.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
s.rpc.clearOwnedChannel(data.channel, function (err) {
cb({error:err});
});
};

View File

@ -2752,7 +2752,8 @@ define([
UI.confirmButton(button, {classes:'danger'}, function () {
var sframeChan = framework._.sfCommon.getSframeChannel();
sframeChan.query('Q_FORM_DELETE_ALL_ANSWERS', {
channel: content.answers.channel
channel: content.answers.channel,
teamId: typeof(owned) === "number" ? owned : undefined
}, function (err, obj) {
if (err || (obj && obj.error)) { return void UI.warn(Messages.error); }
APP.getResults();

View File

@ -147,7 +147,7 @@ define([
accessKeys = _keys;
_keys.some(function (_k) {
if ((personalDrive && !_k.id) || Cryptpad.initialTeam === _k.id) {
if ((personalDrive && !_k.id) || Cryptpad.initialTeam === Number(_k.id)) {
myKeys = _k;
return true;
}
@ -412,7 +412,7 @@ define([
});
sframeChan.on("Q_FORM_DELETE_ALL_ANSWERS", function (data, cb) {
if (!data || !data.channel) { return void cb({error: 'EINVAL'}); }
Cryptpad.clearOwnedChannel(data.channel, cb);
Cryptpad.clearOwnedChannel(data, cb);
});
sframeChan.on("Q_FORM_DELETE_ANSWER", function (data, cb) {
if (!deleteLines) {