| 28371 |
amit.gupta |
1 |
$(document).on('click', ".web-offers", function() {
|
|
|
2 |
doAjaxRequestHandler(context + "/web-offers", "GET", function(response) {
|
|
|
3 |
$('#main-content').html(response);
|
|
|
4 |
});
|
|
|
5 |
});
|
|
|
6 |
$(document).on('click', "a.web-offer-details", function() {
|
|
|
7 |
var webOfferId = $(this).data("id");
|
|
|
8 |
doAjaxRequestHandler(`${context}/web-offer/${webOfferId}`, "GET", function(response) {
|
|
|
9 |
$('.web-offer-products-container').html(response);
|
|
|
10 |
});
|
|
|
11 |
|
|
|
12 |
})
|
|
|
13 |
|
|
|
14 |
$(document).on('click', ".update-rank", function(){
|
|
|
15 |
if(confirm("Are you sure you want to update ranks?")) {
|
|
|
16 |
var webListingId=$(this).data("id");
|
|
|
17 |
var webProductIds=[];
|
|
|
18 |
$("#web-product-listing-tbody").find("tr").each(function(){
|
|
|
19 |
console.log(this);
|
|
|
20 |
webProductIds.push($(this).data("id"));
|
|
|
21 |
});
|
|
|
22 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
|
|
|
23 |
$('.web-products-container').html(response);
|
|
|
24 |
});
|
|
|
25 |
}
|
|
|
26 |
});
|
|
|
27 |
$(document).on('click', "#add-to-offer", function() {
|
|
|
28 |
var webOfferId=$(this).data("id");
|
|
|
29 |
var entityIds = [entityId];
|
|
|
30 |
|
|
|
31 |
var entityIdTxt=$("#entityData").val();
|
|
|
32 |
if(entityIdTxt.length > 0) {
|
|
|
33 |
if(entityIdTxt.indexOf(",") > 0) {
|
|
|
34 |
entityIds = entityIdTxt.split(",");
|
|
|
35 |
}
|
|
|
36 |
} else {
|
|
|
37 |
alert("Please enter items");
|
|
|
38 |
return;
|
|
|
39 |
}
|
|
|
40 |
json = [];
|
|
|
41 |
for(var e of entityIds) {
|
|
|
42 |
json.push({webOfferId:webOfferId, entityId: e});
|
|
|
43 |
}
|
|
|
44 |
console.log(json);
|
|
|
45 |
console.log(JSON.stringify(json))
|
|
|
46 |
doPostAjaxRequestWithJsonHandler(`${context}/web-offer-product/add`, JSON.stringify(json), function(response) {
|
|
|
47 |
$('.web-offer-products-container').html(response);
|
|
|
48 |
});
|
|
|
49 |
|
|
|
50 |
});
|
|
|
51 |
|
|
|
52 |
$(document).on('click', "a.product-remove", function() {
|
|
|
53 |
var webOfferProductId = $(this).closest('tr').data("id");
|
|
|
54 |
if (confirm("Are you sure you want to remove the Item!") == true) {
|
|
|
55 |
|
|
|
56 |
doDeleteAjaxRequestHandler(`${context}/web-offer-product/remove?webOfferProductId=${webOfferProductId}`, function(response) {
|
|
|
57 |
alert("Product removed successfully");
|
|
|
58 |
$('.web-products-container').html(response);
|
|
|
59 |
});
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
})
|
|
|
63 |
|
|
|
64 |
function addWebOffer() {
|
|
|
65 |
webOfferTitle = $("#web-offer-title").val();
|
|
|
66 |
smallText = $("#small-text").val();
|
|
|
67 |
largeText = $("#large-text").val();
|
|
|
68 |
smallBannerUrl = $("#offer-banner-small").val();
|
|
|
69 |
var json = {
|
|
|
70 |
id : 0,
|
|
|
71 |
title : webOfferTitle,
|
|
|
72 |
smallText : smallText,
|
|
|
73 |
largeText : largeText,
|
|
|
74 |
smallBannerUrl : smallBannerUrl,
|
|
|
75 |
startDate : startDate,
|
|
|
76 |
endDate : endDate
|
|
|
77 |
}
|
|
|
78 |
doPostAjaxRequestWithJsonHandler(context + "/web-offer/add", JSON.stringify(json), function(response) {
|
|
|
79 |
$('#main-content').html(response);
|
|
|
80 |
});
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
$(document).on('mousedown', ".grab", function (e) {
|
|
|
85 |
var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
|
|
|
86 |
b.addClass("grabCursor").css("userSelect", "none");
|
|
|
87 |
tr.addClass("grabbed");
|
|
|
88 |
function move (e) {
|
|
|
89 |
console.log(Math.abs(e.pageY - sy));
|
|
|
90 |
if (!drag && Math.abs(e.pageY - sy) < 10) return;
|
|
|
91 |
drag = true;
|
|
|
92 |
tr.siblings().each(function() {
|
|
|
93 |
var s = $(this), i = s.index(), y = s.offset().top;
|
|
|
94 |
if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
|
|
|
95 |
if (e.pageY <= y + (s.outerHeight()/2))
|
|
|
96 |
tr.insertBefore(s);
|
|
|
97 |
else
|
|
|
98 |
tr.insertAfter(s);
|
|
|
99 |
return false;
|
|
|
100 |
}
|
|
|
101 |
});
|
|
|
102 |
}
|
|
|
103 |
function up (e) {
|
|
|
104 |
if (drag && si != tr.index()) {
|
|
|
105 |
drag = false;
|
|
|
106 |
$(".update-rank").prop('disabled', false);
|
|
|
107 |
}
|
|
|
108 |
$(document).unbind("mousemove", move).unbind("mouseup", up);
|
|
|
109 |
b.removeClass("grabCursor").css("userSelect", "none");
|
|
|
110 |
tr.removeClass("grabbed");
|
|
|
111 |
}
|
|
|
112 |
$(document).mousemove(move).mouseup(up);
|
|
|
113 |
});
|
|
|
114 |
|
|
|
115 |
$(document).on('click', ".update-rank", function() {
|
|
|
116 |
if (confirm("Are you sure you want to update ranks?")) {
|
|
|
117 |
var webListingId = $(this).data("id");
|
|
|
118 |
var webProductIds = [];
|
|
|
119 |
$("#web-product-listing-tbody").find("tr").each(function() {
|
|
|
120 |
console.log(this);
|
|
|
121 |
webProductIds.push($(this).data("id"));
|
|
|
122 |
});
|
|
|
123 |
doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
|
|
|
124 |
$('.web-offer-products-container').html(response);
|
|
|
125 |
});
|
|
|
126 |
}
|
|
|
127 |
});
|
|
|
128 |
|
|
|
129 |
|