Files
BeWoPlaner/BeWoPlanerMobil/Views/Scheduler/SchedulerCustomerSelectionPartial.cshtml

55 lines
2.1 KiB
Plaintext

@model BeWoPlanerMobil.Models.SchedulerModel
<script type="text/javascript">
function removeSelectedCustomer(customerOid) {
const checkbox = $(`#customer-${customerOid}-checkbox`);
if(checkbox.length) {
checkbox.prop("checked", false);
}
changeCustomerListSelection();
}
function changeCustomerListSelection() {
const selectedCustomerOids = $("#customer-input-container input:checked").map(function () {return $(this).attr("id").split("-")[1];}).get();
const allCustomersCount = $("#customer-input-container input[type=checkbox]").map(function () {return $(this).attr("id").split("-")[1];}).get();
const selectedCustomersCount = selectedCustomerOids.length;
$("#all-customers-checkbox").prop("checked", (allCustomersCount === selectedCustomersCount));
$("#scheduler-selected-customer-container").load(
"@Url.Action("UpdateCustomerSelection")",
{
oidString: selectedCustomerOids.toString()
},
function() {
$("#one-day-scheduler-partial-container").load('@Url.Action("FetchAppointments", "Scheduler")');
});
}
</script>
<div class="col-12 px-0">
<div class="form-group px-0 w-100" id="selected-customers-list">
@foreach(var selectedCustomer in Model.SelectedCustomers)
{
<div class="input-group mb-1">
<div class="input-group-prepend">
<span class="input-group-text h-100">
<i class="fas fa-user text-bewo-customers h-100"></i>
</span>
</div>
<span class="form-control text-truncate">
@selectedCustomer.DetailDescription
</span>
<div class="input-group-append">
<button type="button" class="btn btn-outline-danger" onclick="removeSelectedCustomer(@selectedCustomer.CustomerOid)">
<span class="fas fa-times-circle"></span>
</button>
</div>
</div>
}
</div>
</div>