Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / templates / webpages / record_links / add_filter.html
index 1ef213b..d9b0209 100644 (file)
@@ -1,16 +1,16 @@
 [%- USE L -%][%- USE LxERP -%][%- USE JavaScript -%]
 [%- SET style='width: 500px' %]
-<div class="listtop">[%- LxERP.t8("Add link: select records to link with") %]</div>
+<h1>[%- LxERP.t8("Add link: select records to link with") %]</h1>
 
 
-<form method="post" action="controller.pl">
+<form method="post" action="controller.pl" id="record_links_add_filter_form">
  [% L.hidden_tag('object_model',   SELF.object_model) %]
  [% L.hidden_tag('object_id',      SELF.object_id) %]
 
  <table>
   <tr>
    <td>[%- LxERP.t8("Link to") %]:</td>
-   <td>[% L.select_tag('link_type', LINK_TYPES, default=DEFAULT_LINK_TYPE, style=style) %]</td>
+   <td>[% L.select_tag('link_type', LINK_TYPES, default=DEFAULT_LINK_TYPE, style=style, id='record_links_add_filter_link_type') %]</td>
   </tr>
 
   <tr>
                        style=style) %]</td>
   </tr>
 
+  <tr>
+   <td>[%- LxERP.t8("Record number") %]:</td>
+   <td>[% L.input_tag('number', '', style=style) %]</td>
+  </tr>
+
   <tr>
    <td>[%- LxERP.t8("Customer/Vendor Number") %]:</td>
    <td>[% L.input_tag('vc_number', is_sales ? SELF.object.customer.customernumber : SELF.object.vendor.vendornumber, style=style) %]</td>
    <td>[% L.input_tag('vc_name', is_sales ? SELF.object.customer.name : SELF.object.vendor.name, style=style) %]</td>
   </tr>
 
-  <tr>
+  <tr id="record_links_add_filter_project_row">
    <td>[%- LxERP.t8("Project") %]:</td>
-   <td>[% L.select_tag('project_id', PROJECTS, default=SELF.object.globalproject_id, with_empty=1, style=style) %]</td>
+   <td>[% L.select_tag('globalproject_id', PROJECTS, default=SELF.object.globalproject_id, with_empty=1, style=style) %]</td>
   </tr>
 
   <tr>
-   <td>[%- LxERP.t8("Transaction description") %]:</td>
+   <td><span id="record_links_add_filter_title">[%- LxERP.t8("Transaction description") %]</span>:</td>
    <td>[% L.input_tag('transaction_description', '', style=style) %]</td>
   </tr>
  </table>
@@ -45,8 +50,8 @@
  <p>
   [% L.button_tag('filter_record_links()', LxERP.t8("Search")) %]
   [% L.button_tag('add_selected_record_links()', LxERP.t8("Add links"), id='add_selected_record_links_button', disabled=1) %]
-  <a href="#" onclick="record_links_reset_form();">[%- LxERP.t8("Reset") %]</a>
-  <a href="#" onclick="record_links_cancel();">[% LxERP.t8("Cancel") %]</a>
+  [% L.button_tag('$("#record_links_add_filter_form").resetForm()', LxERP.t8('Reset')) %]
+  <a href="#" onclick="$('#record_links_add').dialog('close');">[% LxERP.t8("Cancel") %]</a>
  </p>
 
  <hr>
 <script type="text/javascript">
 <!--
 $(function() {
-  $('.jqmWindow input[name=vc_name]').focus();
+  $('#record_links_add input[name=vc_name]').focus();
+  $('#record_links_add_filter_link_type').change(record_links_change_form_to_match_type);
+  record_links_change_form_to_match_type();
 });
 
-function record_links_reset_form() {
-  $('.jqmWindow form input[type=text]').val('');
-  $('.jqmWindow form select').prop('selectedIndex', 0);
-}
-
-function record_links_cancel() {
-  $('.jqmWindow').jqmHide();
-  $('.jqmWindow').remove();
-}
-
 function filter_record_links() {
-  var url="controller.pl?action=RecordLinks/ajax_add_list&" + $(".jqmWindow form").serialize();
+  var url="controller.pl?action=RecordLinks/ajax_add_list&" + $("#record_links_add form").serialize();
   $.ajax({
     url: url,
     success: function(new_data) {
@@ -83,14 +80,30 @@ function filter_record_links() {
 }
 
 function add_selected_record_links() {
-  var url="controller.pl?action=RecordLinks/ajax_add_do&" + $(".jqmWindow form").serialize();
+  var url="controller.pl?action=RecordLinks/ajax_add_do&" + $("#record_links_add form").serialize();
   $.ajax({
     url: url,
     success: function(new_html) {
       $('#record_links_list').replaceWith(new_html);
-      record_links_cancel();
+      $('#record_links_add').dialog('close');
     }
   });
 }
+
+function record_links_change_form_to_match_type() {
+  var type  = $('#record_links_add_filter_link_type').val();
+  var title = type == 'requirement_spec' ? kivi.t8('Title')
+            : type == 'letter'           ? kivi.t8('Subject')
+            :                              kivi.t8('Transaction description');
+
+  if (type == 'letter') {
+    $('#record_links_add_filter_project_row').hide();
+
+  } else {
+    $('#record_links_add_filter_project_row').show();
+  }
+
+  $('#record_links_add_filter_title').html(title);
+}
 -->
 </script>