Новая страница: «<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...»
 
мНет описания правки
 
(не показано 7 промежуточных версий этого же участника)
Строка 1: Строка 1:
<noinclude>{{Documentation}}</noinclude>
<noinclude>{{Documentation}}</noinclude>
<includeonly>
<includeonly>
<div class="songbook-container">
<div class="songbook">
   <div class="songbook-header">
  <!-- Метаданные -->
     <h1>{{{Title}}}</h1>
   <div class="songbook-meta">
     <p>{{{Description}}}</p>
     Владелец: [[User:{{{User}}}|{{{User}}}]]<br>
     <div class="songbook-actions">
     Создан: {{{Created}}}<br>
      <button class="add-song">Добавить песню</button>
     Обновлен: {{{Updated}}}<br>
      <button class="export-pdf">Экспорт в PDF</button>
     Статус: {{#if:{{{IsPublic}}}|Публичный|Приватный}}
     </div>
    <div class="song-search" style="display:none">
      {{#forminput:form=AddSongToBook|autocomplete on category=Песни}}
    </div>
   </div>
   </div>


   <div class="song-list" id="sortable-list">
  <!-- Описание -->
     {{#cargo_query:
   <div class="songbook-description">
    tables=SongbookEntries__SongPage=SP,SongbookEntries=SE
    <h3>Описание</h3>
    |join on=SE.SongPage=SP._pageName
    {{{Description|Нет описания}}}
    |where=SE.SongbookID="{{{SongbookID}}}"
  </div>
    |order by=SE.SortOrder
 
    |fields=SE.EntryID, SP._pageName, SP.Name, SP.Text
  <!-- Кнопка добавления -->
    |format=template
  <div class="songbook-actions">
    |template=SongbookItem
     {{#formlink:form=AddSongToBook
      |link text=Добавить песню
      |link type=button
      |query string=SongbookID={{{SongbookID}}}
     }}
     }}
  </div>
  <!-- Список песен -->
  <div class="song-list">
{{#cargo_query:
tables=SongbookEntries
|join on=SongbookEntries.SongPage=song._pageName
|where=SongbookEntries.SongbookID="{{{SongbookID}}}"
|order by=SortOrder
|fields=SongbookEntries.SongPage,
      song.Name,
      song.Composer
|format=ul
<!-- |template=SongItem-->
}}
   </div>
   </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>

Текущая версия от 19:39, 11 апреля 2025

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