Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e86e30de

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID e86e30de944c4bbe4b42f43d933e0a28a83408dd
  • Vorgänger e2a8a58a
  • Nachfolger 0eb8e223

Pflichtenheftitems und Abschnitte bearbeiten

Unterschiede anzeigen:

SL/Controller/RequirementSpecItem.pm
112 112
  $self->render($js);
113 113
}
114 114

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

  
118
  die "TODO: add action";
119
}
120

  
115 121
sub action_ajax_edit {
116 122
  my ($self, %params) = @_;
117 123

  
......
119 125

  
120 126
  my $js = SL::ClientJS->new;
121 127

  
122
  die "TODO: edit section" if $self->item->get_type =~ m/section/;
123

  
124 128
  if (!$self->visible_section || ($self->visible_section->id != $self->item->get_section->id)) {
129
    # Show section/item to edit if it is not visible.
130

  
125 131
    my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $self->item);
126 132
    $js->html('#column-content', $html);
127 133
  }
128 134

  
129
  if ($self->item->get_type =~ m/function-block/) {
130
    my $create_item = sub {
131
      [ $_[0]->id, $self->presenter->truncate(join(' ', grep { $_ } ($_[1], $_[0]->fb_number, $_[0]->description))) ]
132
    };
133
    my @dependencies =
134
      map { [ $_->fb_number . ' ' . $_->title,
135
              [ map { ( $create_item->($_),
136
                        map { $create_item->($_, '->') } @{ $_->sorted_children })
137
                    } @{ $_->sorted_children } ] ]
138
          } @{ $self->item->requirement_spec->sections };
139

  
140
    my @selected_dependencies = map { $_->id } @{ $self->item->dependencies };
141

  
142
    my $html                  = $self->render('requirement_spec_item/_function_block_form', { output => 0 }, DEPENDENCIES => \@dependencies, SELECTED_DEPENDENCIES => \@selected_dependencies);
143
    my $id_base               = $self->item->get_type . '-' . $self->item->id;
144
    my $content_top_id        = '#' . $self->item->get_type . '-content-top-' . $self->item->id;
145

  
146
    $js->hide($content_top_id)
147
       ->remove("#edit_${id_base}_form")
148
       ->insertAfter($html, $content_top_id)
135
  if ($self->item->get_type =~ m/section/) {
136
    # Edit the section header, not an item.
137
    my $html = $self->render('requirement_spec_item/_section_form', { output => 0 });
138

  
139
    $js->hide('#section-header-' . $self->item->id)
140
       ->remove("#edit_section_form")
141
       ->insertAfter($html, '#section-header-' . $self->item->id)
149 142
       ->jstree->select_node('#tree', '#fb-' . $self->item->id)
150
       ->focus("#edit_${id_base}_description")
151
       ->val('#current_content_type', $self->item->get_type)
152
       ->val('#current_content_id', $self->item->id)
143
       ->focus("#edit_section_title")
144
       ->val('#current_content_type', 'section')
145
       ->val('#current_content_id',   $self->item->id)
153 146
       ->render($self);
147
    return;
154 148
  }
149

  
150
  # Edit a function block or a sub function block
151
  my $create_item = sub {
152
    [ $_[0]->id, $self->presenter->truncate(join(' ', grep { $_ } ($_[1], $_[0]->fb_number, $_[0]->description))) ]
153
  };
154
  my @dependencies =
155
    map { [ $_->fb_number . ' ' . $_->title,
156
            [ map { ( $create_item->($_),
157
                      map { $create_item->($_, '->') } @{ $_->sorted_children })
158
                  } @{ $_->sorted_children } ] ]
159
        } @{ $self->item->requirement_spec->sections };
160

  
161
  my @selected_dependencies = map { $_->id } @{ $self->item->dependencies };
162

  
163
  my $html                  = $self->render('requirement_spec_item/_function_block_form', { output => 0 }, DEPENDENCIES => \@dependencies, SELECTED_DEPENDENCIES => \@selected_dependencies);
164
  my $id_base               = 'edit_function_block_' . $self->item->id;
165
  my $content_top_id        = '#' . $self->item->get_type . '-content-top-' . $self->item->id;
166

  
167
  $js->hide($content_top_id)
168
     ->remove("#${id_base}_form")
169
     ->insertAfter($html, $content_top_id)
170
     ->jstree->select_node('#tree', '#fb-' . $self->item->id)
171
     ->focus("#${id_base}_description")
172
     ->val('#current_content_type', $self->item->get_type)
173
     ->val('#current_content_id', $self->item->id)
174
     ->render($self);
155 175
}
156 176

  
157 177
sub action_ajax_update {
......
170 190

  
171 191
  $self->item->save;
172 192

  
173
  my $id_prefix    = $self->item->get_type eq 'function-block' ? '' : 'sub-';
193
  my $type = $self->item->get_type;
194

  
195
  if ($type eq 'section') {
196
    # Updated section, now update section header.
197

  
198
    my $html = $self->render('requirement_spec_item/_section_header', { output => 0 }, requirement_spec_item => $self->item);
199

  
200
    return SL::ClientJS->new
201
      ->remove('#edit_section_form')
202
      ->html('#section-header-' . $self->item->id, $html)
203
      ->show('#section-header-' . $self->item->id)
204
      ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item))
