Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1bacd5c1

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID 1bacd5c15dbf06c84167d823544015d59fdc23be
  • Vorgänger 32f83e8e
  • Nachfolger 938703cc

Pflichtenhefte: Zuweisung Artikel zu Abschnitten implementiert

Unterschiede anzeigen:

SL/Controller/RequirementSpecOrder.pm
6 6
use parent qw(SL::Controller::Base);
7 7

  
8 8
use SL::ClientJS;
9
use SL::DB::Part;
9 10
use SL::DB::RequirementSpec;
10 11
use SL::DB::RequirementSpecOrder;
11 12
use SL::Helper::Flash;
......
13 14

  
14 15
use Rose::Object::MakeMethods::Generic
15 16
(
16
  'scalar --get_set_init' => [ qw(requirement_spec js) ],
17
  'scalar --get_set_init' => [ qw(requirement_spec js all_parts) ],
17 18
);
18 19

  
19 20
__PACKAGE__->run_before('setup');
......
26 27
sub action_list {
27 28
  my ($self) = @_;
28 29

  
29
  $::lxdebug->dump(0, "hmm", $self->requirement_spec->sections_sorted);
30 30
  $self->render('requirement_spec_order/list', { layout => 0 });
31 31
}
32 32

  
33
sub action_edit_assignment {
34
  my ($self) = @_;
35

  
36
  my $html   = $self->render('requirement_spec_order/edit_assignment', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description });
37
  $self->js->html('#ui-tabs-4', $html)
38
           ->render($self);
39
}
40

  
41
sub action_save_assignment {
42
  my ($self)   = @_;
43
  my $sections = $::form->{sections} || [];
44
  SL::DB::RequirementSpecItem->new(id => $_->{id})->load->update_attributes(order_part_id => ($_->{order_part_id} || undef)) for @{ $sections };
45

  
46
  my $html = $self->render('requirement_spec_order/list', { output => 0 });
47
  $self->js->html('#ui-tabs-4', $html)
48
           ->render($self);
49
}
50

  
51
sub action_cancel {
52
  my ($self) = @_;
53

  
54
  my $html = $self->render('requirement_spec_order/list', { output => 0 });
55
  $self->js->html('#ui-tabs-4', $html)
56
           ->render($self);
57
}
58

  
33 59
#
34 60
# filters
35 61
#
......
58 84
# helpers
59 85
#
60 86

  
87
sub init_all_parts { SL::DB::Manager::Part->get_all_sorted }
88

  
61 89
1;
SL/DB/RequirementSpecItem.pm
41 41
__PACKAGE__->attr_duration(qw(time_estimation));
42 42

  
43 43
__PACKAGE__->before_save(\&_before_save_create_fb_number);
44
__PACKAGE__->before_save(\  &_before_save_invalidate_requirement_spec_version);
44
__PACKAGE__->before_save(\&_before_save_invalidate_requirement_spec_version);
45 45
__PACKAGE__->before_delete(\&_before_delete_invalidate_requirement_spec_version);
46 46

  
47 47
sub _before_save_create_fb_number {
js/requirement_spec.js
325 325
  return $(clicked_elt).find('>[name=order_id]').val();
326 326
};
327 327

  
328
ns.standard_quotation_order_ajax_call = function(key, opt, other_data) {
329
  var data = {
330
    action:              "RequirementSpecOrder/" + key,
331
    requirement_spec_id: $('#requirement_spec_id').val(),
332
    id:                  ns.find_quotation_order_id(opt.$trigger)
333
  };
328
ns.standard_quotation_order_ajax_call = function(key, opt) {
329
  if ((key == 'cancel') && !confirm(kivi.t8('Do you really want to cancel?')))
330
    return true;
331

  
332
  var data = 'action=RequirementSpecOrder/' + key
333
           + '&' + $('#requirement_spec_id').serialize();
334

  
335
  if (key == 'save_assignment')
336
    data += '&' + $('#quotations_and_orders_article_assignment_form').serialize();
337
  else
338
    data += '&id=' + encodeURIComponent(ns.find_quotation_order_id(opt.$trigger));
334 339

  
335 340
  // console.log("I would normally POST the following now:");
336 341
  // console.log(data);
337
  $.post("controller.pl", $.extend(data, other_data || {}), kivi.eval_json_result);
342
  $.post("controller.pl", data, kivi.eval_json_result);
338 343

  
339 344
  return true;
340 345
};
......
347 352
  return !$('#quotations_and_orders_sections');
348 353
};
349 354

  
355
ns.assign_order_part_id_to_all = function() {
356
  var order_part_id = $('#quoations_and_orders_order_id').val();
357
  $('#quotations_and_orders_article_assignment_form SELECT[name="sections[].order_part_id"]').each(function(idx, elt) {
358
    $(elt).val(order_part_id);
359
  });
360
};
361

  
350 362
// -------------------------------------------------------------------------
351 363
// ---------------------------- general actions ----------------------------
352 364
// -------------------------------------------------------------------------
......
507 519
  $.contextMenu({
508 520
    selector: '.quotations-and-orders-context-menu,.quotations-and-orders-order-context-menu',
509 521
    items:    $.extend({
510
        heading:            { name: kivi.t8('Orders/Quotations actions'), className: 'context-menu-heading' }
511
      , edit:               { name: kivi.t8('Edit article/section assignments'), icon: "edit",   callback: ns.standard_quotation_order_ajax_call }
522
        heading:            { name: kivi.t8('Orders/Quotations actions'), className: 'context-menu-heading'                                                                                            }
523
      , edit_assignment:    { name: kivi.t8('Edit article/section assignments'), icon: "edit",   callback: ns.standard_quotation_order_ajax_call                                                       }
512 524
      , sep1:               "---------"
513
      , new:                { name: kivi.t8('Create new qutoation/order'),       icon: "add",    callback: ns.standard_quotation_order_ajax_call, disabled: ns.disable_create_quotation_order_commands}
514
      , update:             { name: kivi.t8('Update quotation/order'),           icon: "update", callback: ns.standard_quotation_order_ajax_call, disabled: ns.disable_edit_quotation_order_commands }
525
      , new:                { name: kivi.t8('Create new qutoation/order'),       icon: "add",    callback: ns.standard_quotation_order_ajax_call, disabled: ns.disable_create_quotation_order_commands }
526
      , update:             { name: kivi.t8('Update quotation/order'),           icon: "update", callback: ns.standard_quotation_order_ajax_call, disabled: ns.disable_edit_quotation_order_commands   }
515 527
      , sep2:               "---------"
516
      , delete:             { name: kivi.t8('Delete quotation/order'),           icon: "delete", callback: ns.ask_delete_quotation_order,         disabled: ns.disable_edit_quotation_order_commands }
528
      , delete:             { name: kivi.t8('Delete quotation/order'),           icon: "delete", callback: ns.ask_delete_quotation_order,         disabled: ns.disable_edit_quotation_order_commands   }
529
    }, general_actions)
530
  });
