Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 59103201

Von Bernd Bleßmann vor mehr als 4 Jahren hinzugefügt

  • ID 59103201cf9d7131024c1c3d5bbb136addb79a3f
  • Vorgänger 9fb93e8c
  • Nachfolger ffb7da30

Auftrags-Controller: Einfüge-Position eines neuen Artiklens angeben können

Unterschiede anzeigen:

js/kivi.Order.js
339 339
    $('.row_entry [name="position"]').each(function(idx, elt) {
340 340
      $(elt).html(idx+1);
341 341
    });
342
    $('.row_entry').each(function(idx, elt) {
343
      $(elt).data("position", idx+1);
344
    });
342 345
  };
343 346

  
344 347
  ns.reorder_items = function(order_by) {
......
374 377
    ns.renumber_positions();
375 378
  };
376 379

  
380
  ns.get_insert_before_item_id = function(wanted_pos) {
381
    if (wanted_pos === '') return;
382

  
383
    var insert_before_item_id;
384
    // selection by data does not seem to work if data is changed at runtime
385
    // var elt = $('.row_entry [data-position="' + wanted_pos + '"]');
386
    $('.row_entry').each(function(idx, elt) {
387
      if ($(elt).data("position") == wanted_pos) {
388
        insert_before_item_id = $(elt).find('[name="orderitem_ids[+]"]').val();
389
        return false;
390
      }
391
    });
392

  
393
    return insert_before_item_id;
394
  };
395

  
377 396
  ns.add_item = function() {
378 397
    if ($('#add_item_parts_id').val() === '') return;
379 398
    if (!ns.check_cv()) return;
380 399

  
381 400
    $('#row_table_id thead a img').remove();
382 401

  
402
    var insert_before_item_id = ns.get_insert_before_item_id($('#add_item_position').val());
403

  
383 404
    var data = $('#order_form').serializeArray();
384
    data.push({ name: 'action', value: 'Order/add_item' });
405
    data.push({ name: 'action', value: 'Order/add_item' },
406
              { name: 'insert_before_item_id', value: insert_before_item_id });
385 407

  
386 408
    $.post("controller.pl", data, kivi.eval_json_result);
387 409
  };
......
439 461
  ns.multi_items_dialog_disable_continue = function() {
440 462
    // disable keydown-event and continue button to prevent
441 463
    // impatient users to add parts multiple times
442
    $('#multi_items_result input').off("keydown");
464
    $('#multi_items_result input, #multi_items_position').off("keydown");
443 465
    $('#multi_items_dialog_continue_button').prop('disabled', true);
444 466
  };
445 467

  
446 468
  ns.multi_items_dialog_enable_continue = function()  {
447
    $('#multi_items_result input').keydown(function(event) {
469
    $('#multi_items_result input, #multi_items_position').keydown(function(event) {
448 470
      if(event.keyCode == 13) {
449 471
        event.preventDefault();
450 472
        ns.add_multi_items();
......
475 497

  
476 498
    ns.multi_items_dialog_disable_continue();
477 499

  
500
    var insert_before_item_id = ns.get_insert_before_item_id($('#multi_items_position').val());
501

  
478 502
    var data = $('#order_form').serializeArray();
479 503
    data = data.concat($('#multi_items_form').serializeArray());
480
    data.push({ name: 'action', value: 'Order/add_multi_items' });
504
    data.push({ name: 'action', value: 'Order/add_multi_items' },
505
              { name: 'insert_before_item_id', value: insert_before_item_id });
481 506
    $.post("controller.pl", data, kivi.eval_json_result);
482 507
  };
483 508

  

Auch abrufbar als: Unified diff