205
      ->render($self);
206
  }
207

  
208
  # Updated function block or sub function block. Update (sub)
209
  # function block and potentially the bottom of the parent function
210
  # block.
211

  
212
  my $id_prefix    = $type eq 'function-block' ? '' : 'sub-';
174 213
  my $html_top     = $self->render('requirement_spec_item/_function_block_content_top',    { output => 0 }, requirement_spec_item => $self->item, id_prefix => $id_prefix);
175 214
  $id_prefix      .= 'function-block-content-';
176 215

  
......
180 219
    ->jstree->rename_node('#tree', '#fb-' . $self->item->id, $::request->presenter->requirement_spec_item_tree_node_title($self->item));
181 220

  
182 221
  $self->replace_bottom($js, $self->item, id_prefix => $id_prefix);
183
  $self->replace_bottom($js, $self->item->parent) if $self->item->get_type eq 'sub-function-block';
222
  $self->replace_bottom($js, $self->item->parent) if $type eq 'sub-function-block';
184 223

  
185 224
  $js->render($self);
186 225
}
js/requirement_spec.js
221 221
  return true;
222 222
}
223 223

  
224
function cancel_edit_item_form(form_id_base, hidden_id_base) {
225
  var id = $('#' + form_id_base + '_id').val();
224
function cancel_edit_item_form(form_id_base, to_show) {
226 225
  $('#' + form_id_base + '_form').remove();
227
  if (id)
228
    $('#' + hidden_id_base + '-' + id).show();
226
  if (to_show)
227
    $(to_show).show();
229 228
}
templates/webpages/requirement_spec/show.html
150 150
  });
151 151
});
152 152

  
153
function edit_section_header() {
154
  $.post("controller.pl?action=RequirementSpecItem/edit_section&id=" + encodeURIComponent($('#active_section_id').val()), function(data) {
155
    var header = $('#section-header');
156
    header.data('old-elements', header.children().detach());
157
    header.html(data);
158
  });
159
}
160

  
161
function submit_section_form() {
162
  $.post("controller.pl?action=RequirementSpecItem/update_section&id=" + $('#section-form form').serialize(), function(data) {
163
    var header = $('#section-header');
164
    header.removeData('old-elements');
165
    header.html(data['header_html']);
166
    $('#tree').jstree('rename_node', '#fb-' + data['id'], data['node_name']);
167
  });
168
}
169

  
170
function cancel_section_form() {
171
  var header = $('#section-header');
172
  header.empty();
173
  header.append(header.data('old-elements'));
174
  header.removeData('old-elements');
175
}
176

  
177

  
178

  
179

  
180

  
181

  
182 153
  -->
