mirror of
https://github.com/ae-utbm/sith.git
synced 2025-03-10 07:17:11 +00:00
typescriptify album-index.js
This commit is contained in:
parent
98175e397c
commit
aede74b908
@ -1,10 +1,6 @@
|
|||||||
import { paginated } from "#core:utils/api";
|
import { paginated } from "#core:utils/api";
|
||||||
import { History, initialUrlParams, updateQueryString } from "#core:utils/history";
|
import { History, initialUrlParams, updateQueryString } from "#core:utils/history";
|
||||||
import {
|
import { type PictureSchema, type PicturesFetchPicturesData, picturesFetchPictures } from "#openapi";
|
||||||
type PictureSchema,
|
|
||||||
type PicturesFetchPicturesData,
|
|
||||||
picturesFetchPictures,
|
|
||||||
} from "#openapi";
|
|
||||||
|
|
||||||
interface AlbumConfig {
|
interface AlbumConfig {
|
||||||
albumId: number;
|
albumId: number;
|
||||||
@ -17,12 +13,14 @@ document.addEventListener("alpine:init", () => {
|
|||||||
page: Number.parseInt(initialUrlParams.get("page")) || 1,
|
page: Number.parseInt(initialUrlParams.get("page")) || 1,
|
||||||
pushstate: History.Push /* Used to avoid pushing a state on a back action */,
|
pushstate: History.Push /* Used to avoid pushing a state on a back action */,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
config: config,
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
await this.fetchPictures();
|
await this.fetchPictures();
|
||||||
this.$watch("page", () => {
|
this.$watch("page", () => {
|
||||||
updateQueryString("page", this.page === 1 ? null : this.page, this.pushstate);
|
updateQueryString("page", this.page === 1 ? null : this.page, this.pushstate);
|
||||||
this.pushstate = History.Push;
|
this.pushstate = History.Push;
|
||||||
|
this.fetchPictures();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("popstate", () => {
|
window.addEventListener("popstate", () => {
|
||||||
@ -30,7 +28,6 @@ document.addEventListener("alpine:init", () => {
|
|||||||
this.page =
|
this.page =
|
||||||
Number.parseInt(new URLSearchParams(window.location.search).get("page")) || 1;
|
Number.parseInt(new URLSearchParams(window.location.search).get("page")) || 1;
|
||||||
});
|
});
|
||||||
this.config = config;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getPage(page: number) {
|
getPage(page: number) {
|
||||||
|
@ -64,11 +64,7 @@
|
|||||||
<br>
|
<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div x-data="pictures({
|
<div x-data="pictures({ albumId: {{ album.id }}, maxPageSize: {{ settings.SITH_SAS_IMAGES_PER_PAGE }} })">
|
||||||
albumId: {{ album.id }},
|
|
||||||
maxPageSize: {{ settings.SITH_SAS_IMAGES_PER_PAGE }},
|
|
||||||
})">
|
|
||||||
|
|
||||||
{{ download_button(_("Download album")) }}
|
{{ download_button(_("Download album")) }}
|
||||||
|
|
||||||
<h4>{% trans %}Pictures{% endtrans %}</h4>
|
<h4>{% trans %}Pictures{% endtrans %}</h4>
|
||||||
@ -94,7 +90,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
{{ paginate_alpine("page", "nbPages()") }}
|
{{ paginate_alpine("page", "nbPages()") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if is_sas_admin %}
|
{% if is_sas_admin %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user