Skip to content

Commit

Permalink
Add option to disable paging called One Page
Browse files Browse the repository at this point in the history
  • Loading branch information
pehala committed Jan 19, 2024
1 parent f6f9aa2 commit 945a740
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 33 deletions.
18 changes: 11 additions & 7 deletions backend/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-12 15:11+0000\n"
"POT-Creation-Date: 2024-01-19 18:35+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -120,27 +120,31 @@ msgstr "Skrýt akordy"
msgid "Prevent sleep"
msgstr "Zabránit uspání"

#: backend/templates/songs/index.html:56
#: backend/templates/songs/index.html:37
msgid "Single page"
msgstr "Bez stránek"

#: backend/templates/songs/index.html:62
msgid "Actions"
msgstr "Akce"

#: backend/templates/songs/index.html:61
#: backend/templates/songs/index.html:67
msgid "Edit"
msgstr "Editor"

#: backend/templates/songs/index.html:64
#: backend/templates/songs/index.html:70
msgid "Delete"
msgstr "Smazat"

#: backend/templates/songs/index.html:78
#: backend/templates/songs/index.html:84
msgid "Transpose"
msgstr "Transponovat"

#: backend/templates/songs/index.html:97
#: backend/templates/songs/index.html:103
msgid "Search"
msgstr "Vyhledávání"

#: backend/templates/songs/index.html:99
#: backend/templates/songs/index.html:105
msgid "Number, text or author"
msgstr "Číslo, text nebo autor"

Expand Down
37 changes: 25 additions & 12 deletions backend/templates/songs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<label class="form-check-label custom" for="preventSleep">{% trans "Prevent sleep" %}</label>
</div>
</div>
<div class="me-2 mt-1 d-flex">
<div><input class="form-check-input ms-2" type="checkbox" value="" id="onePage"></div>
<div class="ms-auto">
<label class="form-check-label custom" for="onePage">{% trans "Single page" %}</label>
</div>
</div>
{% endblock %}
{% block body %}
<script async>
Expand Down Expand Up @@ -114,17 +120,12 @@ <h6 class="d-inline" ><%:author%></h6>
import {Options, BooleanOption} from "{% static 'js/Options.js' %}"
const canWakeLock = () => 'wakeLock' in navigator;

{% if user.is_authenticated %}
const baseEditUrl = "{% url "chords:edit" pk="0" %}?next={{ request.path }}"
const baseDeleteUrl = "{% url "chords:delete" pk="0" %}?next={{ request.path }}"
{% endif %}

$.views.settings.delimiters("<%", "%>");
$.fn.DataTable.ext.pager.numbers_length = 5;
$.templates("song", "#songTemplate")
const table = $('#datatable').DataTable({
let table = null
function createDatatable(paging) {
return $('#datatable').DataTable({
processing: true,
select: false,
paging: paging,
deferRender: true,
drawCallback: function () {
const selector = $(".raw[type='number']")
Expand Down Expand Up @@ -173,6 +174,15 @@ <h6 class="d-inline" ><%:author%></h6>
pageLength: 50,
{% datatables_language %}
});
}
{% if user.is_authenticated %}
const baseEditUrl = "{% url "chords:edit" pk="0" %}?next={{ request.path }}"
const baseDeleteUrl = "{% url "chords:delete" pk="0" %}?next={{ request.path }}"
{% endif %}

$.views.settings.delimiters("<%", "%>");
$.fn.DataTable.ext.pager.numbers_length = 5;
$.templates("song", "#songTemplate")

document.addEventListener('DOMContentLoaded', function () {
const back_to_top = $('#back-to-top')
Expand Down Expand Up @@ -229,7 +239,12 @@ <h6 class="d-inline" ><%:author%></h6>
["hide_chords", new BooleanOption(document.getElementById("hideChords"), hideChords, false)],
["prevent_sleep", new BooleanOption(document.getElementById("preventSleep"), function(value) {
preventSleep(value).then()
}, false)]
}, false)],
["one_page", new BooleanOption(document.getElementById("onePage"), function(value) {
if (table)
table.destroy()
table = createDatatable(!value)
}, false)],
])
const options = new Options(config)

Expand All @@ -240,7 +255,6 @@ <h6 class="d-inline" ><%:author%></h6>
})
}


table.on( 'draw', function () {
if (hidden) {
$(".chord").hide()
Expand All @@ -250,7 +264,6 @@ <h6 class="d-inline" ><%:author%></h6>

});


});

document.getElementById("searchInput").addEventListener("input", function (event) {
Expand Down
28 changes: 14 additions & 14 deletions tenants/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-12 15:18+0000\n"
"POT-Creation-Date: 2024-01-19 18:35+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -23,7 +23,7 @@ msgstr ""
msgid "Tenant"
msgstr "Zpěvník"

#: tenants/menus.py:27 tenants/models.py:30
#: tenants/menus.py:27 tenants/models.py:31
msgid "All Songs"
msgstr "Všechno"

Expand All @@ -35,53 +35,53 @@ msgstr "Soubory"
msgid "Categories"
msgstr "Kategorie"

#: tenants/models.py:12
#: tenants/models.py:13
msgid "Only PNG images are allowed"
msgstr "Jen PNG obrázky jsou podporovány"

#: tenants/models.py:19
#: tenants/models.py:20
msgid "Hostname"
msgstr "Doménové jméno"

#: tenants/models.py:19
#: tenants/models.py:20
msgid "The exact hostname for this Tenant"
msgstr "Přesné doménové jméno pod kterým bude Zpěvník dostupný"

#: tenants/models.py:21
#: tenants/models.py:22
msgid "Name"
msgstr "Jméno"

#: tenants/models.py:21
#: tenants/models.py:22
msgid "Internal name for this Tenant"
msgstr "Interní název tohoto Zpevníku"

#: tenants/models.py:22
#: tenants/models.py:23
msgid "Title"
msgstr "Titulek"

#: tenants/models.py:22
#: tenants/models.py:23
msgid "Title on the Main site"
msgstr "Titulek na hlavní stránce"

#: tenants/models.py:24
#: tenants/models.py:25
msgid "Index redirect path"
msgstr "Cíl přesměrování úvodní stránky"

#: tenants/models.py:25
#: tenants/models.py:26
msgid ""
"Where should new tenant redirect from index page, usually a category slug"
msgstr ""
"Kam by měla úvodní stránka přesměrovat uživatele, většinou URL kategorie"

#: tenants/models.py:31
#: tenants/models.py:32
msgid "True, if all songs category should be added to navigation"
msgstr "Pokud je zaškrknuto tak se do navigace přidá odkaz na všechny písničky"

#: tenants/models.py:34
#: tenants/models.py:35
msgid "Logo"
msgstr ""

#: tenants/models.py:35
#: tenants/models.py:36
msgid "Optional Site logo, should be around 50x50 and in PNG format"
msgstr ""
"Logo zpěvníčku, nepovinné, mělo by mít rozměry kolem 50x50 a být v PNG "
Expand Down

0 comments on commit 945a740

Please sign in to comment.