hitro dodajanje vozila
This commit is contained in:
@@ -280,6 +280,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="divModalCodetablePartnerAddEditPlaceholder"></div>
|
||||
<div id="divModalCodetableVehicleAddEditPlaceholder"></div>
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
@@ -291,6 +292,7 @@
|
||||
<script src="~/vendor/libs/quill/quill.js" asp-append-version="true"></script>
|
||||
<script src="~/vendor/libs/select2/select2.js" asp-append-version="true"></script>
|
||||
<script src="~/js/codeTablePartnerHelper.js?v=1" asp-append-version="true"></script>
|
||||
<script src="~/js/codeTableVehicleHelper.js?v=1" asp-append-version="true"></script>
|
||||
|
||||
<script>
|
||||
var Block = Quill.import('blots/block');
|
||||
@@ -385,7 +387,18 @@
|
||||
|
||||
$('.select2-vehicle').select2({
|
||||
allowClear: true,
|
||||
placeholder: "Izberi vozilo"
|
||||
placeholder: "Izberi vozilo",
|
||||
language: {
|
||||
noResults: function () {
|
||||
return `<button style="width: 100%" type="button"
|
||||
class="btn btn-primary"
|
||||
onClick='addNewCodeTableVehicle()'>Dodaj novega</button>
|
||||
</li>`;
|
||||
}
|
||||
},
|
||||
escapeMarkup: function (markup) {
|
||||
return markup;
|
||||
}
|
||||
}).on('change', function() {
|
||||
if ($(".select2-vehicle").val() !== '') {
|
||||
$('.vehicle-text').val('');
|
||||
@@ -494,5 +507,33 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addNewCodeTableVehicle() {
|
||||
let title = $(".select2-vehicle").data("select2").dropdown.$search.val();
|
||||
codeTableVehicleAddEdit('#divModalCodetableVehicleAddEditPlaceholder', false, null, (idCodeTableVehicle) => {
|
||||
refreshCodeTableVehicle('.select2-vehicle', idCodeTableVehicle, null, true);
|
||||
}, null, title);
|
||||
}
|
||||
|
||||
function refreshCodeTableVehicle(selector, idToSelect) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/CodeTableVehicles/Index/?handler=CodeTableVehiclesSelect",
|
||||
data: {
|
||||
},
|
||||
success: function (data) {
|
||||
$(selector).empty();
|
||||
$(data.vehicles).each(function () {
|
||||
$(selector).append($("<option></option>").val(this.value).html(this.text));
|
||||
});
|
||||
$(selector).val(idToSelect).trigger('change');
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError) {
|
||||
console.log(xhr);
|
||||
alert(xhr.responseText);
|
||||
$.unblockUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
@@ -41,7 +41,7 @@
|
||||
Datum naloga
|
||||
</th>
|
||||
<th>
|
||||
Partner
|
||||
Prevoznik
|
||||
</th>
|
||||
<th style="width: 100px">
|
||||
Status
|
||||
|
||||
Reference in New Issue
Block a user