diff --git a/resources/ajax_templates/em_edit_event_core_data.hbs b/resources/ajax_templates/em_edit_event_core_data.hbs
index d7997ea..1d5a9f5 100644
--- a/resources/ajax_templates/em_edit_event_core_data.hbs
+++ b/resources/ajax_templates/em_edit_event_core_data.hbs
@@ -64,13 +64,15 @@
diff --git a/resources/js/event_billing.js b/resources/js/event_billing.js
index d71df32..68bac3a 100644
--- a/resources/js/event_billing.js
+++ b/resources/js/event_billing.js
@@ -251,8 +251,11 @@ EventBilling = (function () {
let eu_instances = {};
let load_local_templates = async function () {
const eu_instance_card = $.get("/templates/eb_eu_instance_card.hbs");
- await Promise.all([eu_instance_card]).then(function (res) {
+ const new_position_instance = $.get("/templates/eb_eu_instance_card_new_position_instance.hbs");
+ await Promise.all([eu_instance_card, new_position_instance]).then(function (res) {
templates.eu_instance_card = Handlebars.compile(res[0]);
+ templates.new_position_instance = Handlebars.compile(res[1]);
+ Handlebars.registerPartial('new_position_instance', templates.new_position_instance);
});
};
let setup = async function () {
@@ -275,7 +278,6 @@ EventBilling = (function () {
}
$(".eu_instances_container").append(templates.eu_instance_card(instance));
- console.log(instance);
}
@@ -285,16 +287,31 @@ EventBilling = (function () {
//Apply remove/restore position_instance button listeners
$(".remove_position_instance_button").off("click").on("click", delete_position_btn);
- $(".remove_new_position_instance_button").off("click").on("click", function () {
- $(this).closest(".card").remove();
- });
$(".restore_position_instance_button").off("click").on("click", restore_position_btn);
$(".approve_times_btn").off("click").on("click", approve_times);
$(".qsf").off("change").on("change", function () { //Show save button if instance changed
$(this).closest(".position_instance").addClass("modified");
$(this).closest(".instance").find(".eb_eu_instance_save_btn").show();
- })
+ });
+
+ let add_new_position_instance_listener = function(){
+ $(this).closest(".new_position_instances").append(templates.new_position_instance);
+ $(".new_position_instance").off("click");
+ $(".new_position_instance:last-child").on("click", add_new_position_instance_listener);
+ $(".remove_new_position_instance_button").off("click").on("click", function () {
+ $(this).closest(".card").remove();
+ $(".new_position_instance").off("click");
+ $(".new_position_instance:last-child").on("click", add_new_position_instance_listener);
+ });
+ }
+
+ $(".new_position_instance:last-child").off("click").on("click", function(){
+ add_new_position_instance_listener(this);
+ });
+ $(".remove_new_position_instance_button").off("click").on("click", function () {
+ $(this).closest(".card").remove();
+ });
};
let save = async function () {
//TODO: use global save_pending_requests()
@@ -381,7 +398,8 @@ EventBilling = (function () {
}
if (!error_occured) {
save_btn.hide();
- await setup();
+ parent.find(".marked-for-delete").remove();
+ parent.find(".modified").removeClass("modified");
}
}, function () {
//Failure
@@ -442,7 +460,9 @@ EventBilling = (function () {
}
});
if (is_ok(res)) {
- window.location.href = "/portal/eb/personnel_billing?event_id=" + event.entity_id;
+ setTimeout(function(){
+ window.location.href = "/portal/eb/personnel_billing?event_id=" + event.entity_id;
+ }, 500);
} else {
throw res;
}
diff --git a/resources/js/search2.js b/resources/js/search2.js
index ef035d9..2a990b7 100644
--- a/resources/js/search2.js
+++ b/resources/js/search2.js
@@ -162,6 +162,21 @@ Search2 = (function () {
let res = res_map.get($(this).data("entity-id"));
setValue(this, res.entity_id, res.identifier+" ("+res.numberplate+")");
};
+ }else if (type === "organiser") {
+ options.url = "/api/event_organisers/";
+ options.get_data = {
+ "q": searchbar.val()
+ };
+ options.res_handler = function (data) {
+ $.each(data.organisers, function (index, value) {
+ res_map.set(value.entity_id, value);
+ overlay_list.append("Hinzufügen: " + value.company + " : "+value.firstname + " " + value.lastname +"");
+ });
+ };
+ options.overlay_click_handler = function () {
+ let res = res_map.get($(this).data("entity-id"));
+ setValue(this, res.entity_id, res.company+" "+res.firstname+" "+res.lastname);
+ };
}else {
console.error("Unknown search type: " + type);
return;