From 449dff8141c3e462c2f831a2a17dae28050c78e5 Mon Sep 17 00:00:00 2001 From: Corban-Lee Jones Date: Thu, 3 Oct 2024 12:50:11 +0100 Subject: [PATCH] render badges array column & model submit use PUT use PUT instead of PATCH --- apps/home/static/home/js/tables.js | 14 +++++++++++++- apps/home/static/home/js/tabs/subs.js | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/home/static/home/js/tables.js b/apps/home/static/home/js/tables.js index 114f5dd..4c75a0b 100644 --- a/apps/home/static/home/js/tables.js +++ b/apps/home/static/home/js/tables.js @@ -425,7 +425,7 @@ async function onModalSubmit($modal, $table, url) { const formData = objectToFormData(data); const id = $modal.data("primary-key"); const isNewItem = parseInt(id) !== -1; - const method = isNewItem ? "PATCH" : "POST"; + const method = isNewItem ? "PUT" : "POST"; url = isNewItem ? url + `${id}/` : url; ajaxRequest(url, method, formData) @@ -449,6 +449,18 @@ function renderBooleanColumn(data) { return ``; } +function renderArrayBadgesColumn(data) { + let badges = $("
"); + + data.forEach((item, index) => { + let badge = $(`${item}`); + if (index > 0) { badge.addClass("ms-2") } + badges.append(badge); + }); + + return badges.html(); +} + // region Get Table Parts diff --git a/apps/home/static/home/js/tabs/subs.js b/apps/home/static/home/js/tabs/subs.js index 18b817f..22d9e59 100644 --- a/apps/home/static/home/js/tabs/subs.js +++ b/apps/home/static/home/js/tabs/subs.js @@ -26,7 +26,8 @@ function initSubscriptionsModule() { }, { title: "Channels", - data: "channels", + data: "channels_detail", + render: data => renderArrayBadgesColumn(data.map(item => "#" + item.name)) }, { title: "Rules", @@ -244,7 +245,7 @@ function loadChannelOptions() { data.forEach(item => { $input.append($( "