From 5bc95511e56af7cb4809dd8b2e4e9aedf275d63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Manelli?= Date: Wed, 30 Aug 2017 00:52:55 -0300 Subject: Allow delete from client. List all integrations in web UI --- client/components/boards/boardHeader.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'client/components/boards/boardHeader.js') diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index 2ee21905..b7807ca9 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -241,39 +241,44 @@ BlazeComponent.extendComponent({ }).register('boardChangeWatchPopup'); BlazeComponent.extendComponent({ - integration() { + integrations() { const boardId = Session.get('currentBoard'); - return Integrations.findOne({ boardId: `${boardId}` }); + return Integrations.find({ boardId: `${boardId}` }).fetch(); + }, + + integration(id) { + const boardId = Session.get('currentBoard'); + return Integrations.findOne({ _id: id, boardId: `${boardId}` }); }, events() { return [{ 'submit'(evt) { evt.preventDefault(); - const url = this.find('.js-outgoing-webhooks-url').value.trim(); + const url = evt.target.url.value; const boardId = Session.get('currentBoard'); - const integration = this.integration(); - if (integration) { + let id = null; + let integration = null; + if (evt.target.id) { + id = evt.target.id.value; + integration = this.integration(id); if (url) { Integrations.update(integration._id, { $set: { - enabled: true, url: `${url}`, }, }); } else { - Integrations.update(integration._id, { - $set: { - enabled: false, - }, - }); + Integrations.remove(integration._id); } } else if (url) { Integrations.insert({ + userId: Meteor.userId(), enabled: true, type: 'outgoing-webhooks', url: `${url}`, boardId: `${boardId}`, + activities: ['all'], }); } Popup.close(); -- cgit v1.2.3-1-g7c22