Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b0ac4850

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID b0ac485034697396a72f36f9bf48f0171b9b1692
  • Vorgänger 0eb8e223
  • Nachfolger 85c4af4a

Pflichtenheftitems: Abschnitte anlegen

Unterschiede anzeigen:

SL/Controller/RequirementSpecItem.pm
92 92
    $js->hide('#section-list-empty');
93 93

  
94 94
    my $id_prefix = $new_type eq 'sub-function-block' ? 'sub-' : '';
95
    my $template  = apply { s/-/_/g; $_ } $new_type;
96
    my $html      = "" . $self->render('requirement_spec_item/_' . $template, { output => 0 }, requirement_spec_item => $self->item);
95
    my $template  = 'requirement_spec_item/_' . (apply { s/-/_/g; $_ } $new_type);
96
    my $html      = "" . $self->render($template, { output => 0 }, requirement_spec_item => $self->item);
97 97
    my $next_item = $self->item->get_next_in_list;
98 98

  
99 99
    if ($next_item) {
......
112 112
  $self->render($js);
113 113
}
114 114

  
115
sub action_ajax_add {
115
sub action_ajax_add_section {
116 116
  my ($self, %params) = @_;
117 117

  
118
  die "TODO: add action";
118
  die "Missing parameter 'requirement_spec_id'" if !$::form->{requirement_spec_id};
119

  
120
  $self->item(SL::DB::RequirementSpecItem->new(requirement_spec_id => $::form->{requirement_spec_id}));
121

  
122
  my $insert_after = $::form->{id} ? SL::DB::RequirementSpecItem->new(id => $::form->{id})->load->get_section->id : undef;
123
  my $html         = $self->render('requirement_spec_item/_section_form', { output => 0 }, id_base => 'new_section', insert_after => $insert_after);
124

  
125
  SL::ClientJS->new
126
    ->remove('#new_section_form')
127
    ->hide('#column-content > *')
128
    ->appendTo($html, '#column-content')
129
    ->focus('#new_section_title')
130
    ->render($self);
131
}
132

  
133
sub action_ajax_create {
134
  my ($self, %params) = @_;
135

  
136
  my $js              = SL::ClientJS->new;
137
  my $prefix          = $::form->{form_prefix} || die "Missing parameter 'form_prefix'";
138
  my $attributes      = $::form->{$prefix}     || die "Missing parameter group '${prefix}'";
139
  my $insert_after    = delete $attributes->{insert_after};
140

  
141
  my @errors = $self->item(SL::DB::RequirementSpecItem->new(%{ $attributes }))->validate;
142
  return $js->error(@errors)->render($self) if @errors;
143

  
144
  $self->item->save;
145
  $self->item->add_to_list(position => 'after', reference => $insert_after) if $insert_after;
146

  
147
  my $type = $self->item->get_type;
148

  
149
  if ($type eq 'section') {
150
    my $node = $self->presenter->requirement_spec_item_jstree_data($self->item);
151
    return $self->render_list($js, $self->item)
152
      ->jstree->create_node('#tree', $insert_after ? ('#fb-' . $insert_after, 'after') : ('#sections', 'last'), $node)
153
      ->jstree->select_node('#tree', '#fb-' . $self->item->id)
154
      ->render($self);
155
  }
156

  
157
  die 'TODO: create item';
119 158
}
120 159

  
121 160
sub action_ajax_edit {
......
178 217
  my ($self, %params) = @_;
179 218

  
180 219
  my $js         = SL::ClientJS->new;
181
  my $prefix     = $::form->{form_prefix} || 'function_block';
220
  my $prefix     = $::form->{form_prefix} || die "Missing parameter 'form_prefix'";
182 221
  my $attributes = $::form->{$prefix}     || {};
183 222

  
184 223
  foreach (qw(requirement_spec_id parent_id position)) {
locale/de/all
892 892
  'Edit requirement spec status' => 'Pflichtenheftstatus bearbeiten',
893 893
  'Edit requirement spec type'  => 'Pflichtenhefttypen bearbeiten',
894 894
  'Edit risk level'             => 'Risikograd bearbeiten',
895
  'Edit section #1'             => 'Abschnitt #1 bearbeiten',
895 896
  'Edit templates'              => 'Vorlagen bearbeiten',
896 897
  'Edit text block'             => 'Textblock bearbeiten',
897 898
  'Edit text block \'#1\''      => 'Textblock \'#1\' bearbeiten',
templates/webpages/requirement_spec/show.html
125 125
    selector: '.section-context-menu',
126 126
    items: {
127 127
      add_section:        { name: "[% LxERP.t8('Add section') %]",        icon: "add",    callback: standard_item_ajax_call },
128
      add_function_block: { name: "[% LxERP.t8('Add function block') %]", icon: "add",    callback: standard_text_block_ajax_call, disabled: disable_edit_item_commands },
128
      add_function_block: { name: "[% LxERP.t8('Add function block') %]", icon: "add",    callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
129 129
      sep1:               "---------",
130 130
      edit:               { name: "[% LxERP.t8('Edit') %]",               icon: "edit",   callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
131 131
      delete:             { name: "[% LxERP.t8('Delete') %]",             icon: "delete", callback: ask_delete_item,         disabled: disable_edit_item_commands },
......
138 138
  $.contextMenu({
139 139
    selector: '.function-block-context-menu,.sub-function-block-context-menu',
140 140
    items: {
141
      new_item:     { name: "[% LxERP.t8('Add function block') %]",     icon: "add", callback: standard_item_ajax_call },
142
      new_sub_item: { name: "[% LxERP.t8('Add sub function block') %]", icon: "add", callback: standard_item_ajax_call },
143
      sep1:         "---------",
144
      edit:         { name: "[% LxERP.t8('Edit') %]",   icon: "edit",   callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
145
      delete:       { name: "[% LxERP.t8('Delete') %]", icon: "delete", callback: ask_delete_item,         disabled: disable_edit_item_commands },
146
      sep2:         "---------",
147
      copy:         { name: "[% LxERP.t8('Copy') %]",  icon: "copy",  disabled: disable_edit_item_commands },
148
      paste:        { name: "[% LxERP.t8('Paste') %]", icon: "paste", disabled: disable_edit_item_commands }
141
      add_function_block:     { name: "[% LxERP.t8('Add function block') %]",     icon: "add", callback: standard_item_ajax_call },
142
      add_sub_function_block: { name: "[% LxERP.t8('Add sub function block') %]", icon: "add", callback: standard_item_ajax_call },
143
      sep1:                   "---------",
144
      edit:                   { name: "[% LxERP.t8('Edit') %]",   icon: "edit",   callback: standard_item_ajax_call, disabled: disable_edit_item_commands },
145
      delete:                 { name: "[% LxERP.t8('Delete') %]", icon: "delete", callback: ask_delete_item,         disabled: disable_edit_item_commands },
146
      sep2:                   "---------",
147
      copy:                   { name: "[% LxERP.t8('Copy') %]",  icon: "copy",  disabled: disable_edit_item_commands },
148
      paste:                  { name: "[% LxERP.t8('Paste') %]", icon: "paste", disabled: disable_edit_item_commands }
149 149
    }
150 150
  });
151 151
});
templates/webpages/requirement_spec_item/_section_form.html
2 2
[%- DEFAULT id_base="edit_section" %]
3 3
[%- SET style="width: 500px" %]
4 4
<form id="[% id_base %]_form">
5
 <h1>[%- LxERP.t8("Edit section #1", SELF.item.fb_number) %]</h1>
5
 [%- IF SELF.item.id %]
6
  [%- SET hidden = '#section-header-' _ SELF.item.id %]
7
  <h1>[%- LxERP.t8("Edit section #1", SELF.item.fb_number) %]</h1>
8

  
9
 [%- ELSE %]
10
  [%- SET hidden = '#column-content > *' %]
11
  <h1>[%- LxERP.t8("Add section") %]</h1>
12

  
13
 [%- END %]
6 14

  
7 15
 [% L.hidden_tag(id_base _ '_id',                  SELF.item.id) %]
8 16
 [% L.hidden_tag(id_base _ '.requirement_spec_id', SELF.item.requirement_spec_id) %]
......
22 30

  
23 31
 <p>
24 32
  [% L.button_tag('submit_edit_item_form("' _ id_base _ '")', LxERP.t8('Save')) %]
25
  <a href="#" onclick="cancel_edit_item_form('[% id_base %]', '[% '#section-header-' _ SELF.item.id %]')">[%- LxERP.t8("Cancel") %]</a>
33
  <a href="#" onclick="cancel_edit_item_form('[% id_base %]', '[% hidden %]')">[%- LxERP.t8("Cancel") %]</a>
26 34
 </p>
27 35
</form>

Auch abrufbar als: Unified diff