From cc1f1d856a432cd669fcec19dfb6938d8c638767 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 17 May 2021 16:32:09 +0200 Subject: [PATCH] Zeiterfassung: Auch beim Laden entsprechende Eingabe-Felder sperren: MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - wenn Auftrag ausgewählt. so ist Kunde und Projekt gesperrt - wenn Projekt ausgewählt, und Projekt einen Kunden hat, so ist Kunde gesperrt --- SL/Controller/TimeRecording.pm | 13 ++++++++++++- js/kivi.TimeRecording.js | 14 ++++++++++++++ templates/webpages/time_recording/form.html | 8 ++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/SL/Controller/TimeRecording.pm b/SL/Controller/TimeRecording.pm index 5175af70e..628c8ae1e 100644 --- a/SL/Controller/TimeRecording.pm +++ b/SL/Controller/TimeRecording.pm @@ -103,10 +103,13 @@ sub action_edit { $self->{end_time} = $self->time_recording->end_time->to_kivitendo_time; } + my $inputs_to_disable = $self->get_inputs_to_disable; + $self->setup_edit_action_bar; $self->render('time_recording/form', - title => t8('Time Recording'), + title => t8('Time Recording'), + inputs_to_disable => $inputs_to_disable, ); } @@ -405,4 +408,12 @@ sub safe_callback { $::form->{callback} || (action => 'list') } +sub get_inputs_to_disable { + my ($self) = @_; + + return [qw(customer project)] if $self->time_recording->order_id; + return [qw(customer)] if $self->time_recording->project_id && $self->time_recording->project->customer_id; +} + + 1; diff --git a/js/kivi.TimeRecording.js b/js/kivi.TimeRecording.js index 574549e0e..dd44411cf 100644 --- a/js/kivi.TimeRecording.js +++ b/js/kivi.TimeRecording.js @@ -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())); @@ -56,8 +58,20 @@ 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); + } + }); + }; + }); $(function() { + kivi.TimeRecording.set_input_constraints(); $('#time_recording_project_id').on('set_item:ProjectPicker', function(){ kivi.TimeRecording.project_changed() }); }); diff --git a/templates/webpages/time_recording/form.html b/templates/webpages/time_recording/form.html index 07939daaa..c5a8d639f 100644 --- a/templates/webpages/time_recording/form.html +++ b/templates/webpages/time_recording/form.html @@ -93,3 +93,11 @@ [%- END %] + + -- 2.20.1