| 33973 |
tejus.loha |
1 |
<style>
|
|
|
2 |
.select2-container .select2-selection--single {
|
|
|
3 |
box-sizing: border-box;
|
|
|
4 |
cursor: pointer;
|
|
|
5 |
display: block;
|
|
|
6 |
height: 35px;
|
|
|
7 |
padding: 3px;
|
|
|
8 |
user-select: none;
|
|
|
9 |
-webkit-user-select: none;
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
.modal-body {
|
|
|
13 |
overflow-y: auto;
|
|
|
14 |
max-height: calc(100vh - 200px);
|
|
|
15 |
}
|
|
|
16 |
</style>
|
|
|
17 |
<section class="wrapper">
|
|
|
18 |
<div class="row">
|
|
|
19 |
<div class="col-lg-12">
|
|
|
20 |
<h3 class="page-header"><i class="icon_document_alt"></i>Super Catalog</h3>
|
|
|
21 |
<ol class="breadcrumb">
|
|
|
22 |
<li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Dashboard</a></li>
|
|
|
23 |
<li><i class="icon_document_alt"></i>Super Catalog</li>
|
|
|
24 |
<li class="pull-right">
|
|
|
25 |
<button class="btn btn-primary map-catalog" type="button" data-toggle="modal" data-target="#manageSuperCatalogModal">
|
|
|
26 |
<i class="icon_document_alt"></i>Create New</button>
|
|
|
27 |
</li>
|
|
|
28 |
</ol>
|
|
|
29 |
</div>
|
|
|
30 |
</div>
|
|
|
31 |
<div class="table-responsive">
|
|
|
32 |
<table class="table table-bordered" id="super-catalog">
|
|
|
33 |
<thead>
|
|
|
34 |
<tr>
|
|
|
35 |
<th>#</th>
|
|
|
36 |
<th>Name</th>
|
|
|
37 |
<th>Action</th>
|
|
|
38 |
</tr>
|
|
|
39 |
</thead>
|
|
|
40 |
<tbody>
|
|
|
41 |
#if($allSuperCatalogs.size() > 0)
|
|
|
42 |
#foreach($superCatalog in $allSuperCatalogs)
|
|
|
43 |
<tr data-id="$superCatalog.getId()" data-catalog_name="$superCatalog.getSuperCatalogName()" data-brand_name="$superCatalog.getBrandId()">
|
|
|
44 |
<td>$superCatalog.getId()</td>
|
|
|
45 |
<td>$superCatalog.getSuperCatalogName()</td>
|
|
|
46 |
<td data-id="$superCatalog.getId()">
|
|
|
47 |
<button class="btn btn-primary view-super-catalog"><i class="fa fa-eye" title="View"></i></button>
|
|
|
48 |
<button class="btn btn-danger delete-super-catalog-mapping"><i class="fa fa-trash" title="Delete"></i></button>
|
|
|
49 |
</td>
|
|
|
50 |
</tr>
|
|
|
51 |
#end
|
|
|
52 |
#else
|
|
|
53 |
<tr>
|
|
|
54 |
<td colspan="7">No super catalogs mapping available.</td>
|
|
|
55 |
</tr>
|
|
|
56 |
#end
|
|
|
57 |
</tbody>
|
|
|
58 |
</table>
|
|
|
59 |
</div>
|
|
|
60 |
</section>
|
|
|
61 |
|
|
|
62 |
<div id="manageSuperCatalogModal" class="modal" role="dialog">
|
|
|
63 |
<div class="modal-dialog">
|
|
|
64 |
<div class="modal-content">
|
|
|
65 |
<div class="modal-header">
|
|
|
66 |
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
|
67 |
<h4 class="modal-title">Manage super catalog</h4>
|
|
|
68 |
</div>
|
|
|
69 |
<div class="modal-body" id="manageSuperCatalogModalBody">
|
|
|
70 |
<div class="form-group">
|
|
|
71 |
<label for="brand_id">Select brand</label>
|
|
|
72 |
<select id="brand_id" class="form-control">
|
|
|
73 |
<option value="">-- Select --</option>
|
|
|
74 |
#foreach($brand in $brands)
|
|
|
75 |
<option value="$brand.getId()">$brand.getName()</option>
|
|
|
76 |
#end
|
|
|
77 |
</select>
|
|
|
78 |
</div>
|
|
|
79 |
<div class="form-group">
|
|
|
80 |
<label for="super_catalog_name">Super catalog name</label>
|
|
|
81 |
<select id="super_catalog_name" class="form-control selectOrCreate">
|
|
|
82 |
#foreach($row in $allSuperCatalogs)
|
|
|
83 |
<option value="$row.getId()">$row.getSuperCatalogName()</option>
|
|
|
84 |
#end
|
|
|
85 |
</select>
|
|
|
86 |
</div>
|
|
|
87 |
<table class="table" id="catalogMappingTable">
|
|
|
88 |
<thead>
|
|
|
89 |
<tr>
|
|
|
90 |
<th>Catalog</th>
|
|
|
91 |
<th>Variant</th>
|
|
|
92 |
<th><button class="btn btn-primary addNew"><i class="fa fa-plus"></i></button></th>
|
|
|
93 |
</tr>
|
|
|
94 |
</thead>
|
|
|
95 |
<tbody id="catalogMapping">
|
|
|
96 |
<tr>
|
|
|
97 |
<td>
|
|
|
98 |
<div class="form-group">
|
|
|
99 |
<select id="catalog_id" class="form-control">
|
|
|
100 |
<option value="" readonly selected>-- Select Catalog --</option>
|
|
|
101 |
#foreach($row in $catalogs)
|
| 34023 |
vikas.jang |
102 |
<option value="$row.getId()">$row.getDescription()</option>
|
| 33973 |
tejus.loha |
103 |
#end
|
|
|
104 |
</select>
|
|
|
105 |
</div>
|
|
|
106 |
</td>
|
|
|
107 |
<td>
|
|
|
108 |
<div class="form-group">
|
|
|
109 |
<input id="variant_name" class="form-control" placeholder="Variant name">
|
|
|
110 |
<input id="mapping_id" type="hidden" value="0">
|
|
|
111 |
</div>
|
|
|
112 |
</td>
|
|
|
113 |
<td>
|
|
|
114 |
<button class="btn btn-primary removeExisting"><i class="fa fa-minus"></i></button>
|
|
|
115 |
</td>
|
|
|
116 |
</tr>
|
|
|
117 |
</tbody>
|
|
|
118 |
</table>
|
|
|
119 |
</div>
|
|
|
120 |
<div class="modal-footer">
|
|
|
121 |
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
|
|
|
122 |
<button type="button" class="btn btn-primary save_super_model">Save</button>
|
|
|
123 |
</div>
|
|
|
124 |
</div>
|
|
|
125 |
</div>
|
|
|
126 |
</div>
|
|
|
127 |
|
|
|
128 |
<script type="text/javascript">
|
|
|
129 |
|
|
|
130 |
$(document).ready(function (){
|
|
|
131 |
|
|
|
132 |
const freshTr = `<tr>
|
|
|
133 |
<td>
|
|
|
134 |
<div class="form-group">
|
|
|
135 |
<select id="catalog_id" class="form-control">
|
|
|
136 |
<option value="" readonly selected>-- Select Catalog --</option>
|
|
|
137 |
#foreach($row in $catalogs)
|
| 34023 |
vikas.jang |
138 |
<option value="$row.getId()">$row.getDescription()</option>
|
| 33973 |
tejus.loha |
139 |
#end
|
|
|
140 |
</select>
|
|
|
141 |
</div>
|
|
|
142 |
</td>
|
|
|
143 |
<td>
|
|
|
144 |
<div class="form-group">
|
|
|
145 |
<input id="variant_name" class="form-control" placeholder="Variant name">
|
|
|
146 |
<input id="mapping_id" type="hidden" value="0">
|
|
|
147 |
</div>
|
|
|
148 |
</td>
|
|
|
149 |
<td>
|
|
|
150 |
<button class="btn btn-primary removeExisting"><i class="fa fa-minus"></i></button>
|
|
|
151 |
</td>
|
|
|
152 |
</tr>`;
|
|
|
153 |
|
|
|
154 |
$('#catalog_id, #brand_id').multiselect({
|
|
|
155 |
includeSelectAllOption: false,
|
|
|
156 |
multiple:false,
|
|
|
157 |
maxHeight: 200,
|
|
|
158 |
buttonWidth: '100%',
|
|
|
159 |
numberDisplayed: 1,
|
|
|
160 |
nonSelectedText: '-- Select One --',
|
|
|
161 |
nSelectedText: ' - Selected',
|
|
|
162 |
enableFiltering: true,
|
|
|
163 |
enableCaseInsensitiveFiltering : true
|
|
|
164 |
});
|
|
|
165 |
|
|
|
166 |
$('#manageSuperCatalogModal').on('hidden.bs.modal', function () {
|
|
|
167 |
$('#mapping_id').val(0);
|
|
|
168 |
$('#variant_name').val('');
|
|
|
169 |
$('#brand_id').val('').trigger('change');
|
|
|
170 |
$('#catalog_id').val('').trigger('change');
|
|
|
171 |
$('#super_catalog_name').val('').trigger('change');
|
|
|
172 |
});
|
|
|
173 |
|
|
|
174 |
$('#manageSuperCatalogModal').on('click', '.addNew',function () {
|
|
|
175 |
$('#catalogMapping').append(freshTr);
|
|
|
176 |
const lastTr = $('#catalogMapping tr:last');
|
|
|
177 |
lastTr.find('#catalog_id').multiselect({
|
|
|
178 |
includeSelectAllOption: false,
|
|
|
179 |
multiple:false,
|
|
|
180 |
maxHeight: 200,
|
|
|
181 |
buttonWidth: '100%',
|
|
|
182 |
numberDisplayed: 1,
|
|
|
183 |
nonSelectedText: '-- Select One --',
|
|
|
184 |
nSelectedText: ' - Selected',
|
|
|
185 |
enableFiltering: true,
|
|
|
186 |
enableCaseInsensitiveFiltering : true
|
|
|
187 |
});
|
|
|
188 |
});
|
|
|
189 |
|
|
|
190 |
$('#manageSuperCatalogModal').on('click', '.removeExisting',function () {
|
|
|
191 |
if (confirm("Are you sure you want to remove this")) {
|
| 34010 |
vikas.jang |
192 |
const tr = $(this).closest('tr');
|
|
|
193 |
const mappingId = tr.data('mapping-id');
|
| 33973 |
tejus.loha |
194 |
if (mappingId > 0) {
|
|
|
195 |
doDeleteAjaxRequestHandler(context + "/super-catalog/mapping/" + mappingId, function (response) {
|
| 34010 |
vikas.jang |
196 |
if (response == "true") {
|
|
|
197 |
tr.remove();
|
| 33973 |
tejus.loha |
198 |
} else {
|
|
|
199 |
alert("Something went wrong while deleting the variant");
|
|
|
200 |
}
|
|
|
201 |
})
|
|
|
202 |
} else {
|
| 34010 |
vikas.jang |
203 |
tr.remove();
|
| 33973 |
tejus.loha |
204 |
}
|
|
|
205 |
}
|
|
|
206 |
});
|
|
|
207 |
|
|
|
208 |
$('.selectOrCreate').select2({
|
|
|
209 |
placeholder: "Select or add new",
|
|
|
210 |
tags: true,
|
|
|
211 |
createTag: function(params) {
|
|
|
212 |
return {
|
|
|
213 |
id: params.term,
|
|
|
214 |
text: params.term,
|
|
|
215 |
newOption: true
|
|
|
216 |
};
|
|
|
217 |
},
|
|
|
218 |
templateResult: function(data) {
|
|
|
219 |
return data.newOption ? $('<span class="new-option">Add: ' + data.text + '</span>') : data.text;
|
|
|
220 |
},
|
|
|
221 |
});
|
|
|
222 |
|
|
|
223 |
$('#super-catalog').on('click', '.view-super-catalog', function (ev) {
|
|
|
224 |
ev.preventDefault();
|
|
|
225 |
let superCatalogId = $(this).parent().parent('tr').data('id'),
|
|
|
226 |
brand = $(this).parent().parent('tr').data('brand_name');
|
|
|
227 |
|
|
|
228 |
doGetAjaxRequestHandler(context + "/super-catalog/"+superCatalogId,(response) => {
|
|
|
229 |
$('#manageSuperCatalogModalBody').empty();
|
|
|
230 |
$('#manageSuperCatalogModalBody').html(response);
|
|
|
231 |
$('#manageSuperCatalogModal').modal('show');
|
|
|
232 |
$('#catalog_id, #brand_id').multiselect({
|
|
|
233 |
includeSelectAllOption: false,
|
|
|
234 |
multiple:false,
|
|
|
235 |
maxHeight: 200,
|
|
|
236 |
buttonWidth: '100%',
|
|
|
237 |
numberDisplayed: 1,
|
|
|
238 |
nonSelectedText: '-- Select One --',
|
|
|
239 |
nSelectedText: ' - Selected',
|
|
|
240 |
allSelectedText: 'All Selected',
|
|
|
241 |
enableFiltering: true,
|
|
|
242 |
enableCaseInsensitiveFiltering : true
|
|
|
243 |
});
|
|
|
244 |
});
|
|
|
245 |
});
|
|
|
246 |
|
|
|
247 |
$('#super-catalog').DataTable();
|
|
|
248 |
|
|
|
249 |
});
|
|
|
250 |
|
|
|
251 |
</script>
|