531

  
532
  $.contextMenu({
533
    selector: '.quotations-and-orders-edit-assignment-context-menu',
534
    items:    $.extend({
535
        heading:         { name: kivi.t8('Edit article/section assignments'), className: 'context-menu-heading'    }
536
      , save_assignment: { name: kivi.t8('Save'),   icon: "edit",  callback: ns.standard_quotation_order_ajax_call }
537
      , cancel:          { name: kivi.t8('Cancel'), icon: "close", callback: ns.standard_quotation_order_ajax_call }
517 538
    }, general_actions)
518 539
  });
519 540

  
templates/webpages/requirement_spec_order/_assignment_form.html
1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE P -%]
2
<div>
3
 [% LxERP.t8("Assign the following article to all sections") %]:
4
 [% L.select_tag('quotations_and_orders_dummy', SELF.all_parts, default=INSTANCE_CONF.get_requirement_spec_section_order_part_id, title_sub=\make_part_title, id='quoations_and_orders_order_id') %]
5
 [% L.button_tag('kivi.requirement_spec.assign_order_part_id_to_all()', LxERP.t8('Assign article')) %]
6
</div>
7

  
8
<form id="quotations_and_orders_article_assignment_form">
9
 <table style="width: 100%">
10
  <thead>
11
   <tr class="listheading">
12
    <th>[% LxERP.t8("Number") %]</th>
13
    <th>[% LxERP.t8("Title") %]</th>
14
    <th>[% LxERP.t8("Description") %]</th>
15
    <th>[% LxERP.t8("Article") %]</th>
16
   </tr>
17
  </thead>
18

  
19
  <tbody>
20
   [% FOREACH section = SELF.requirement_spec.sections_sorted %]
21
   <tr class="listrow">
22
    [% L.hidden_tag("sections[+].id", section.id, no_id=1) %]
23
    <td>[% HTML.escape(section.fb_number) %]</td>
24
    <td>[% HTML.escape(section.title) %]</td>
25
    <td>[% HTML.escape(P.truncate(section.description)) %]</td>
26
    <td>[% L.select_tag('sections[].order_part_id', SELF.all_parts, default=section.order_part_id, with_empty=1, title_sub=\make_part_title, no_id=1) %]</td>
27
   </tr>
28
   [% END %]
29
  </tbody>
30
 </table>
31
</form>
templates/webpages/requirement_spec_order/edit_assignment.html
1
[%- USE LxERP -%][%- USE L -%]
2
<div id="quotations_and_orders_article_assignment" class="quotations-and-orders-edit-assignment-context-menu">
3
 <h2>[% LxERP.t8("Edit assignment of articles to sections") %]</h2>
4

  
5
 [% INCLUDE 'requirement_spec_order/_assignment_form.html' %]
6
</div>
templates/webpages/requirement_spec_order/list.html
1 1
[%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE P -%]
2 2
<div id="quotations_and_orders" class="quotations-and-orders-context-menu">
3 3
 <h2>[% LxERP.t8("Assignment of articles to sections") %]</h2>
4

  
4 5
 [% SET sections = SELF.requirement_spec.sections_sorted %]
5 6
 [% IF !sections.size %]
6 7
 <div>

Auch abrufbar als: Unified diff