мНет описания правки
мНет описания правки
Строка 4: Строка 4:
   <div class="songbook-header">
   <div class="songbook-header">
     <h1>{{{Title}}}</h1>
     <h1>{{{Title}}}</h1>
     <p>{{{Description}}}</p>
     <div class="songbook-meta">
      [[Участник:{{{User}}}|{{{User}}}]] •
      Создан: {{#time:d.m.Y H:i|{{{Created}}}}} •
      Обновлен: {{#time:d.m.Y H:i|{{{Updated}}}}} •
      {{#if:{{{IsPublic}}}|Публичный|Приватный}}
    </div>
   
     <div class="songbook-actions">
     <div class="songbook-actions">
       <button class="add-song">Добавить песню</button>
       {{#formlink:form=AddSongToBook
      <button class="export-pdf">Экспорт в PDF</button>
        |link text=Добавить песню
    </div>
        |link type=button
    <div class="song-search" style="display:none">
        |query string=SongbookID={{{SongbookID}}}
       {{#forminput:form=AddSongToBook|autocomplete on category=Песни}}
       }}
     </div>
     </div>
   </div>
   </div>


   <div class="song-list" id="sortable-list">
   <div class="song-list">
     {{#cargo_query:
     {{#cargo_query:
     tables=SongbookEntries
     tables=SongbookEntries
Строка 20: Строка 26:
     |where=SongbookEntries.SongbookID="{{{SongbookID}}}"
     |where=SongbookEntries.SongbookID="{{{SongbookID}}}"
     |order by=SongbookEntries.SortOrder
     |order by=SongbookEntries.SortOrder
     |fields=SongbookEntries.EntryID,  
     |fields=SongbookEntries.SongPage,
           SongbookEntries.SongPage
           song.Name,
     |format=template
          song.Composer
     |template=SongbookItem
     |format=ul
     |template=SongItem
     }}
     }}
   </div>
   </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>

Версия от 18:37, 11 апреля 2025

Документация