From 2c014ca49a91a8c05d065ca1530a87d86a731a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rijaniaina=20Elie=20Fid=C3=A8le?= <elierijaniaina@gmail.com> Date: Mon, 24 Feb 2025 15:41:18 +0300 Subject: [PATCH] re: remove contributor from kanban aap --- assets/js/aap/aap.js | 6 ++++++ assets/js/co.js | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/assets/js/aap/aap.js b/assets/js/aap/aap.js index a312386f9..d76c4e10a 100755 --- a/assets/js/aap/aap.js +++ b/assets/js/aap/aap.js @@ -6217,6 +6217,12 @@ var aapObj = { ajaxPost(null, url, post, function (html) { $('#action-modal-preview').empty().html(html); }, null, 'text'); + }, + onContributorRemove: arg => { + coInterface.actions.request_participation({ + action: arg.cardData.id, + contributors: arg.list.map(c => c.id), + }).then(r => toastr.success(JSON.stringify(r))); } }); $(document.body).off('action.set-contributor').on('action.set-contributor', function (event, data) { diff --git a/assets/js/co.js b/assets/js/co.js index 4d1c74d51..89af83918 100755 --- a/assets/js/co.js +++ b/assets/js/co.js @@ -1948,10 +1948,26 @@ var coInterface = { }, request_participation: function (args) { return new Promise(function (resolve, reject) { + const fn = "request_participation"; + if (typeof args !== 'object' || !args) - reject('Undefined argument'); - else if (typeof args.action === 'undefined' || typeof args.contributor === 'undefined') - reject('Argument error'); + reject({ + side: "client", + msg: "Argument format error", + fn, + }); + else if (typeof args.action === 'undefined') + reject({ + side: "client", + msg: "Undefined action id", + fn, + }); + else if (typeof args.contributor === "undefined" && typeof args.contributors === "undefined") + reject({ + side: "client", + msg: "Should provide contributor id(s)", + fn, + }); else { var url = baseUrl; if (typeof args.server_url === 'string') @@ -1959,13 +1975,17 @@ var coInterface = { url += '/costum/project/action/request/set_contributors'; var post = { action: args.action, - contributor: args.contributor, emiter: wsCO && wsCO.id ? wsCO.id : '' }; - if (typeof args.participate === 'number') - post.participate = args.participate; - else - post.participate = 0; + if (typeof args.contributors === "object") + post.contributors = args.contributors; + else if (typeof args.contributor === "string") { + post.contributor = args.contributor; + if (typeof args.participate === 'number') + post.participate = args.participate; + else + post.participate = 0; + } ajaxPost(null, url, post, resolve, reject); } }); -- GitLab