mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 17:52:21 +01:00
Store page size on manage and request pages
This commit is contained in:
@ -36,4 +36,26 @@ Number.prototype.timestampToHHMMSS = function () {
|
||||
seconds = '0' + seconds;
|
||||
}
|
||||
return hours + ':' + minutes + ':' + seconds;
|
||||
};
|
||||
};
|
||||
|
||||
function setCookie(name, value, days) {
|
||||
let expires = "";
|
||||
value = encodeURI(value);
|
||||
if (days) {
|
||||
let date = new Date();
|
||||
date.setTime(date.getTime() + (days*24*60*60*1000));
|
||||
expires = "; expires=" + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
let nameEQ = name + "=";
|
||||
let ca = document.cookie.split(';');
|
||||
for(let i=0;i < ca.length;i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0)===' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) === 0) return decodeURIComponent(c.substring(nameEQ.length,c.length));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -22,6 +22,10 @@
|
||||
|
||||
<!-- Base JavaScript -->
|
||||
<script type="text/javascript" src="{% static "marietje/js/base.js" %}"></script>
|
||||
|
||||
<script>
|
||||
const CSRF_TOKEN = "{{ csrf_token }}";
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg sticky-top navbar-dark bg-primary">
|
||||
@ -109,9 +113,6 @@
|
||||
</footer>
|
||||
{% endif %}
|
||||
{% bootstrap_javascript %}
|
||||
<script>
|
||||
const CSRF_TOKEN = "{{ csrf_token }}";
|
||||
</script>
|
||||
{% block js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -425,6 +425,7 @@
|
||||
this.page_size = 10;
|
||||
}
|
||||
this.page_number = 1;
|
||||
setCookie("REQUEST_PAGE_SIZE", this.page_size, 14);
|
||||
this.search();
|
||||
}
|
||||
}
|
||||
@ -455,6 +456,10 @@
|
||||
tata.error("", "An unknown error occurred, please try again.")
|
||||
}
|
||||
});
|
||||
const stored_page_size = parseInt(getCookie("REQUEST_PAGE_SIZE"));
|
||||
if (stored_page_size !== Number.NaN && stored_page_size > 0) {
|
||||
this.page_size = stored_page_size;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
|
||||
@ -101,6 +101,7 @@
|
||||
this.page_size = 10;
|
||||
}
|
||||
this.page_number = 1;
|
||||
setCookie("MANAGE_PAGE_SIZE", this.page_size, 14);
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
@ -131,6 +132,10 @@
|
||||
tata.error("", "An unknown error occurred, please try again.")
|
||||
}
|
||||
});
|
||||
const stored_page_size = parseInt(getCookie("MANAGE_PAGE_SIZE"));
|
||||
if (stored_page_size !== Number.NaN && stored_page_size > 0) {
|
||||
this.page_size = stored_page_size;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
|
||||
Reference in New Issue
Block a user