render badges array column & model submit use PUT
use PUT instead of PATCH
This commit is contained in:
parent
2da4018483
commit
449dff8141
@ -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 `<i class="bi ${iconClass}"></i>`;
|
||||
}
|
||||
|
||||
function renderArrayBadgesColumn(data) {
|
||||
let badges = $("<div>");
|
||||
|
||||
data.forEach((item, index) => {
|
||||
let badge = $(`<span class="badge text-bg-secondary rounded-1">${item}</span>`);
|
||||
if (index > 0) { badge.addClass("ms-2") }
|
||||
badges.append(badge);
|
||||
});
|
||||
|
||||
return badges.html();
|
||||
}
|
||||
|
||||
|
||||
// region Get Table Parts
|
||||
|
||||
|
@ -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($(
|
||||
"<option>",
|
||||
{text: `#${item.name}`, value: BigInt(item.id)}
|
||||
{text: `#${item.name}`, value: item.id}
|
||||
));
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user