From aa8a5ab9950105154c9841deb319a3f001130f0c Mon Sep 17 00:00:00 2001 From: tobias <thinkdifferent055@gmail.com> Date: Fri, 6 Oct 2023 23:53:58 +0200 Subject: [PATCH] #187 - Add option to trigger cart by index --- actions.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/actions.js b/actions.js index d730f55..c03f571 100644 --- a/actions.js +++ b/actions.js @@ -8,17 +8,31 @@ module.exports = function (self) { type: 'textinput', label: 'Pad Name', default: '', + required: false + }, + { + id: 'index', + type: 'number', + label: 'Pad ID', + default: '', + required: false }, ], callback: async (event) => { - const pad = self.currentProject.findPadByName(event.options.name); - if (!pad) { - self.log('warning', 'Cannot find a pad with name ' + event.options.name); - return; + if (event.options.name) { + const pad = self.currentProject.findPadByName(event.options.name); + if (!pad) { + self.log('warning', 'Cannot find a pad with name ' + event.options.name); + return; + } + self.sendToWebSocket('cart-action', { + 'padId': pad.id + }); + } else if (event.options.index) { + self.sendToWebSocket('cart-action', { + 'padIndex': event.options.index - 1 + }); } - self.sendToWebSocket('cart-action', { - 'pad': pad.id - }); }, }, page_action: { -- GitLab