Новая страница: «<noinclude>{{Documentation}}</noinclude> <includeonly> <div class="songbook-container"> <div class="songbook-header"> <h1>{{{Title}}}</h1> <p>{{{Description}}}</p> <div class="songbook-actions"> <button class="add-song">Добавить песню</button> <button class="export-pdf">Экспорт в PDF</button> </div> <div class="song-search" style="display:none"> {{#forminput:form=AddSongToBook|autocomplete on categ...»
 
мНет описания правки
Строка 1: Строка 1:
<noinclude>{{Documentation}}</noinclude>
<includeonly>
<includeonly>
<div class="songbook-container">
<div class="songbook">
  <div class="songbook-header">
{{#cargo_query:
    <h1>{{{Title}}}</h1>
tables=SongbookEntries,Song
    <p>{{{Description}}}</p>
|join on=SongbookEntries.SongPage=Song._pageName
    <div class="songbook-actions">
|where=SongbookEntries.SongbookID="{{{SongbookID}}}"
      <button class="add-song">Добавить песню</button>
|order by=SongbookEntries.SortOrder
      <button class="export-pdf">Экспорт в PDF</button>
|fields=SongbookEntries.EntryID,
    </div>
        Song._pageName,
    <div class="song-search" style="display:none">
        Song.Name,
      {{#forminput:form=AddSongToBook|autocomplete on category=Песни}}
        Song.Text
    </div>
|format=template
  </div>
|template=SongbookItem
 
}}
  <div class="song-list" id="sortable-list">
    {{#cargo_query:
    tables=SongbookEntries__SongPage=SP,SongbookEntries=SE
    |join on=SE.SongPage=SP._pageName
    |where=SE.SongbookID="{{{SongbookID}}}"
    |order by=SE.SortOrder
    |fields=SE.EntryID, SP._pageName, SP.Name, SP.Text
    |format=template
    |template=SongbookItem
    }}
  </div>
</div>
</div>
<script>
// Drag-and-drop сортировка
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:08, 11 апреля 2025