Revision 28faaa2a
Von Tamino Steinert vor 10 Tagen hinzugefügt
js/kivi.Part.js | ||
---|---|---|
103 | 103 |
ns.renumber_positions(); |
104 | 104 |
}; |
105 | 105 |
|
106 |
ns.reorder_variants = function(order_by) { |
|
107 |
var dir = $('#variant_' + order_by + '_header_id a img').attr("data-sort-dir"); |
|
108 |
$('#parent_variant_table thead a img').remove();
|
|
106 |
ns.reorder_variants_values = function(order_by) {
|
|
107 |
var dir = $('#variant_value_' + order_by + '_header_id a img').attr("data-sort-dir");
|
|
108 |
$('#variant_value_table thead a img').remove();
|
|
109 | 109 |
|
110 | 110 |
var src; |
111 | 111 |
if (dir == "1") { |
... | ... | |
116 | 116 |
src = "image/down.png"; |
117 | 117 |
} |
118 | 118 |
|
119 |
$('#variant_' + order_by + '_header_id a').append('<img border=0 data-sort-dir=' + dir + ' src=' + src + ' alt="' + kivi.t8('sort items') + '">'); |
|
119 |
$('#variant_value_' + order_by + '_header_id a').append('<img border=0 data-sort-dir=' + dir + ' src=' + src + ' alt="' + kivi.t8('sort items') + '">');
|
|
120 | 120 |
|
121 | 121 |
var data = $('#ic').serializeArray(); |
122 |
data.push({ name: 'action', value: 'Part/reorder_variants' }, |
|
122 |
data.push({ name: 'action', value: 'Part/reorder_variants_values' },
|
|
123 | 123 |
{ name: 'order_by', value: order_by }, |
124 | 124 |
{ name: 'sort_dir', value: dir }); |
125 | 125 |
|
126 | 126 |
$.post("controller.pl", data, kivi.eval_json_result); |
127 | 127 |
}; |
128 | 128 |
|
129 |
ns.redisplay_variants = function(data) { |
|
130 |
var old_rows = $('.variant_row_entry').detach(); |
|
129 |
ns.redisplay_variants_values = function(data) { |
|
130 |
console.log("data", data); |
|
131 |
var old_rows = $('.variant_value_row_entry').detach(); |
|
131 | 132 |
var new_rows = []; |
132 | 133 |
$(data).each(function(idx, elt) { |
133 | 134 |
let new_row = old_rows[elt.old_pos - 1]; |
134 |
$(new_row).find('[name="variants[].position"]').val( idx+1); |
|
135 |
$(new_row).find('[name="variants_values[].position"]').val( idx+1);
|
|
135 | 136 |
new_rows.push(new_row); |
136 | 137 |
}); |
137 |
$(new_rows).appendTo($('#parent_variant_table'));
|
|
138 |
$(new_rows).appendTo($('#variant_value_table'));
|
|
138 | 139 |
}; |
139 | 140 |
|
140 |
ns.get_selected_variants = function() { |
|
141 |
ns.get_selected_variants_values = function() {
|
|
141 | 142 |
let selected_rows = []; |
142 | 143 |
$('[name^="variant_multi_id_"]').each( function() { |
143 | 144 |
if (this.checked) { |
... | ... | |
147 | 148 |
return selected_rows; |
148 | 149 |
} |
149 | 150 |
|
150 |
ns.variant_rows_toggle_selected = function() { |
|
151 |
ns.variant_value_rows_toggle_selected = function() {
|
|
151 | 152 |
$('[name^="variant_multi_id_"]').each( function() { |
152 | 153 |
this.checked = !this.checked; |
153 | 154 |
}); |
154 | 155 |
} |
155 | 156 |
|
156 | 157 |
ns.set_selected_variants_to_value = function(value_name) { |
157 |
let value = $('[name="' + value_name + '_for_selected_variants"]').val(); |
|
158 |
let selected_rows = ns.get_selected_variants(); |
|
158 |
let value = $('[name="' + value_name + '_for_selected_variants_values"]').val();
|
|
159 |
let selected_rows = ns.get_selected_variants_values();
|
|
159 | 160 |
selected_rows.forEach(function(row) { |
160 | 161 |
$(row).find( |
161 |
'[name="variants[].' + value_name + '"]' |
|
162 |
'[name="variants_values[].' + value_name + '"]'
|
|
162 | 163 |
).val( |
163 | 164 |
value |
164 | 165 |
); |
165 | 166 |
}); |
166 | 167 |
}; |
167 | 168 |
|
169 |
ns.reorder_variants_properties = function(order_by) { |
|
170 |
var dir = $('#variant_property_' + order_by + '_header_id a img').attr("data-sort-dir"); |
|
171 |
$('#variant_property_table thead a img').remove(); |
|
172 |
|
|
173 |
var src; |
|
174 |
if (dir == "1") { |
|
175 |
dir = "0"; |
|
176 |
src = "image/up.png"; |
|
177 |
} else { |
|
178 |
dir = "1"; |
|
179 |
src = "image/down.png"; |
|
180 |
} |
|
181 |
|
|
182 |
$('#variant_property_' + order_by + '_header_id a').append('<img border=0 data-sort-dir=' + dir + ' src=' + src + ' alt="' + kivi.t8('sort items') + '">'); |
|
183 |
|
|
184 |
var data = $('#ic').serializeArray(); |
|
185 |
data.push({ name: 'action', value: 'Part/reorder_variants_properties' }, |
|
186 |
{ name: 'order_by', value: order_by }, |
|
187 |
{ name: 'sort_dir', value: dir }); |
|
188 |
|
|
189 |
$.post("controller.pl", data, kivi.eval_json_result); |
|
190 |
}; |
|
191 |
|
|
192 |
ns.redisplay_variants_properties = function(data) { |
|
193 |
var old_rows = $('.variant_property_row_entry').detach(); |
|
194 |
var new_rows = []; |
|
195 |
$(data).each(function(idx, elt) { |
|
196 |
let new_row = old_rows[elt.old_pos - 1]; |
|
197 |
$(new_row).find('[name="variants_properties[].position"]').val( idx+1); |
|
198 |
new_rows.push(new_row); |
|
199 |
}); |
|
200 |
$(new_rows).appendTo($('#variant_property_table')); |
|
201 |
}; |
|
202 |
|
|
203 |
|
|
204 |
ns.get_selected_variants_properties = function() { |
|
205 |
let selected_rows = []; |
|
206 |
$('[name^="variant_property_multi_id_"]').each( function() { |
|
207 |
if (this.checked) { |
|
208 |
selected_rows.push($(this).parents("tr").first()); |
|
209 |
} |
|
210 |
}); |
|
211 |
return selected_rows; |
|
212 |
} |
|
213 |
|
|
214 |
ns.variant_property_rows_toggle_selected = function() { |
|
215 |
$('[name^="variant_property_multi_id_"]').each( function() { |
|
216 |
this.checked = !this.checked; |
|
217 |
}); |
|
218 |
} |
|
219 |
|
|
220 |
ns.set_selected_variants_to_property = function(value_name) { |
|
221 |
let value = $('[name="' + value_name + '_for_selected_variants_properties"]').val(); |
|
222 |
let selected_rows = ns.get_selected_variants_properties(); |
|
223 |
selected_rows.forEach(function(row) { |
|
224 |
$(row).find( |
|
225 |
'[name="variants_properties[].' + value_name + '"]' |
|
226 |
).val( |
|
227 |
value |
|
228 |
); |
|
229 |
}); |
|
230 |
}; |
|
231 |
|
|
232 |
ns.remove_variant_property = function(button) { |
|
233 |
if (!confirm(kivi.t8("Do you really want to delete the property?"))) return; |
|
234 |
let column_head_th = $(button).parents("th").first()[0]; |
|
235 |
let index = column_head_th.cellIndex; |
|
236 |
let table = $('#variant_property_table')[0]; |
|
237 |
for(const row of table.rows) { |
|
238 |
row.deleteCell(index); |
|
239 |
}; |
|
240 |
}; |
|
241 |
|
|
168 | 242 |
ns.assortment_recalc = function() { |
169 | 243 |
var data = $('#assortment :input').serializeArray(); |
170 | 244 |
data.push( |
... | ... | |
411 | 485 |
$.post("controller.pl", data, kivi.eval_json_result); |
412 | 486 |
}; |
413 | 487 |
|
414 |
ns.update_variants = function() { |
|
488 |
ns.update_variants_values = function() { |
|
489 |
var data = $('#ic').serializeArray(); |
|
490 |
data.push({ name: 'action', value: 'Part/update_variants_values' }); |
|
491 |
$.post("controller.pl", data, kivi.eval_json_result); |
|
492 |
}; |
|
493 |
|
|
494 |
ns.update_variants_properties = function() { |
|
415 | 495 |
var data = $('#ic').serializeArray(); |
416 |
data.push({ name: 'action', value: 'Part/update_variants' }); |
|
496 |
data.push({ name: 'action', value: 'Part/update_variants_properties' });
|
|
417 | 497 |
$.post("controller.pl", data, kivi.eval_json_result); |
418 | 498 |
}; |
419 | 499 |
|
... | ... | |
1075 | 1155 |
|
1076 | 1156 |
$('#part_warehouse_id').change(kivi.Part.reload_bin_selection); |
1077 | 1157 |
|
1078 |
$('#variant_select_all').click( function() { |
|
1158 |
$('#variant_value_select_all').click( function() { |
|
1159 |
var checked = this.checked; |
|
1160 |
$('[name^="variant_value_multi_id_"]').each(function() { |
|
1161 |
this.checked = checked; |
|
1162 |
}); |
|
1163 |
}); |
|
1164 |
|
|
1165 |
$('#variant_property_select_all').click( function() { |
|
1079 | 1166 |
var checked = this.checked; |
1080 |
$('[name^="variant_multi_id_"]').each(function() { |
|
1167 |
$('[name^="variant_property_multi_id_"]').each(function() {
|
|
1081 | 1168 |
this.checked = checked; |
1082 | 1169 |
}); |
1083 | 1170 |
}); |
Auch abrufbar als: Unified diff
Varianten: Varianten Ausprägungen bearbeiten