FIX: show pagination on event billing list, show event in the past in event billing list

This commit is contained in:
Keanu D?lle 2022-04-25 05:57:24 +02:00
parent f1b56bb520
commit 8794f3e324
3 changed files with 49 additions and 41 deletions

View File

@ -4,21 +4,25 @@ $(document).ready(async function () {
EventBillingList = (function () {
let templates = {};
let pending_requests = [];
let pag;
let limit = 10;
let setup = async function () {
await load_templates();
await setup_pagination();
setup_pagination();
await load_events(0);
$(".event_billing_list_load").off("click").on("click", load_events);
};
let load_templates = function(){
$.get("/templates/eb_list_card.hbs", function( res) {
templates.eb_list_card = Handlebars.compile(res);
$("#event_billing_list_num_of_res").on("change", function(){
limit = $("#eventlist_num_of_res option:selected").data("num");
load_events();
});
$.get("/templates/pagination.hbs", function( res) {
templates.pagination = Handlebars.compile(res);
};
let load_templates = async function () {
const eb_list_card = $.get("/templates/eb_list_card.hbs");
const pagination = $.get("/templates/pagination.hbs");
await Promise.all([eb_list_card, pagination]).then(function (res) {
templates.eb_list_card = Handlebars.compile(res[0]);
templates.pagination = Handlebars.compile(res[1]);
});
};
let setup_pagination = function(){
@ -135,6 +139,7 @@ EventBillingList = (function () {
$("#event_billing_list_accordion").append(templates.eb_list_card(val))
}
$("#event_billing_list_accordion").show();
pag.render(values.length, offset);
})
}
}

View File

@ -20,11 +20,7 @@ class Pagination{
for(let i=1;i<=this.total_page_count();i++){
let page = {};
page.num = i;
if(this.current_page() === i){
page.disabled = true;
}else{
page.disabled = false;
}
page.disabled = this.current_page() === i;
data.pages.push(page);
}

View File

@ -35,34 +35,6 @@ pub fn read_events(
return Err(Json(ApiError::new(403, "Keine Berechtigung Einsätze abzurufen!".to_string()).to_wrapper()))
}
let start = match start {
Some(mut start) => {
start += "T00:00";
match NaiveDateTime::parse_from_str(&start, "%Y-%m-%dT%H:%M") {
Ok(start) => start,
Err(e) => {
error!("Couldn't parse start datetime: {}", e);
return Err(Json(ApiError::new(400, "Das eingegebene Datum konnte nicht verarbeitet werden.".to_string()).to_wrapper()))
}
}
},
None => Local::now().naive_local()
};
let end = match end {
Some(mut end) => {
end += "T23:59";
match NaiveDateTime::parse_from_str(&end, "%Y-%m-%dT%H:%M") {
Ok(end) => end,
Err(e) => {
error!("Couldn't parse end datetime: {}", e);
return Err(Json(ApiError::new(400, "Das eingegebene Datum konnte nicht verarbeitet werden.".to_string()).to_wrapper()))
}
}
},
None => Local::now().naive_local() + Duration::days(90)
};
let limit = limit.unwrap_or(settings.api.default_pagination_limit);
let offset = offset.unwrap_or(0);
let states = match states{
Some(states) => {
let mut res: Vec<i16> = vec![];
@ -81,6 +53,41 @@ pub fn read_events(
None => None
};
let start = match start {
Some(mut start) => {
start += "T00:00";
match NaiveDateTime::parse_from_str(&start, "%Y-%m-%dT%H:%M") {
Ok(start) => start,
Err(e) => {
error!("Couldn't parse start datetime: {}", e);
return Err(Json(ApiError::new(400, "Das eingegebene Datum konnte nicht verarbeitet werden.".to_string()).to_wrapper()))
}
}
},
None => {
if states.is_some(){
Local::now().naive_local() - Duration::days(365)
}else{
Local::now().naive_local()
}
}
};
let end = match end {
Some(mut end) => {
end += "T23:59";
match NaiveDateTime::parse_from_str(&end, "%Y-%m-%dT%H:%M") {
Ok(end) => end,
Err(e) => {
error!("Couldn't parse end datetime: {}", e);
return Err(Json(ApiError::new(400, "Das eingegebene Datum konnte nicht verarbeitet werden.".to_string()).to_wrapper()))
}
}
},
None => Local::now().naive_local() + Duration::days(90)
};
let limit = limit.unwrap_or(settings.api.default_pagination_limit);
let offset = offset.unwrap_or(0);
let groups = match groups{
Some(groups) => {
let mut groups_res: Vec<uuid::Uuid> = vec![];