Revision 9e05d029
Von Sven Schöling vor mehr als 3 Jahren hinzugefügt
js/kivi.Part.js | ||
---|---|---|
7 | 7 |
url: 'controller.pl?action=Part/history&part.id=' + id, |
8 | 8 |
dialog: { title: kivi.t8('History') }, |
9 | 9 |
}); |
10 |
} |
|
10 |
};
|
|
11 | 11 |
|
12 | 12 |
ns.save = function() { |
13 | 13 |
var data = $('#ic').serializeArray(); |
... | ... | |
34 | 34 |
}; |
35 | 35 |
|
36 | 36 |
ns.set_tab_active_by_index = function (index) { |
37 |
$("#ic_tabs").tabs({active: index}) |
|
37 |
$("#ic_tabs").tabs({active: index});
|
|
38 | 38 |
}; |
39 | 39 |
|
40 | 40 |
ns.set_tab_active_by_name= function (name) { |
... | ... | |
66 | 66 |
|
67 | 67 |
$('#' + order_by + '_header_id a').append('<img border=0 data-sort-dir=' + dir + ' src=' + src + ' alt="' + kivi.t8('sort items') + '">'); |
68 | 68 |
|
69 |
data.push({ name: 'action', value: 'Part/reorder_items' }, |
|
70 |
{ name: 'order_by', value: order_by }, |
|
71 |
{ name: 'part_type', value: part_type }, |
|
72 |
{ name: 'sort_dir', value: dir }); |
|
69 |
data.push( |
|
70 |
{ name: 'action', value: 'Part/reorder_items' }, |
|
71 |
{ name: 'order_by', value: order_by }, |
|
72 |
{ name: 'part_type', value: part_type }, |
|
73 |
{ name: 'sort_dir', value: dir } |
|
74 |
); |
|
73 | 75 |
|
74 | 76 |
$.post("controller.pl", data, kivi.eval_json_result); |
75 | 77 |
}; |
76 | 78 |
|
77 | 79 |
ns.assortment_recalc = function() { |
78 | 80 |
var data = $('#assortment :input').serializeArray(); |
79 |
data.push({ name: 'action', value: 'Part/update_item_totals' }, |
|
80 |
{ name: 'part_type', value: 'assortment' }); |
|
81 |
data.push( |
|
82 |
{ name: 'action', value: 'Part/update_item_totals' }, |
|
83 |
{ name: 'part_type', value: 'assortment' } |
|
84 |
); |
|
81 | 85 |
|
82 | 86 |
$.post("controller.pl", data, kivi.eval_json_result); |
83 | 87 |
}; |
84 | 88 |
|
85 | 89 |
ns.assembly_recalc = function() { |
86 | 90 |
var data = $('#assembly :input').serializeArray(); |
87 |
data.push( { name: 'action', value: 'Part/update_item_totals' }, |
|
88 |
{ name: 'part_type', value: 'assembly' }); |
|
91 |
data.push( |
|
92 |
{ name: 'action', value: 'Part/update_item_totals' }, |
|
93 |
{ name: 'part_type', value: 'assembly' } |
|
94 |
); |
|
89 | 95 |
|
90 | 96 |
$.post("controller.pl", data, kivi.eval_json_result); |
91 | 97 |
}; |
... | ... | |
159 | 165 |
$('#row_table_id thead a img').remove(); |
160 | 166 |
|
161 | 167 |
var data = $('#assortment :input').serializeArray(); |
162 |
data.push({ name: 'action', value: 'Part/add_assortment_item' }, |
|
163 |
{ name: 'part.id', value: $('#part_id').val() }, |
|
164 |
{ name: 'part.part_type', value: 'assortment' }); |
|
168 |
data.push( |
|
169 |
{ name: 'action', value: 'Part/add_assortment_item' }, |
|
170 |
{ name: 'part.id', value: $('#part_id').val() }, |
|
171 |
{ name: 'part.part_type', value: 'assortment' } |
|
172 |
); |
|
165 | 173 |
$('#assortment_picker').data('part_picker').clear(); |
166 | 174 |
|
167 | 175 |
$.post("controller.pl", data, kivi.eval_json_result); |
... | ... | |
171 | 179 |
if ($('#assembly_picker').val() === '') return; |
172 | 180 |
|
173 | 181 |
var data = $('#assembly :input').serializeArray(); |
174 |
data.push({ name: 'action', value: 'Part/add_assembly_item' }, |
|
175 |
{ name: 'part.id', value: $("#part_id").val() }, |
|
176 |
{ name: 'part.part_type', value: 'assembly' }); |
|
182 |
data.push( |
|
183 |
{ name: 'action', value: 'Part/add_assembly_item' }, |
|
184 |
{ name: 'part.id', value: $("#part_id").val() }, |
|
185 |
{ name: 'part.part_type', value: 'assembly' } |
|
186 |
); |
|
177 | 187 |
$('#assembly_picker').data('part_picker').clear(); |
178 | 188 |
|
179 | 189 |
$.post("controller.pl", data, kivi.eval_json_result); |
... | ... | |
183 | 193 |
data.push({ name: 'part.id', value: $('#part_id').val() }); |
184 | 194 |
data.push({ name: 'part.part_type', value: $('#part_part_type').val() }); |
185 | 195 |
$.post("controller.pl?action=Part/add_multi_assembly_items", data, kivi.eval_json_result); |
186 |
} |
|
196 |
};
|
|
187 | 197 |
|
188 | 198 |
ns.set_multi_assortment_items = function(data) { |
189 | 199 |
data.push({ name: 'part.id', value: $('#part_id').val() }); |
190 | 200 |
data.push({ name: 'part.part_type', value: $('#part_part_type').val() }); |
191 | 201 |
$.post("controller.pl?action=Part/add_multi_assortment_items", data, kivi.eval_json_result); |
192 |
} |
|
202 |
};
|
|
193 | 203 |
|
194 | 204 |
ns.close_picker_dialogs = function() { |
195 | 205 |
$('.part_autocomplete').each(function(_, e) { |
196 | 206 |
var picker = $(e).data('part_picker'); |
197 | 207 |
if (picker && picker.dialog) picker.close_dialog(); |
198 | 208 |
}); |
199 |
} |
|
209 |
};
|
|
200 | 210 |
|
201 | 211 |
ns.redisplay_items = function(data) { |
202 | 212 |
var old_rows; |
... | ... | |
285 | 295 |
|
286 | 296 |
|
287 | 297 |
ns.reload_bin_selection = function() { |
288 |
$.post("controller.pl", { action: 'Part/warehouse_changed', warehouse_id: function(){ return $('#part_warehouse_id').val() } }, kivi.eval_json_result); |
|
289 |
} |
|
298 |
$.post("controller.pl", { action: 'Part/warehouse_changed', warehouse_id: function(){ return $('#part_warehouse_id').val(); } }, kivi.eval_json_result);
|
|
299 |
};
|
|
290 | 300 |
|
291 | 301 |
var KEY = { |
292 | 302 |
TAB: 9, |
... | ... | |
402 | 412 |
make_defined_state: function() { |
403 | 413 |
if (this.state == this.STATES.PICKED) { |
404 | 414 |
this.annotate_state(); |
405 |
return true |
|
406 |
} else if (this.state == this.STATES.UNDEFINED && this.$dummy.val() === '') |
|
407 |
this.set_item({}) |
|
408 |
else { |
|
409 |
this.set_item({ id: this.last_real, name: this.last_dummy }) |
|
415 |
return true;
|
|
416 |
} else if (this.state == this.STATES.UNDEFINED && this.$dummy.val() === '') {
|
|
417 |
this.set_item({});
|
|
418 |
} else {
|
|
419 |
this.set_item({ id: this.last_real, name: this.last_dummy });
|
|
410 | 420 |
} |
411 | 421 |
this.annotate_state(); |
412 | 422 |
}, |
... | ... | |
507 | 517 |
url: 'controller.pl?action=Part/ajax_autocomplete', |
508 | 518 |
dataType: "json", |
509 | 519 |
data: self.ajax_data(req.term), |
510 |
success: function (data){ rsp(data) } |
|
520 |
success: function (data){ rsp(data); }
|
|
511 | 521 |
})); |
512 | 522 |
}, |
513 | 523 |
select: function(event, ui) { |
... | ... | |
516 | 526 |
self.run_action(self.o.action.commit_one); |
517 | 527 |
} |
518 | 528 |
}, |
519 |
search: function(event, ui) {
|
|
529 |
search: function(event) { |
|
520 | 530 |
if ((event.which == KEY.SHIFT) || (event.which == KEY.CTRL) || (event.which == KEY.ALT)) |
521 | 531 |
event.preventDefault(); |
522 | 532 |
}, |
... | ... | |
527 | 537 |
self.autocomplete_open = false; |
528 | 538 |
} |
529 | 539 |
}); |
530 |
this.$dummy.keydown(function(event){ self.handle_keydown(event) }); |
|
540 |
this.$dummy.keydown(function(event){ self.handle_keydown(event); });
|
|
531 | 541 |
this.$dummy.on('paste', function(){ |
532 | 542 |
setTimeout(function() { |
533 | 543 |
self.handle_changed_text(); |
... | ... | |
535 | 545 |
}); |
536 | 546 |
this.$dummy.blur(function(){ |
537 | 547 |
window.clearTimeout(self.timer); |
538 |
self.timer = window.setTimeout(function() { self.annotate_state() }, 100); |
|
548 |
self.timer = window.setTimeout(function() { self.annotate_state(); }, 100);
|
|
539 | 549 |
}); |
540 | 550 |
|
541 | 551 |
var popup_button = $('<span>').addClass('ppp_popup_button'); |
542 | 552 |
this.$dummy.after(popup_button); |
543 |
popup_button.click(function() { self.open_dialog() }); |
|
553 |
popup_button.click(function() { self.open_dialog(); });
|
|
544 | 554 |
}, |
545 | 555 |
run_action: function(code, args) { |
546 | 556 |
if (typeof code === 'function') |
547 |
code.apply(this, args) |
|
557 |
code.apply(this, args);
|
|
548 | 558 |
else |
549 | 559 |
kivi.run(code, args); |
550 | 560 |
}, |
... | ... | |
584 | 594 |
}, |
585 | 595 |
init_search: function() { |
586 | 596 |
var self = this; |
587 |
$('#part_picker_filter').keypress(function(e) { self.result_timer(e) }).focus(); |
|
588 |
$('#no_paginate').change(function() { self.update_results() }); |
|
597 |
$('#part_picker_filter').keypress(function(e) { self.result_timer(e); }).focus();
|
|
598 |
$('#no_paginate').change(function() { self.update_results(); });
|
|
589 | 599 |
this.update_results(); |
590 | 600 |
}, |
591 | 601 |
update_results: function() { |
... | ... | |
596 | 606 |
no_paginate: $('#no_paginate').prop('checked') ? 1 : 0, |
597 | 607 |
}, self.pp.ajax_data(function(){ |
598 | 608 |
var val = $('#part_picker_filter').val(); |
599 |
return val === undefined ? '' : val |
|
609 |
return val === undefined ? '' : val;
|
|
600 | 610 |
})), |
601 | 611 |
success: function(data){ |
602 | 612 |
$('#part_picker_result').html(data); |
... | ... | |
623 | 633 |
}); |
624 | 634 |
}); |
625 | 635 |
$('#part_selection').keydown(function(e){ |
626 |
if (e.which == KEY.ESCAPE) {
|
|
627 |
self.close_dialog();
|
|
628 |
self.pp.$dummy.focus();
|
|
629 |
}
|
|
636 |
if (e.which == KEY.ESCAPE) { |
|
637 |
self.close_dialog(); |
|
638 |
self.pp.$dummy.focus(); |
|
639 |
} |
|
630 | 640 |
}); |
631 | 641 |
}, |
632 | 642 |
result_timer: function(event) { |
... | ... | |
645 | 655 |
if (event.which == KEY.ENTER) { |
646 | 656 |
self.update_results(); |
647 | 657 |
} else { |
648 |
this.timer = window.setTimeout(function() { self.update_results() }, 100); |
|
658 |
this.timer = window.setTimeout(function() { self.update_results(); }, 100);
|
|
649 | 659 |
} |
650 | 660 |
}, |
651 | 661 |
close_dialog: function() { |
... | ... | |
693 | 703 |
}); |
694 | 704 |
|
695 | 705 |
$('#multi_items_filter_all_substr_multi_ilike').focus(); |
696 |
$('#multi_items_filter_button').click(function(){ self.update_results() }); |
|
697 |
$('#multi_items_filter_reset').click(function(){ $("#multi_items_form").resetForm() }); |
|
698 |
$('#continue_button').click(function(){ self.add_multi_items() }); |
|
706 |
$('#multi_items_filter_button').click(function(){ self.update_results(); });
|
|
707 |
$('#multi_items_filter_reset').click(function(){ $("#multi_items_form").resetForm(); });
|
|
708 |
$('#continue_button').click(function(){ self.add_multi_items(); });
|
|
699 | 709 |
}, |
700 | 710 |
update_results: function() { |
701 | 711 |
var self = this; |
... | ... | |
704 | 714 |
data.push({ name: 'limit', value: self.pp.o.multiple_limit }); |
705 | 715 |
var ppdata = self.pp.ajax_data(function(){ |
706 | 716 |
var val = $('#multi_items_filter').val(); |
707 |
return val === undefined ? '' : val |
|
717 |
return val === undefined ? '' : val;
|
|
708 | 718 |
}); |
709 | 719 |
$.each(Object.keys(ppdata), function() {data.push({ name: 'multi_items.' + this, value: ppdata[this]});}); |
710 | 720 |
$.ajax({ |
... | ... | |
729 | 739 |
$('#multi_items_all_qty').change(function(event){ |
730 | 740 |
$('.multi_items_qty').val($(event.target).val()); |
731 | 741 |
}); |
732 |
$('.multi_items_qty').click(function(){ self.set_qty_to_one(this) }); |
|
742 |
$('.multi_items_qty').click(function(){ self.set_qty_to_one(this); });
|
|
733 | 743 |
}, |
734 |
result_timer: function(event) {
|
|
744 |
result_timer: function() { |
|
735 | 745 |
}, |
736 | 746 |
close_dialog: function() { |
737 | 747 |
$('#jq_multi_items_dialog').dialog('close'); |
... | ... | |
782 | 792 |
kivi.run_once_for('#makemodel_rows', 'makemodel_row_sort_renumber', function(elt) { |
783 | 793 |
$(elt).on('sortstop', kivi.Part.makemodel_renumber_positions); |
784 | 794 |
}); |
785 |
} |
|
795 |
};
|
|
786 | 796 |
|
787 | 797 |
ns.init = function() { |
788 | 798 |
ns.reinit_widgets(); |
789 |
} |
|
799 |
};
|
|
790 | 800 |
|
791 | 801 |
$(function(){ |
792 | 802 |
$('#ic').on('focusout', '.reformat_number', function(event) { |
793 |
ns.reformat_number(event);
|
|
803 |
ns.reformat_number(event); |
|
794 | 804 |
}); |
795 | 805 |
|
796 | 806 |
$('#part_warehouse_id').change(kivi.Part.reload_bin_selection); |
Auch abrufbar als: Unified diff
Part: eslint fixes