Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f3cfe3bd

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID f3cfe3bd1d0be609d699ce8c2d31a9b1e94272de
  • Vorgänger 602e604a
  • Nachfolger bb52114e

Löschen von Textblöcken

Unterschiede anzeigen:

SL/Controller/RequirementSpecTextBlock.pm
17 17
 scalar => [ qw(requirement_spec text_block) ],
18 18
);
19 19

  
20
__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit update dragged_and_dropped)]);
20
__PACKAGE__->run_before('load_requirement_spec_text_block', only => [qw(ajax_edit ajax_update ajax_delete dragged_and_dropped)]);
21 21

  
22 22
#
23 23
# actions
......
70 70
  my $html             = $self->render('requirement_spec_text_block/_form', { output => 0 }, PREDEFINED_TEXTS => $predefined_texts);
71 71

  
72 72
  $js->hide('#text-block-' . $self->text_block->id)
73
     ->remove('#edit_text_block_' . $self->text_block->id . '_form')
73 74
     ->insertAfter($html, '#text-block-' . $self->text_block->id)
74 75
     ->jstree->select_node('#tree', '#tb-' . $self->text_block->id)
75 76
     ->render($self);
76 77
}
77 78

  
78
sub action_update {
79
sub action_ajax_update {
79 80
  my ($self, %params) = @_;
80 81

  
81 82
  my $prefix     = $::form->{form_prefix} || 'text_block';
......
96 97
    ->render($self);
97 98
}
98 99

  
100
sub action_ajax_delete {
101
  my ($self) = @_;
102

  
103
  my $js = SL::ClientJS->new;
104

  
105
  my $current_where = $self->output_position_from_id($::form->{current_content_id}, $::form->{current_content_type}) // -1;
106
  if ($self->text_block->output_position == $current_where) {
107
    $js->remove('#edit_text_block_' . $self->text_block->id . '_form')
108
       ->remove('#text-block-' . $self->text_block->id);
109

  
110
    $js->show('#text-block-list-empty') if 1 == scalar @{ $self->text_block->get_full_list };
111
  }
112

  
113
  $self->text_block->delete;
114

  
115
  $js->jstree->delete_node('#tree', '#tb-' . $self->text_block->id)
116
     ->render($self);
117
}
99 118

  
100 119
sub action_dragged_and_dropped {
101 120
  my ($self)       = @_;
......
154 173
    }
155 174
  }
156 175

  
157
  $::lxdebug->message(0, "old $old_where current $current_where new $new_where");
158

  
159
  $::lxdebug->dump(0, "actions", $js);
160

  
161 176
  $self->render($js);
162 177
}
163 178

  
js/requirement_spec.js
205 205
function submit_edit_text_block_form(id_base) {
206 206
  var url  = "controller.pl?" + $('#' + id_base + '_form').serialize();
207 207
  var data = {
208
    action:      'RequirementSpecTextBlock/update.js',
208
    action:      'RequirementSpecTextBlock/ajax_update',
209 209
    id:          $('#' + id_base + '_id').val(),
210 210
    form_prefix: id_base
211 211
  };
templates/webpages/requirement_spec/show.html
28 28
  [% L.hidden_tag('current_content_id',   SELF.requirement_spec_item.id) %]
29 29

  
30 30
  <div id="column-content">
31
   [%- IF SELF.requirement_spec_item && SELF.requirement_spec_item.id -%]
31
   [%- IF SELF.requirement_spec_item -%]
32 32
    [%- INCLUDE 'requirement_spec_item/_single_section.html' requirement_spec_item=SELF.requirement_spec_item -%]
33 33
   [%- ELSE -%]
34 34
    no section
......
101 101
         plugins: [ "themes", "json_data", "ui", "crrm", "dnd" ]
102 102
       })
103 103
       .bind("move_node.jstree", requirement_spec_tree_node_moved)
104
       .bind("click.jstree",     requirement_spec_tree_node_clicked)
104
       .bind("click.jstree",     requirement_spec_tree_node_clicked);
105
[%- IF SELF.requirement_spec_item -%]
106
       $.jstree._reference("#tree").select_node('fb-[% SELF.requirement_spec_item.id %]', true);
107
[%- END -%]
105 108
     });
106 109

  
107 110
function ask_delete_text_block(key, opt) {

Auch abrufbar als: Unified diff