Subversion Repositories SmartDukaan

Rev

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

Rev 27754 Rev 28270
Line 4... Line 4...
4
$(document).on('click', "a.listing-details", function() {
4
$(document).on('click', "a.listing-details", function() {
5
	var webListingId = $(this).data("id");
5
	var webListingId = $(this).data("id");
6
	doAjaxRequestHandler(`${context}/web-listing/${webListingId}`, "GET", function(response) {
6
	doAjaxRequestHandler(`${context}/web-listing/${webListingId}`, "GET", function(response) {
7
		$('.web-products-container').html(response);
7
		$('.web-products-container').html(response);
8
	});
8
	});
9
	
9
 
10
})
10
})
11
 
11
 
-
 
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
 
12
$(document).on('click', "#update-rank", function(){
48
$(document).on('click', "#update-rank", function() {
13
	if(confirm("Are you sure you want to update ranks?")) {
49
	if (confirm("Are you sure you want to update ranks?")) {
14
		var webListingId=$(this).data("id");
50
		var webListingId = $(this).data("id");
15
		var webProductIds=[];
51
		var webProductIds = [];
16
		$("#web-product-listing-tbody").find("tr").each(function(){
52
		$("#web-product-listing-tbody").find("tr").each(function() {
17
			console.log(this);
53
			console.log(this);
18
			webProductIds.push($(this).data("id"));
54
			webProductIds.push($(this).data("id"));
19
		});
55
		});
20
		doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
56
		doPostAjaxRequestWithJsonHandler(`${context}/web-listing/order/${webListingId}`, JSON.stringify(webProductIds), function(response) {
21
			$('.web-products-container').html(response);
57
			$('.web-products-container').html(response);
22
		});
58
		});
23
	}
59
	}
24
});
60
});
-
 
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
 
25
$(document).on('click', "#add-listing", function() {
120
$(document).on('click', "#add-listing", function() {
26
	var webListingId=$(this).data("id");
121
	var webListingId = $(this).data("id");
27
	var entityIds = [entityId];
122
	var entityIds = [entityId];
28
 
123
 
29
	var entityIdTxt=$("#entityData").val();
124
	var entityIdTxt = $("#entityData").val();
30
	if(entityIdTxt.length > 0) {
125
	if (entityIdTxt.length > 0) {
31
		if(entityIdTxt.indexOf(",") > 0) {
126
		if (entityIdTxt.indexOf(",") > 0) {
32
			entityIds = entityIdTxt.split(",");
127
			entityIds = entityIdTxt.split(",");
33
		}
128
		}
34
	} else {
129
	} else {
35
		alert("Please enter items");
130
		alert("Please enter items");
36
		return;
131
		return;
37
	}
132
	}
38
	json = [];
133
	json = [];
39
	for(var e of entityIds) {
134
	for (var e of entityIds) {
40
		json.push({webListingId:webListingId, entityId: e});
135
		json.push({ webListingId: webListingId, entityId: e });
41
	}
136
	}
42
	console.log(json);
137
	console.log(json);
43
	console.log(JSON.stringify(json))
138
	console.log(JSON.stringify(json))
44
	doPostAjaxRequestWithJsonHandler(`${context}/web-product-listing/add`, JSON.stringify(json), function(response) {
139
	doPostAjaxRequestWithJsonHandler(`${context}/web-product-listing/add`, JSON.stringify(json), function(response) {
45
		$('.web-products-container').html(response);
140
		$('.web-products-container').html(response);
46
	});
141
	});
47
	
142
 
48
});
143
});
49
 
144
 
50
function loadWebListing(domId) {
145
function loadWebListing(domId) {
51
	doAjaxRequestHandler(context + "/web-listing", "GET", function(response) {
146
	doAjaxRequestHandler(context + "/web-listing", "GET", function(response) {
52
		$('#' + domId).html(response);
147
		$('#' + domId).html(response);
53
	});
148
	});
54
}
149
}
55
function addWebListing() {
150
function addWebListing() {
56
	webListingTitle = $("#web-listing-title").val();
151
	webListingTitle = $("#web-listing-title").val();
57
	webListingUrl = $("#web-listing-url").val();
152
	webListingUrl = $("#web-listing-url").val();
-
 
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
 
58
	json = {title:webListingTitle, url : webListingUrl};
169
	json = { title: webListingTitle, url: webListingUrl, rank: webListingRank };
59
	doPostAjaxRequestWithJsonHandler(context + "/web-listing/add", JSON.stringify(json), function(response) {
170
	doPostAjaxRequestWithJsonHandler(context + "/web-listing/add", JSON.stringify(json), function(response) {
60
		$('#main-content').html(response);
171
		$('#main-content').html(response);
61
	});
172
	});
62
}
173
}
63
 
174
 
64
 
175
 
65
$(document).on('mousedown', ".grab", function (e) {
176
$(document).on('mousedown', ".grab", function(e) {
66
    var tr = $(e.target).closest("TR"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
177
	var tr = $(e.target).closest("#web-product-listing-table tr"), si = tr.index(), sy = e.pageY, b = $(document.body), drag;
67
    b.addClass("grabCursor").css("userSelect", "none");
178
	b.addClass("grabCursor").css("userSelect", "none");
68
    tr.addClass("grabbed");
179
	tr.addClass("grabbed");
69
    function move (e) {
180
	function move(e) {
70
    	console.log(Math.abs(e.pageY - sy));
181
		console.log(Math.abs(e.pageY - sy));
71
        if (!drag && Math.abs(e.pageY - sy) < 10) return;
182
		if (!drag && Math.abs(e.pageY - sy) < 10) return;
72
        drag = true;
183
		drag = true;
73
        tr.siblings().each(function() {
184
		tr.siblings().each(function() {
74
            var s = $(this), i = s.index(), y = s.offset().top;
185
			var s = $(this), i = s.index(), y = s.offset().top;
75
            if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
186
			if (e.pageY >= y && e.pageY < y + s.outerHeight()) {
76
                if (e.pageY <= y + (s.outerHeight()/2))
187
				if (e.pageY <= y + (s.outerHeight() / 2))
77
                    tr.insertBefore(s);
188
					tr.insertBefore(s);
78
                else
189
				else
79
                    tr.insertAfter(s);
190
					tr.insertAfter(s);
80
                return false;
191
				return false;
-
 
192
			}
-
 
193
		});
-
 
194
	}
-
 
195
	function up(e) {
-
 
196
		if (drag && si != tr.index()) {
81
            }
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);
-
 
205
});
-
 
206
 
-
 
207
 
-
 
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;
82
        });
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;
83
    }
224
			}
-
 
225
		});
-
 
226
	}
84
    function up (e) {
227
	function up(e) {
85
        if (drag && si != tr.index()) {
228
		if (drag && si != tr.index()) {
86
            drag = false;
229
			drag = false;
87
            $("#update-rank").prop('disabled', false);
230
			$("#weblisting-update-rank").prop('disabled', false);
88
        }
231
		}
89
        $(document).unbind("mousemove", move).unbind("mouseup", up);
232
		$(document).unbind("mousemove", move).unbind("mouseup", up);
90
        b.removeClass("grabCursor").css("userSelect", "none");
233
		b.removeClass("grabCursor").css("userSelect", "none");
91
        tr.removeClass("grabbed");
234
		tr.removeClass("grabbed");
92
    }
235
	}
93
    $(document).mousemove(move).mouseup(up);
236
	$(document).mousemove(move).mouseup(up);
94
});
237
});
95
 
238
 
96
 
239
 
97
 
240
 
98
 
241
 
-
 
242
 
-
 
243