From 0fe99ae652ae3cf4025e27bc82448a38a18a04f5 Mon Sep 17 00:00:00 2001 From: Corban-Lee Jones Date: Sun, 20 Oct 2024 14:32:01 +0100 Subject: [PATCH] open related message style --- apps/home/static/home/js/tables.js | 14 ++++++++++++++ apps/home/static/home/js/tabs/subs.js | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/home/static/home/js/tables.js b/apps/home/static/home/js/tables.js index 451406b..b6bd107 100644 --- a/apps/home/static/home/js/tables.js +++ b/apps/home/static/home/js/tables.js @@ -565,6 +565,20 @@ function renderMutatorColumn(data) { return $(`${data.name}`).prop("outerHTML"); } +const renderLinkToStyleColumn = style => { + if (!style.is_embed) { + return ""; + } + + const hexWithHashtag = `#${style.colour}`.toUpperCase(); + + let icon = $("
"); + icon.addClass("col-hex-icon js-openSubStyle"); + icon.css("background-color", hexWithHashtag); + + return $(`${icon.prop("outerHTML")}`).tooltip()[0]; +} + const renderPopoverBadgesColumn = (items, iconClass) => { if (!items.length) { return ""; diff --git a/apps/home/static/home/js/tabs/subs.js b/apps/home/static/home/js/tabs/subs.js index 76b962f..7c40c04 100644 --- a/apps/home/static/home/js/tabs/subs.js +++ b/apps/home/static/home/js/tabs/subs.js @@ -43,7 +43,7 @@ function initSubscriptionsModule() { title: "Style", data: "message_style_detail", className: "col-hex", - render: data => renderHexColourColumn(data.colour, null, data) + render: renderLinkToStyleColumn }, { title: "Created At", @@ -288,4 +288,17 @@ async function loadChannelOptions() { }) $input.prop("disabled", false); -} \ No newline at end of file +} + + +// region Open Sub Style + +$(subTableId).on("click", ".js-openSubStyle", async event => { + const subTable = $(subTableId).DataTable(); + const row = subTable.row($(event.currentTarget).closest("tr")); + const styleId = row.data().message_style + + // Open styles tab and styles modal + $("#stylesTab").click(); + await openDataModal(styleModalId, styleId); +});