Subversion Repositories SmartDukaan

Rev

Rev 30596 | Rev 30603 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30596 Rev 30599
Line 1... Line 1...
1
$(document).on('click', ".web-offers", function() {
1
$(document).on('click', ".web-offers", function () {
2
	doAjaxRequestHandler(context + "/web-offers", "GET", function(response) {
2
	doAjaxRequestHandler(context + "/web-offers", "GET", function (response) {
3
		$('#main-content').html(response);
3
		$('#main-content').html(response);
4
	});
4
	});
5
});
5
});
6
$(document).on('click', "a.web-offer-details", function() {
6
$(document).on('click', "a.web-offer-details", function () {
7
	var webOfferId = $(this).data("id");
7
	var webOfferId = $(this).data("id");
8
	doAjaxRequestHandler(`${context}/web-offer/${webOfferId}`, "GET", function(response) {
8
	doAjaxRequestHandler(`${context}/web-offer/${webOfferId}`, "GET", function (response) {
9
		$('.web-offer-products-container').html(response);
9
		$('.web-offer-products-container').html(response);
10
	});
10
	});
11
 
11
 
12
})
12
})
13
 
13
 
14
 
14
 
15
$(document).on('click', ".web-offer-id", function() {
15
$(document).on('click', ".web-offer-id", function () {
16
	var webOfferId = $(this).data("id");
16
	var webOfferId = $(this).data("id");
17
	doAjaxRequestHandler(`${context}/getwebOffer/${webOfferId}`, "GET", function(response) {
17
	doAjaxRequestHandler(`${context}/getwebOffer/${webOfferId}`, "GET", function (response) {
18
		$('.web-offer-edit-container .modal-content').html(response);
18
		$('.web-offer-edit-container .modal-content').html(response);
19
	});
19
	});
20
});
20
});
21
 
21
 
22
 
22
 
23
 
-
 
24
$(document).on('click', ".updateWebOfferDuration", function() {
23
$(document).on('click', ".updateWebOfferDuration", function () {
25
	var webOfferId = $(this).data("id");
24
	var webOfferId = $(this).data("id");
26
 
25
 
27
	if (confirm("Are you sure you want to update offer!") == true) {
26
	if (confirm("Are you sure you want to update offer!") == true) {
28
		doPostAjaxRequestHandler(context
27
		doPostAjaxRequestHandler(context
29
			+ "/web-offer-duration/update?id="
28
			+ "/web-offer-duration/update?id="
30
			+ webOfferId + "&startDate=" + startDate + "&endDate=" + endDate, function(response) {
29
			+ webOfferId + "&startDate=" + startDate + "&endDate=" + endDate, function (response) {
31
				if (response == 'true') {
30
			if (response == 'true') {
32
					alert("update successfully ");
31
				alert("update successfully ");
33
 
32
 
34
					$('#main-content').html(response);
33
				$('#main-content').html(response);
35
				}
34
			}
36
			});
35
		});
37
 
36
 
38
		return false;
37
		return false;
39
	}
38
	}
40
 
39
 
41
});
40
});
42
 
41
 
43
 
42
 
44
$(document).on('click', "#add-to-offer", function() {
43
$(document).on('click', "#add-to-offer", function () {
45
	var webOfferId = $(this).data("id");
44
	var webOfferId = $(this).data("id");
46
	var entityIds = [entityId];
45
	var entityIds = [entityId];
47
 
46
 
48
	var entityIdTxt = $("#entityData").val();
47
	var entityIdTxt = $("#entityData").val();
49
	if (entityIdTxt.length > 0) {
48
	if (entityIdTxt.length > 0) {
Line 54... Line 53...
54
		alert("Please enter items");
53
		alert("Please enter items");
55
		return;
54
		return;
56
	}
55
	}
57
	json = [];
56
	json = [];
58
	for (var e of entityIds) {
57
	for (var e of entityIds) {
59
		json.push({ webOfferId: webOfferId, entityId: e });
58
		json.push({webOfferId: webOfferId, entityId: e});
60
	}
59
	}
61
	console.log(json);
60
	console.log(json);
62
	console.log(JSON.stringify(json))
61
	console.log(JSON.stringify(json))
63
	doPostAjaxRequestWithJsonHandler(`${context}/web-offer-product/add`, JSON.stringify(json), function(response) {
62
	doPostAjaxRequestWithJsonHandler(`${context}/web-offer-product/add`, JSON.stringify(json), function (response) {
64
		$('.web-offer-products-container').html(response);
63
		$('.web-offer-products-container').html(response);
65
	});
64
	});
66
 
65
 
67
});
66
});
68
 
67
 
