From 2e8dd1d85541033e1b4f5fe2f41da528e860c6e5 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 31 Jul 2013 16:49:43 +0200 Subject: [PATCH] =?utf8?q?Pflichtenheft=20Angebote/Auftr=C3=A4ge:=20"Abbre?= =?utf8?q?chen"=20ohne=20AJAX-Call=20nur=20in=20JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/RequirementSpecOrder.pm | 33 +++++++++---------- js/requirement_spec.js | 7 +++- .../requirement_spec_order/update.html | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/SL/Controller/RequirementSpecOrder.pm b/SL/Controller/RequirementSpecOrder.pm index fafa77c77..f0f20d496 100644 --- a/SL/Controller/RequirementSpecOrder.pm +++ b/SL/Controller/RequirementSpecOrder.pm @@ -17,7 +17,8 @@ use SL::DB::RequirementSpecOrder; use SL::Helper::Flash; use SL::Locale::String; -use constant TAB_ID => 'ui-tabs-4'; +use constant LIST_SELECTOR => '#quotations_and_orders'; +use constant FORMS_SELECTOR => '#quotations_and_orders_article_assignment,#quotations_and_orders_new,#quotations_and_orders_update'; use Rose::Object::MakeMethods::Generic ( @@ -44,8 +45,9 @@ sub action_new { return $self->js->flash('error', t8('This function requires the presence of articles with a time-based unit such as "h" or "min".'))->render($self); } - my $html = $self->render('requirement_spec_order/new', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description }); - $self->js->html('#' . TAB_ID(), $html) + my $html = $self->render('requirement_spec_order/new', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description }); + $self->js->hide(LIST_SELECTOR()) + ->after(LIST_SELECTOR(), $html) ->render($self); } @@ -72,7 +74,8 @@ sub action_create { # 3. Notify the user and return to list. my $html = $self->render('requirement_spec_order/list', { output => 0 }); - $self->js->html('#' . TAB_ID(), $html) + $self->js->replaceWith(LIST_SELECTOR(), $html) + ->remove(FORMS_SELECTOR()) ->flash('info', $::form->{quotation} ? t8('Sales quotation #1 has been created.', $order->quonumber) : t8('Sales order #1 has been created.', $order->ordnumber)) ->render($self); } @@ -99,7 +102,8 @@ sub action_update { make_section_title => sub { $_[0]->fb_number . ' ' . $_[0]->title }, ); - $self->js->html('#' . TAB_ID(), $html) + $self->js->hide(LIST_SELECTOR()) + ->after(LIST_SELECTOR(), $html) ->render($self); } @@ -136,7 +140,8 @@ sub action_do_update { $self->init_requirement_spec; my $html = $self->render('requirement_spec_order/list', { output => 0 }); - $self->js->html('#' . TAB_ID(), $html) + $self->js->replaceWith(LIST_SELECTOR(), $html) + ->remove(FORMS_SELECTOR()) ->flash('info', $::form->{quotation} ? t8('Sales quotation #1 has been updated.', $order->quonumber) : t8('Sales order #1 has been updated.', $order->ordnumber)) ->render($self); } @@ -149,7 +154,8 @@ sub action_edit_assignment { } my $html = $self->render('requirement_spec_order/edit_assignment', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description }); - $self->js->html('#' . TAB_ID(), $html) + $self->js->hide(LIST_SELECTOR()) + ->after(LIST_SELECTOR(), $html) ->render($self); } @@ -159,7 +165,8 @@ sub action_save_assignment { SL::DB::RequirementSpecItem->new(id => $_->{id})->load->update_attributes(order_part_id => ($_->{order_part_id} || undef)) for @{ $sections }; my $html = $self->render('requirement_spec_order/list', { output => 0 }); - $self->js->html('#' . TAB_ID(), $html) + $self->js->replaceWith(LIST_SELECTOR(), $html) + ->remove(FORMS_SELECTOR()) ->render($self); } @@ -172,19 +179,11 @@ sub action_delete { $self->init_requirement_spec; my $html = $self->render('requirement_spec_order/list', { output => 0 }); - $self->js->html('#' . TAB_ID(), $html) + $self->js->replaceWith(LIST_SELECTOR(), $html) ->flash('info', $order->quotation ? t8('Sales quotation #1 has been deleted.', $order->quonumber) : t8('Sales order #1 has been deleted.', $order->ordnumber)) ->render($self); } -sub action_cancel { - my ($self) = @_; - - my $html = $self->render('requirement_spec_order/list', { output => 0 }); - $self->js->html('#' . TAB_ID(), $html) - ->render($self); -} - # # filters # diff --git a/js/requirement_spec.js b/js/requirement_spec.js index d2a50523f..5c4967f41 100644 --- a/js/requirement_spec.js +++ b/js/requirement_spec.js @@ -365,8 +365,13 @@ ns.find_quotation_order_id = function(clicked_elt) { }; ns.standard_quotation_order_ajax_call = function(key, opt) { - if ((key == 'cancel') && !confirm(kivi.t8('Do you really want to cancel?'))) + if (key == 'cancel') { + if (confirm(kivi.t8('Do you really want to cancel?'))) { + $('#quotations_and_orders').show(); + $('#quotations_and_orders_article_assignment,#quotations_and_orders_new,#quotations_and_orders_update').remove(); + } return true; + } else if ((key == 'create') && $('#quotations_and_orders_form INPUT[name="sections[].order_part_id"]').filter(function(idx, elt) { return ($(elt).val() || '') == '' }).size()) { alert(kivi.t8('There is one or more sections for which no part has been assigned yet; therefore creating the new record is not possible yet.')); diff --git a/templates/webpages/requirement_spec_order/update.html b/templates/webpages/requirement_spec_order/update.html index 17d83431a..2230bd21d 100644 --- a/templates/webpages/requirement_spec_order/update.html +++ b/templates/webpages/requirement_spec_order/update.html @@ -2,7 +2,7 @@ [% SET style = "width: 400px" %] [% SET order = SELF.rs_order.order %] -
+

[% IF order.quotation %] -- 2.20.1