Subversion Repositories SmartDukaan

Rev

Rev 37899 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37899 Rev 37903
Line 51... Line 51...
51
				<input type="file" id="emi-cat-import-file" accept="application/json,.json" class="form-control"
51
				<input type="file" id="emi-cat-import-file" accept="application/json,.json" class="form-control"
52
					   required>
52
					   required>
53
			</div>
53
			</div>
54
			<div class="col-lg-3">
54
			<div class="col-lg-3">
55
				<button type="submit" class="btn btn-primary" id="emi-cat-import-btn">Import &amp; Persist</button>
55
				<button type="submit" class="btn btn-primary" id="emi-cat-import-btn">Import &amp; Persist</button>
-
 
56
			</div>
-
 
57
			<div class="col-lg-12" style="margin-top:6px;">
-
 
58
				<label style="font-weight: normal; cursor: pointer;">
-
 
59
					<input type="checkbox" id="emi-cat-wipe-all" checked>
-
 
60
					<strong>Wipe all existing EMI offers before import</strong>
56
				<span style="color:#666; font-size:11px; margin-left:8px;">Replaces existing offers per SKU.</span>
61
					<span style="color:#666; font-size:11px;">
-
 
62
						&nbsp;&mdash; recommended for a daily full-catalog refresh. Uncheck for partial / brand-scoped imports.
-
 
63
					</span>
-
 
64
				</label>
57
			</div>
65
			</div>
58
		</form>
66
		</form>
59
		<div class="col-lg-12 emi-import-result" id="emi-cat-import-result"></div>
67
		<div class="col-lg-12 emi-import-result" id="emi-cat-import-result"></div>
60
	</div>
68
	</div>
61
 
69
 
Line 107... Line 115...
107
			alert('Pick a JSON file first');
115
			alert('Pick a JSON file first');
108
			return;
116
			return;
109
		}
117
		}
110
		var fd = new FormData();
118
		var fd = new FormData();
111
		fd.append('file', fi.files[0]);
119
		fd.append('file', fi.files[0]);
-
 
120
		fd.append('wipeAll', $('#emi-cat-wipe-all').is(':checked'));
112
		var $btn = $('#emi-cat-import-btn');
121
		var $btn = $('#emi-cat-import-btn');
113
			$btn.prop('disabled', true).text('Importing...');
122
			$btn.prop('disabled', true).text('Importing...');
114
		$('#emi-cat-import-result').html('<em>Working…</em>');
123
		$('#emi-cat-import-result').html('<em>Working…</em>');
115
		$.ajax({
124
		$.ajax({
116
			url: context + '/emi-catalog/import',
125
			url: context + '/emi-catalog/import',
Line 126... Line 135...
126
			}
135
			}
127
		});
136
		});
128
	}
137
	}
129
 
138
 
130
	function renderEmiCatImportResult(r) {
139
	function renderEmiCatImportResult(r) {
-
 
140
		var wipedMsg = (r.wipedBeforeImport > 0)
-
 
141
				? '<span style="color:#c62828;">wiped ' + r.wipedBeforeImport + ' old products before import</span> &middot; '
-
 
142
				: '';
131
		var html = '<div class="alert alert-success">'
143
		var html = '<div class="alert alert-success">'
132
				+ '<strong>Imported.</strong> &middot; '
144
				+ '<strong>Imported.</strong> &middot; '
-
 
145
				+ wipedMsg
133
				+ 'products: ' + (r.productsUpserted || 0) + ' &middot; '
146
				+ 'products: ' + (r.productsUpserted || 0) + ' &middot; '
134
				+ 'groups: ' + (r.groupsInserted || 0) + ' &middot; '
147
				+ 'groups: ' + (r.groupsInserted || 0) + ' &middot; '
135
				+ 'plans: ' + (r.plansInserted || 0) + ' &middot; '
148
				+ 'plans: ' + (r.plansInserted || 0) + ' &middot; '
136
				+ 'cleared: ' + (r.groupsDeleted || 0) + ' old groups'
149
				+ 'cleared: ' + (r.groupsDeleted || 0) + ' per-product group refreshes'
137
				+ '</div>';
150
				+ '</div>';
138
		if (r.failures && r.failures.length) {
151
		if (r.failures && r.failures.length) {
139
			html += '<div class="alert alert-danger"><strong>Failures:</strong><ul>';
152
			html += '<div class="alert alert-danger"><strong>Failures:</strong><ul>';
140
			r.failures.forEach(function (f) {
153
			r.failures.forEach(function (f) {
141
				html += '<li>' + f + '</li>';
154
				html += '<li>' + f + '</li>';