]> wagnertech.de Git - mfinanz.git/blobdiff - js/kivi.TimeRecording.js
Zeiterfassung: Eingaben: Wenn Projekt-Picker gesperrt, dann auch Lupe nicht erlauben
[mfinanz.git] / js / kivi.TimeRecording.js
index 574549e0e20ff669b03939199ca1fdd2a049e8b9..b897b764f20d9a5d504cbe452dee12270ef293fb 100644 (file)
@@ -1,6 +1,8 @@
 namespace('kivi.TimeRecording', function(ns) {
   'use strict';
 
+  ns.inputs_to_disable = [];
+
   ns.set_end_date = function() {
     if ($('#start_date').val() !== '' && $('#end_date').val() === '') {
       var kivi_start_date  = kivi.format_date(kivi.parse_date($('#start_date').val()));
@@ -25,6 +27,7 @@ namespace('kivi.TimeRecording', function(ns) {
       $('#time_recording_customer_id_name').prop('disabled', false);
       $('#time_recording_project_id').data('project_picker').set_item({});
       $('#time_recording_project_id_name').prop('disabled', false);
+      $('#time_recording_project_id ~ .ppp_popup_button').show()
       return;
     }
 
@@ -34,6 +37,7 @@ namespace('kivi.TimeRecording', function(ns) {
       $('#time_recording_customer_id_name').prop('disabled', true);
       $('#time_recording_project_id').data('project_picker').set_item(data.project);
       $('#time_recording_project_id_name').prop('disabled', true);
+      $('#time_recording_project_id ~ .ppp_popup_button').hide()
     });
   };
 
@@ -56,8 +60,21 @@ namespace('kivi.TimeRecording', function(ns) {
     });
   };
 
+  ns.set_input_constraints = function() {
+    $(ns.inputs_to_disable).each(function(idx, elt) {
+      if ("customer" === elt) {
+        $('#time_recording_customer_id_name').prop('disabled', true);
+      }
+      if ("project" === elt) {
+        $('#time_recording_project_id_name').prop('disabled', true);
+        setTimeout(function() {$('#time_recording_project_id ~ .ppp_popup_button').hide();}, 100);
+      }
+    });
+  };
+
 });
 
 $(function() {
+  kivi.TimeRecording.set_input_constraints();
   $('#time_recording_project_id').on('set_item:ProjectPicker', function(){ kivi.TimeRecording.project_changed() });
 });