183 154
</script>
templates/webpages/requirement_spec_item/_function_block_form.html
29 29

  
30 30
  <div style="width: 59%">
31 31
   [% LxERP.t8("Description of #1", SELF.item.fb_number) %]:<br>
32
   [% L.textarea_tag(id_base _ '.description', SELF.item.description, id=id_base _ '_description', rows=8, style="width: 100%") %]
32
   [% L.textarea_tag(id_base _ '.description', SELF.item.description, rows=8, style="width: 100%") %]
33 33
  </div>
34 34
 </div>
35 35

  
36 36
 <p>
37 37
  [% L.button_tag('submit_edit_item_form("' _ id_base _ '")', LxERP.t8('Save')) %]
38
  <a href="#" onclick="cancel_edit_item_form('[% id_base %]', '[% SELF.item.get_type %]-content-top')">[%- LxERP.t8("Cancel") %]</a>
38
  <a href="#" onclick="cancel_edit_item_form('[% id_base %]', '[% '#' _ SELF.item.get_type _ '-content-top-' _ SELF.item.id %]')">[%- LxERP.t8("Cancel") %]</a>
39 39
 </p>
40 40
</form>
templates/webpages/requirement_spec_item/_section_form.html
1 1
[%- USE HTML %][%- USE L %][%- USE LxERP %]
2
[%- SET id_base="section-form" %]
3
<div id="[% id_base %]">
2
[%- DEFAULT id_base="edit_section" %]
3
[%- SET style="width: 500px" %]
4
<form id="[% id_base %]_form">
4 5
 <h1>[%- LxERP.t8("Edit section #1", SELF.item.fb_number) %]</h1>
5 6

  
6
 <form>
7
  [% L.hidden_tag("requirement_spec_id", SELF.item.requirement_spec_id, id=(id_base _ "-requirement-spec-id")) %]
8
  [% L.hidden_tag("id", SELF.item.id, id=(id_base _ "-requirement-spec-item-id")) %]
7
 [% L.hidden_tag(id_base _ '_id',                  SELF.item.id) %]
8
 [% L.hidden_tag(id_base _ '.requirement_spec_id', SELF.item.requirement_spec_id) %]
9
 [% IF insert_after %]
10
  [% L.hidden_tag(id_base _ '.insert_after',       insert_after) %]
11
 [% END %]
9 12

  
10
  <p>
11
   [%- LxERP.t8("Title") %]:<br>
12
   [% L.input_tag("title", SELF.item.title, id=(id_base _ "-title")) %]
13
  </p>
13
 <p>
14
  [%- LxERP.t8("Title") %]:<br>
15
  [% L.input_tag(id_base _ '.title', SELF.item.title, style=style) %]
16
 </p>
14 17

  
15
  <p>
16
   [%- LxERP.t8("Description") %]:<br>
17
   [% L.textarea_tag("description", SELF.item.description, id=(id_base _ "-description"), rows=8, cols=80) %]
18
  </p>
18
 <p>
19
  [%- LxERP.t8("Description") %]:<br>
20
  [% L.textarea_tag(id_base _ '.description', SELF.item.description, rows=8, cols=80, style=style) %]
21
 </p>
19 22

  
20
  <p>
21
   [% L.button_tag("submit_section_form()", LxERP.t8("Save")) %]
22
   <a href="#" onclick="cancel_section_form()">[% LxERP.t8("Cancel") %]</a>
23
  </p>
24
 </form>
25
</div>
23
 <p>
24
  [% 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>
26
 </p>
27
</form>
templates/webpages/requirement_spec_item/_section_header.html
10 10
 [% END %]
11 11
</h1>
12 12

  
13
<div class="section-description">
13
<div class="section-description" id="section-description">
14 14
 <div class="section-description-heading">[%- LxERP.t8("Preamble") %]</div>
15 15
 [% IF requirement_spec_item.description %]
16 16
  [%- L.simple_format(requirement_spec_item.description) -%]

Auch abrufbar als: Unified diff