Шаблон:SongbookView: различия между версиями
Grayenot (обсуждение | вклад) мНет описания правки |
Grayenot (обсуждение | вклад) мНет описания правки |
||
| Строка 1: | Строка 1: | ||
<noinclude>{{Documentation}}</noinclude> | |||
<includeonly> | <includeonly> | ||
<div class="songbook"> | <div class="songbook-container"> | ||
{{#cargo_query: | <div class="songbook-header"> | ||
tables=SongbookEntries | <h1>{{{Title}}}</h1> | ||
|join on=SongbookEntries.SongPage=song._pageName | <p>{{{Description}}}</p> | ||
|where=SongbookEntries.SongbookID="{{{SongbookID}}}" | <div class="songbook-actions"> | ||
|order by=SongbookEntries.SortOrder | <button class="add-song">Добавить песню</button> | ||
|fields=SongbookEntries.EntryID, | <button class="export-pdf">Экспорт в PDF</button> | ||
</div> | |||
<div class="song-search" style="display:none"> | |||
{{#forminput:form=AddSongToBook|autocomplete on category=Песни}} | |||
|format=template | </div> | ||
|template=SongbookItem | </div> | ||
}} | |||
<div class="song-list" id="sortable-list"> | |||
{{#cargo_query: | |||
tables=SongbookEntries | |||
|join on=SongbookEntries.SongPage=song._pageName | |||
|where=SongbookEntries.SongbookID="{{{SongbookID}}}" | |||
|order by=SongbookEntries.SortOrder | |||
|fields=SongbookEntries.EntryID, | |||
SongbookEntries.SongPage | |||
|format=template | |||
|template=SongbookItem | |||
}} | |||
</div> | |||
</div> | </div> | ||
<script> | |||
document.addEventListener('DOMContentLoaded', function() { | |||
new Sortable(document.getElementById('sortable-list'), { | |||
animation: 150, | |||
onUpdate: function(evt) { | |||
const entries = Array.from(evt.from.children).map((item, index) => ({ | |||
entryId: item.dataset.entryId, | |||
order: index + 1 | |||
})); | |||
new mw.Api().postWithToken('csrf', { | |||
action: 'cargoupdate', | |||
table: 'SongbookEntries', | |||
updates: entries.map(e => `SortOrder=${e.order} WHERE EntryID="${e.entryId}"`) | |||
}); | |||
} | |||
}); | |||
}); | |||
</script> | |||
</includeonly> | </includeonly> | ||
Версия от 16:38, 11 апреля 2025
Документация
создать |
Этому шаблону не хватает документации.