| 27754 |
amit.gupta |
1 |
$(document).on('click', ".web-listing", function() {
|
| 26738 |
amit.gupta |
2 |
loadWebListing("main-content");
|
|
|
3 |
});
|
| 27754 |
amit.gupta |
4 |
$(document).on('click', "a.listing-details", function() {
|
| 26738 |
amit.gupta |
5 |
var webListingId = $(this).data("id");
|
|
|
6 |
doAjaxRequestHandler(`${context}/web-listing/${webListingId}`, "GET", function(response) {
|
|
|
7 |
$('.web-products-container').html(response);
|
| 26731 |
amit.gupta |
8 |
});
|
| 28270 |
tejbeer |
9 |
|
| 26738 |
amit.gupta |
10 |
})
|
|
|
11 |
|
| 28270 |
tejbeer |
12 |
|
|
|
13 |
$(document).on('click', "a.prodcut-remove", function() {
|
|
|
14 |
var webProductId = $(this).data("productid");
|
|
|
15 |
var webListingId = $(this).data("id");
|
|
|
16 |
if (confirm("Are you sure you want to remove the Item!") == true) {
|
|
|
17 |
|
|
|
18 |
doDeleteAjaxRequestHandler(context + "/webProductListing/removeItem?id="
|
|
|
19 |
+ webProductId + "&webListingId=" + webListingId, function(response) {
|
|
|
20 |
|
|
|
21 |
alert("Product removed successfully");
|
|
|
22 |
$('.web-products-container').html(response);
|
|
|
23 |
|
|
|
24 |
});
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
})
|
|
|
28 |
|
|
|
29 |
$(document).on('click', ".web-listing-active", function() {
|
|
|
30 |
var webListingId = $(this).data("id");
|
|
|
31 |
var status = $(this).data("active");
|
|
|
32 |
if (status == true) {
|
|
|
33 |
status = false;
|
|
|
34 |
} else {
|
|
|
35 |
status = true;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
if (confirm("Are you sure you want to Update the Status!") == true) {
|
|
|
40 |
doPostAjaxRequestHandler(context
|
|
|
41 |
+ "/web-listing/updateStatus?id=" + webListingId + "&status=" + status,
|
|
|
42 |
function(response) {
|
|
|
43 |
$('#main-content').html(response);
|
|
|
44 |
});
|
|
|
45 |
}
|
|
|
46 |
})
|
|
|
47 |
|
|
|
48 |
$(document).on('click', "#update-rank", function() {
|
|
|
49 |
if (confirm("Are you sure you want to update ranks?")) {
|
|
|
50 |
var webListingId = $(this).data("id");
|
|
|
51 |
var webProductIds = [];
|
|
|
52 |
$("#web-product-listing-tbody").find("tr").each(function() {
|
| 26738 |
amit.gupta |
53 |
console.log(this);
|
|
|
54 |
webProductIds.push($(this).data("id"));
|
|
|
55 |
});
|
|
|
56 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
|
|
|
57 |
$('.web-products-container').html(response);
|
|
|
58 |
});
|
|
|
59 |
}
|
| 26731 |
amit.gupta |
60 |
});
|
| 28270 |
tejbeer |
61 |
|
|
|
62 |
|
|
|
63 |
$(document).on('click', "#weblisting-update-rank", function() {
|
|
|
64 |
if (confirm("Are you sure you want to update ranks?")) {
|
|
|
65 |
var webListingIds = [];
|
|
|
66 |
$("#web-listing-tbody").find("tr").each(function() {
|
|
|
67 |
console.log(this);
|
|
|
68 |
webListingIds.push($(this).data("id"));
|
|
|
69 |
});
|
|
|
70 |
|
|
|
71 |
console.log(webListingIds)
|
|
|
72 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order-listing`, JSON.stringify(webListingIds), function(response) {
|
|
|
73 |
$('#main-content').html(response);
|
|
|
74 |
});
|
|
|
75 |
}
|
|
|
76 |
});
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
$(document).on('click', ".web-listing-id", function() {
|
|
|
81 |
var webListingId = $(this).data("id");
|
|
|
82 |
doAjaxRequestHandler(`${context}/getweb-listing/${webListingId}`, "GET", function(response) {
|
|
|
83 |
$('.web-listing-edit-container .modal-content').html(response);
|
|
|
84 |
});
|
|
|
85 |
});
|
|
|
86 |
|
|
|
87 |
$(document).on('click', ".edit-web-listing", function() {
|
|
|
88 |
var webListingId = $(this).data("id");
|
|
|
89 |
|
|
|
90 |
webListingTitle = $("#web-listing-edit-title").val();
|
|
|
91 |
webListingUrl = $("#web-listing-edit-url").val();
|
|
|
92 |
webListingRank = $("#web-listing-edit-rank").val();
|
|
|
93 |
|
|
|
94 |
if (webListingTitle === "") {
|
|
|
95 |
alert("Title is required!");
|
|
|
96 |
return false;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
if (webListingUrl === "") {
|
|
|
100 |
alert("Url is required!");
|
|
|
101 |
return false;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
if (webListingRank === "") {
|
|
|
105 |
alert("Rank is required!");
|
|
|
106 |
return false;
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
json = { title: webListingTitle, url: webListingUrl, rank: webListingRank };
|
|
|
110 |
console.log(json)
|
|
|
111 |
if (confirm("Are you sure you want to Edit the Web Listing!") == true) {
|
|
|
112 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing-edit/${webListingId}`, JSON.stringify(json),
|
|
|
113 |
function(response) {
|
|
|
114 |
$('#main-content').html(response);
|
|
|
115 |
|
|
|
116 |
});
|
|
|
117 |
}
|
|
|
118 |
});
|
|
|
119 |
|
| 27754 |
amit.gupta |
120 |
$(document).on('click', "#add-listing", function() {
|
| 28270 |
tejbeer |
121 |
var webListingId = $(this).data("id");
|
| 26738 |
amit.gupta |
122 |
var entityIds = [entityId];
|
| 26731 |
amit.gupta |
123 |
|
| 28270 |
tejbeer |
124 |
var entityIdTxt = $("#entityData").val();
|
|
|
125 |
if (entityIdTxt.length > 0) {
|
|
|
126 |
if (entityIdTxt.indexOf(",") > 0) {
|
| 26738 |
amit.gupta |
127 |
entityIds = entityIdTxt.split(",");
|
|
|
128 |
}
|
|
|
129 |
} else {
|
|
|
130 |
alert("Please enter items");
|
|
|
131 |
return;
|
|
|
132 |
}
|
|
|
133 |
json = [];
|
| 28270 |
tejbeer |
134 |
for (var e of entityIds) {
|
|
|
135 |
json.push({ webListingId: webListingId, entityId: e });
|
| 26738 |
amit.gupta |
136 |
}
|
|
|
137 |
console.log(json);
|
|
|
138 |
console.log(JSON.stringify(json))
|
|
|
139 |
doPostAjaxRequestWithJsonHandler(`${context}/web-product-listing/add`, JSON.stringify(json), function(response) {
|
|
|
140 |
$('.web-products-container').html(response);
|
|
|
141 |
});
|
| 28270 |
tejbeer |
142 |
|
| 26738 |
amit.gupta |
143 |
});
|
|
|
144 |
|
| 26731 |
amit.gupta |
145 |
function loadWebListing(domId) {
|
|
|
146 |
doAjaxRequestHandler(context + "/web-listing", "GET", function(response) {
|
|
|
147 |
$('#' + domId).html(response);
|
|
|
148 |
});
|
|
|
149 |
}
|
| 26738 |
amit.gupta |
150 |
function addWebListing() {
|
|
|
151 |
webListingTitle = $("#web-listing-title").val();
|
|
|
152 |
webListingUrl = $("#web-listing-url").val();
|
| 28270 |
tejbeer |
153 |
webListingRank = $("#web-listing-rank").val();
|
|
|
154 |
if (webListingTitle === "") {
|
|
|
155 |
alert("Title is required!");
|
|
|
156 |
return false;
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
if (webListingUrl === "") {
|
|
|
160 |
alert("Url is required!");
|
|
|
161 |
return false;
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
if (webListingRank === "") {
|
|
|
165 |
alert("Rank is required!");
|
|
|
166 |
return false;
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
json = { title: webListingTitle, url: webListingUrl, rank: webListingRank };
|
| 26738 |
amit.gupta |
170 |
doPostAjaxRequestWithJsonHandler(context + "/web-listing/add", JSON.stringify(json), function(response) {
|
|
|
171 |
$('#main-content').html(response);
|
| 26731 |
amit.gupta |
172 |
});
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
|
| 28270 |
tejbeer |
176 |
$(document).on('mousedown', ".grab", function(e) {
|
|
|
177 |
var tr = $(e.target).closest("#web-product-listing-table tr"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
|
|
|
178 |
b.addClass("grabCursor").css("userSelect", "none");
|
|
|
179 |
tr.addClass("grabbed");
|
|
|
180 |
function move(e) {
|
|
|
181 |
console.log(Math.abs(e.pageY - sy));
|
|
|
182 |
if (!drag && Math.abs(e.pageY - sy) < 10) return;
|
|
|
183 |
drag = true;
|
|
|
184 |
tr.siblings().each(function() {
|
|
|
185 |
var s = $(this), i = s.index(), y = s.offset().top;
|
|
|
186 |
if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
|
|
|
187 |
if (e.pageY <= y + (s.outerHeight() / 2))
|
|
|
188 |
tr.insertBefore(s);
|
|
|
189 |
else
|
|
|
190 |
tr.insertAfter(s);
|
|
|
191 |
return false;
|
|
|
192 |
}
|
|
|
193 |
});
|
|
|
194 |
}
|
|
|
195 |
function up(e) {
|
|
|
196 |
if (drag && si != tr.index()) {
|
|
|
197 |
drag = false;
|
|
|
198 |
$("#update-rank").prop('disabled', false);
|
|
|
199 |
}
|
|
|
200 |
$(document).unbind("mousemove", move).unbind("mouseup", up);
|
|
|
201 |
b.removeClass("grabCursor").css("userSelect", "none");
|
|
|
202 |
tr.removeClass("grabbed");
|
|
|
203 |
}
|
|
|
204 |
$(document).mousemove(move).mouseup(up);
|
| 26738 |
amit.gupta |
205 |
});
|
| 26731 |
amit.gupta |
206 |
|
|
|
207 |
|
| 28270 |
tejbeer |
208 |
$(document).on('mousedown', ".grab", function(e) {
|
|
|
209 |
var tr = $(e.target).closest("#catalog-feature-table tr"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
|
|
|
210 |
b.addClass("grabCursor").css("userSelect", "none");
|
|
|
211 |
tr.addClass("grabbed");
|
|
|
212 |
function move(e) {
|
|
|
213 |
console.log(Math.abs(e.pageY - sy));
|
|
|
214 |
if (!drag && Math.abs(e.pageY - sy) < 10) return;
|
|
|
215 |
drag = true;
|
|
|
216 |
tr.siblings().each(function() {
|
|
|
217 |
var s = $(this), i = s.index(), y = s.offset().top;
|
|
|
218 |
if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
|
|
|
219 |
if (e.pageY <= y + (s.outerHeight() / 2))
|
|
|
220 |
tr.insertBefore(s);
|
|
|
221 |
else
|
|
|
222 |
tr.insertAfter(s);
|
|
|
223 |
return false;
|
|
|
224 |
}
|
|
|
225 |
});
|
|
|
226 |
}
|
|
|
227 |
function up(e) {
|
|
|
228 |
if (drag && si != tr.index()) {
|
|
|
229 |
drag = false;
|
|
|
230 |
$("#weblisting-update-rank").prop('disabled', false);
|
|
|
231 |
}
|
|
|
232 |
$(document).unbind("mousemove", move).unbind("mouseup", up);
|
|
|
233 |
b.removeClass("grabCursor").css("userSelect", "none");
|
|
|
234 |
tr.removeClass("grabbed");
|
|
|
235 |
}
|
|
|
236 |
$(document).mousemove(move).mouseup(up);
|
|
|
237 |
});
|
| 26738 |
amit.gupta |
238 |
|
|
|
239 |
|
| 28270 |
tejbeer |
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|