69
$(document).on('click', "a.product-remove", function() {
68
$(document).on('click', "a.product-remove", function () {
70
	var webOfferProductId = $(this).closest('tr').data("id");
69
	var webOfferProductId = $(this).closest('tr').data("id");
71
	if (confirm("Are you sure you want to remove the Item!") == true) {
70
	if (confirm("Are you sure you want to remove the Item!") == true) {
72
 
71
 
73
		doDeleteAjaxRequestHandler(`${context}/web-offer-product/remove?webOfferProductId=${webOfferProductId}`, function(response) {
72
		doDeleteAjaxRequestHandler(`${context}/web-offer-product/remove?webOfferProductId=${webOfferProductId}`, function (response) {
74
			alert("Product removed successfully");
73
			alert("Product removed successfully");
75
			$('.web-products-container').html(response);
74
			$('.web-products-container').html(response);
76
		});
75
		});
77
	}
76
	}
78
 
77
 
Line 93... Line 92...
93
		id: 0,
92
		id: 0,
94
		title: webOfferTitle,
93
		title: webOfferTitle,
95
		smallText: smallText,
94
		smallText: smallText,
96
		largeText: largeText,
95
		largeText: largeText,
97
		smallBannerUrl: smallBannerUrl,
96
		smallBannerUrl: smallBannerUrl,
98
		startDate: startDate,
97
		startDate: getDatesFromPicker($('input[name="offerdateRange"]')).startDate,
99
		endDate: endDate
98
		endDate: getDatesFromPicker($('input[name="offerdateRange"]')).endDate
100
	}
99
	}
101
	if (confirm("Are you sure you want to add the offer!") == true) {
100
	if (confirm("Are you sure you want to add the offer!") == true) {
102
		doPostAjaxRequestWithJsonHandler(context + "/web-offer/add", JSON.stringify(json), function(response) {
101
		doPostAjaxRequestWithJsonHandler(context + "/web-offer/add", JSON.stringify(json), function (response) {
103
			$('#main-content').html(response);
102
			$('#main-content').html(response);
104
		});
103
		});
105
	}
104
	}
106
}
105
}
107
 
106
 
108
 
107
 
109
$(document).on('mousedown', ".grab", function(e) {
108
$(document).on('mousedown', ".grab", function (e) {
110
	var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
109
	var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
111
	b.addClass("grabCursor").css("userSelect", "none");
110
	b.addClass("grabCursor").css("userSelect", "none");
112
	tr.addClass("grabbed");
111
	tr.addClass("grabbed");
-
 
112
 
113
	function move(e) {
113
	function move(e) {
114
		console.log(Math.abs(e.pageY - sy));
114
		console.log(Math.abs(e.pageY - sy));
115
		if (!drag && Math.abs(e.pageY - sy) < 10) return;
115
		if (!drag && Math.abs(e.pageY - sy) < 10) return;
116
		drag = true;
116
		drag = true;
117
		tr.siblings().each(function() {
117
		tr.siblings().each(function () {
118
			var s = $(this), i = s.index(), y = s.offset().top;
118
			var s = $(this), i = s.index(), y = s.offset().top;
119
			if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
119
			if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
120
				if (e.pageY <= y + (s.outerHeight() / 2))
120
				if (e.pageY <= y + (s.outerHeight() / 2))
121
					tr.insertBefore(s);
121
					tr.insertBefore(s);
122
				else
122
				else
123
					tr.insertAfter(s);
123
					tr.insertAfter(s);
124
				return false;
124
				return false;
125
			}
125
			}
126
		});
126
		});
127
	}
127
	}
-
 
128
 
128
	function up(e) {
129
	function up(e) {
129
		if (drag && si != tr.index()) {
130
		if (drag && si != tr.index()) {
130
			drag = false;
131
			drag = false;
131
			$(".update-rank").prop('disabled', false);
132
			$(".update-rank").prop('disabled', false);
132
		}
133
		}
133
		$(document).unbind("mousemove", move).unbind("mouseup", up);
134
		$(document).unbind("mousemove", move).unbind("mouseup", up);
134
		b.removeClass("grabCursor").css("userSelect", "none");
135
		b.removeClass("grabCursor").css("userSelect", "none");
135
		tr.removeClass("grabbed");
136
		tr.removeClass("grabbed");
136
	}
137
	}
-
 
138
 
137
	$(document).mousemove(move).mouseup(up);
139
	$(document).mousemove(move).mouseup(up);
138
});
140
});
139
 
141
 
140
$(document).on('click', ".update-rank", function() {
142
$(document).on('click', ".update-rank", function () {
141
	if (confirm("Are you sure you want to update ranks?")) {
143
	if (confirm("Are you sure you want to update ranks?")) {
142
		var webListingId = $(this).data("id");
144
		var webListingId = $(this).data("id");
143
		var webProductIds = [];
145
		var webProductIds = [];
144
		$("#web-product-listing-tbody").find("tr").each(function() {
146
		$("#web-product-listing-tbody").find("tr").each(function () {
145
			console.log(this);
147
			console.log(this);
146
			webProductIds.push($(this).data("id"));
148
			webProductIds.push($(this).data("id"));
147
		});
149
		});
148
		doPostAjaxRequestWithJsonHandler(`${context}/web-offer/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
150
		doPostAjaxRequestWithJsonHandler(`${context}/web-offer/order/${webListingId}`, JSON.stringify(webProductIds), function (response) {
149
			$('.web-offer-products-container').html(response);
151
			$('.web-offer-products-container').html(response);
150
		});
152
		});
151
	}
153
	}
152
});
154
});
153
 
155