| 34387 |
vikas.jang |
1 |
|
|
|
2 |
function initializeSelect(selector, type='catalogs') {
|
|
|
3 |
if (type === 'catalogs') {
|
|
|
4 |
$(selector).multiselect('destroy');
|
|
|
5 |
$(selector).multiselect({
|
|
|
6 |
includeSelectAllOption: false,
|
|
|
7 |
multiple: false,
|
|
|
8 |
maxHeight: 200,
|
|
|
9 |
buttonWidth: '100%',
|
|
|
10 |
numberDisplayed: 1,
|
|
|
11 |
nonSelectedText: '-- Select One --',
|
|
|
12 |
nSelectedText: ' - Selected',
|
|
|
13 |
enableFiltering: true,
|
|
|
14 |
enableCaseInsensitiveFiltering: true
|
|
|
15 |
});
|
|
|
16 |
} else {
|
|
|
17 |
$(selector).select2({
|
|
|
18 |
placeholder: "Select or add new",
|
|
|
19 |
tags: true,
|
|
|
20 |
createTag: params => ({ id: params.term, text: params.term, newOption: true }),
|
|
|
21 |
templateResult: data => data.newOption ? $('<span class="new-option">Add: ' + data.text + '</span>') : data.text,
|
|
|
22 |
});
|
|
|
23 |
}
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
function validateRequiredFields(fields) {
|
|
|
27 |
let isValid = true;
|
|
|
28 |
fields.each(function () {
|
|
|
29 |
if (!$(this).val()) {
|
|
|
30 |
isValid = false;
|
|
|
31 |
$(this).addClass('is-invalid');
|
|
|
32 |
} else {
|
|
|
33 |
$(this).removeClass('is-invalid');
|
|
|
34 |
}
|
|
|
35 |
});
|
|
|
36 |
return isValid;
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
$(document).on('click', ".liquidation-list", function () {
|
|
|
40 |
doGetAjaxRequestHandler(context + "/liquidation", (response) => {
|
|
|
41 |
$('#main-content').html(response);
|
| 34405 |
vikas.jang |
42 |
initializeSelect('#catalogId, #status')
|
| 34387 |
vikas.jang |
43 |
$('#liquidation-table').DataTable();
|
|
|
44 |
|
|
|
45 |
});
|
|
|
46 |
});
|
|
|
47 |
|
|
|
48 |
$(document).on('click', ".save-liquidation", function () {
|
|
|
49 |
const params = serializeFormToJson('form#biddingForm');
|
| 34405 |
vikas.jang |
50 |
params.restricted = $('#restricted:checked').length
|
| 34387 |
vikas.jang |
51 |
doAjaxRequestWithJsonHandler(context + "/liquidation", "POST", JSON.stringify(params), (response) => {
|
|
|
52 |
if (response) {
|
|
|
53 |
$('.liquidation-list').trigger('click');
|
|
|
54 |
$('#manageLiquidationModal').modal('hide');
|
|
|
55 |
alert("Saved successfully");
|
|
|
56 |
} else {
|
|
|
57 |
alert("Something went wrong!");
|
|
|
58 |
}
|
|
|
59 |
});
|
|
|
60 |
});
|
|
|
61 |
|
| 34405 |
vikas.jang |
62 |
function editLiquidation(id) {
|
|
|
63 |
doGetAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
|
|
|
64 |
if (response.statusCode == 200){
|
|
|
65 |
$('#manageLiquidationModal').modal('show');
|
|
|
66 |
let names = Object.keys(response.response);
|
|
|
67 |
if (names.length){
|
|
|
68 |
names.forEach(name => {
|
|
|
69 |
if (name == 'catalogId' || name == 'status') {
|
|
|
70 |
$(`#${name}`).val(response.response[name]);
|
|
|
71 |
$(`#${name}`).multiselect('refresh');
|
|
|
72 |
} else {
|
|
|
73 |
if(name == 'restricted') $(`#restricted`).prop('checked', response.response['restricted']);
|
|
|
74 |
$(`#${name}`).val(response.response[name]);
|
|
|
75 |
}
|
|
|
76 |
})
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
});
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
function deleteLiquidation(id) {
|
| 34387 |
vikas.jang |
83 |
if (confirm("Are you sure you want to delete this record")) {
|
|
|
84 |
if (id > 0) {
|
|
|
85 |
doDeleteAjaxRequestHandler(`${context}/liquidation/${id}`, (response) => {
|
|
|
86 |
if (response) {
|
|
|
87 |
$(this).parent('td').closest('tr').remove();
|
|
|
88 |
$('.liquidation-list').trigger('click');
|
|
|
89 |
alert("Deleted successfully");
|
|
|
90 |
} else {
|
|
|
91 |
alert("Something went wrong!");
|
|
|
92 |
}
|
|
|
93 |
});
|
|
|
94 |
} else {
|
| 34405 |
vikas.jang |
95 |
alert("Liquidation not found");
|
| 34387 |
vikas.jang |
96 |
}
|
|
|
97 |
}
|
|
|
98 |
}
|