Pflichtenheftitems: RETURN in Zeitschätzungs-Input via AJAX submitten gefixt
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 15 Aug 2013 13:55:52 +0000 (15:55 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:09:11 +0000 (13:09 +0200)
SL/Controller/RequirementSpec.pm
SL/Controller/RequirementSpecItem.pm
js/requirement_spec.js

index 944e9dd..f99e0bf 100644 (file)
@@ -261,7 +261,7 @@ sub setup {
 
   $::auth->assert('sales_quotation_edit');
   $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec);
-  $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu requirement_spec);
+  $::request->{layout}->use_javascript("${_}.js")  for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec);
   $self->init_visible_section;
 
   return 1;
index 7b1ed81..0f7d66f 100644 (file)
@@ -258,7 +258,7 @@ sub action_ajax_edit {
     ->hide($content_top_id)
     ->remove("#${id_base}_form")
     ->insertAfter($html, $content_top_id)
-    ->on("#${id_base}_form INPUT[type=text]", "keydown", "kivi.requirement_spec.text_block_input_key_down")
+    ->run('kivi.requirement_spec.init_function_block_keypress_events', "${id_base}_form")
     ->jstree->select_node('#tree', '#fb-' . $self->item->id)
     ->focus("#${id_base}_description")
     ->val('#current_content_type', $self->item->item_type)
@@ -601,6 +601,7 @@ sub add_new_item_form {
 
   return $self->js
     ->action($params{insert_position}, $html, $params{display_reference})
+    ->run('kivi.requirement_spec.init_function_block_keypress_events', "${id_base}_form")
     ->focus("#${id_base}_description");
 }
 
index f33e52e..11bab36 100644 (file)
@@ -178,15 +178,6 @@ ns.ask_delete_text_block = function(key, opt) {
   return true;
 };
 
-ns.text_block_input_key_down = function(event) {
-  if(event.keyCode == 13) {
-    event.preventDefault();
-    var prefix = $(this).attr('id').match("^edit_function_block_\\d+")[0];
-    $("#" + prefix + "_submit").click();
-    return false;
-  }
-};
-
 ns.find_text_block_picture_id = function(clicked_elt) {
   var id    = $(clicked_elt).attr('id');
   var match = id.match(/^text-block-picture-(\d+)$/);
@@ -350,6 +341,19 @@ ns.item_popup_menu_hidden = function(opt) {
   return ns.handle_item_popup_menu_markings(opt, false);
 };
 
+ns.submit_function_block = function(event) {
+  event.preventDefault();
+
+  var prefix = $(this).attr('id').match("^(?:edit|new)_function_block_[\\d_]+\\d")[0];
+  kivi.submit_ajax_form('controller.pl?action=RequirementSpecItem/ajax_update', '#' + prefix + '_form');
+
+  return false;
+};
+
+ns.init_function_block_keypress_events = function(form_id) {
+  $("#" + form_id + " INPUT[type=text]").bind("keypress", "return", ns.submit_function_block);
+};
+
 // -------------------------------------------------------------------------
 // ------------------------------- templates -------------------------------
 // -------------------------------------------------------------------------