Subversion Repositories SmartDukaan

Rev

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

Rev 34490 Rev 34495
Line 147... Line 147...
147
		console.log('response', response);
147
		console.log('response', response);
148
 
148
 
149
		// Remove old expanded rows
149
		// Remove old expanded rows
150
		$('.expanded-row').remove();
150
		$('.expanded-row').remove();
151
 
151
 
152
		var expandHtml = '<tr class="expanded-row"><td colspan="10">' + buildStockInfoHtml(response) + '</td></tr>';
152
		var expandHtml = '<tr class="expanded-row"><td colspan="10">' + buildStockInfoHtml(response.response) + '</td></tr>';
153
 
153
 
154
		$clickedTr.after(expandHtml);
154
		$clickedTr.after(expandHtml);
155
	});
155
	});
156
});
156
});
157
 
157
 
-
 
158
// function to build HTML when response is a LIST
158
function buildStockInfoHtml(response) {
159
function buildStockInfoHtml(responseList) {
159
	if (!response) {
160
	console.log("responseList {}", responseList);
-
 
161
	if (!Array.isArray(responseList) || responseList.length === 0) {
160
		return '<div>No stock info available.</div>';
162
		return '<div>No stock info available.</div>';
161
	}
163
	}
162
 
164
 
163
	// if it's a single object
-
 
164
	var html = '<div style="padding:10px; background:#f1f1f1; border:1px solid #ccc;">';
165
	var html = '<div style="padding:10px; background:#f9f9f9; border:1px solid #ccc;">';
165
	html += '<strong>Stock Info:</strong><br>';
166
	html += '<strong>Stock Details:</strong>';
166
	html += '<ul>';
-
 
167
	html += '<li><strong>Item ID:</strong> ' + response.itemId + '</li>';
167
	html += '<table class="table table-bordered" style="margin-top:10px;">';
168
	html += '<li><strong>Availability:</strong> ' + response.availability + '</li>';
168
	html += '<thead><tr><th>Item ID</th><th>Availability</th><th>Description</th></tr></thead>';
-
 
169
	html += '<tbody>';
169
 
170
 
170
	if (response.itemDescription && response.itemDescription !== 0) {
171
	responseList.forEach(function (item) {
-
 
172
		html += '<tr>';
171
		html += '<li><strong>Description:</strong> ' + response.itemDescription + '</li>';
173
		html += '<td>' + item.itemId + '</td>';
172
	} else {
174
		html += '<td>' + item.availability + '</td>';
173
		html += '<li><strong>Description:</strong> Not available</li>';
175
		html += '<td>' + (item.itemDescription && item.itemDescription !== 0 ? item.itemDescription : 'Not Available') + '</td>';
-
 
176
		html += '</tr>';
174
	}
177
	});
175
 
178
 
176
	html += '</ul></div>';
179
	html += '</tbody></table></div>';
177
 
180
 
178
	return html;
181
	return html;
179
}
182
}
180
 
183
 
181
 
184