Relabel var_idx after reordering extra keys

This commit is contained in:
Kijin Sung 2025-05-23 15:19:03 +09:00
parent 4155f9fe9c
commit e5ea2e5a6d
2 changed files with 9 additions and 2 deletions

View file

@ -129,7 +129,7 @@
<td>
<div class="wrap" style="user-select:none">
<button type="button" class="dragBtn">Move to</button>
{$val->idx}
<span class="var_idx">{$val->idx}</span>
</div>
</td>
<td>{$val->eid}</td>

View file

@ -3,9 +3,10 @@
// Reorder extra keys
$('table.extra_keys.sortable').on('after-drag.st', function(e) {
const $table = $(this);
let order = [];
let i = 1;
$(this).find('tbody > tr').each(function() {
$table.find('tbody > tr').each(function() {
order.push({
eid: $(this).data('eid'),
old_idx: parseInt($(this).data('idx'), 10),
@ -15,6 +16,12 @@
Rhymix.ajax('document.procDocumentAdminReorderExtraVars', {
module_srl: $(this).data('moduleSrl'),
order: order
}, function() {
let i = 1;
$table.find('.var_idx').each(function() {
$(this).text(i);
i++;
});
});
});