From: Sven Schöling Date: Tue, 22 Sep 2015 12:20:16 +0000 (+0200) Subject: RequirementSpecs: js accessor angepasst X-Git-Tag: release-3.4.1~719 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d41efcfe571f88b63aa53492e3e3460d948232d6;p=kivitendo-erp.git RequirementSpecs: js accessor angepasst --- diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index 1e3618112..38bb4460b 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -7,7 +7,6 @@ use parent qw(SL::Controller::Base); use File::Spec (); -use SL::ClientJS; use SL::Common (); use SL::Controller::Helper::GetModels; use SL::Controller::Helper::ReportGenerator; @@ -29,7 +28,7 @@ use SL::Template::LaTeX; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(requirement_spec_item visible_item visible_section) ], - 'scalar --get_set_init' => [ qw(requirement_spec customers types statuses complexities risks projects project_types project_statuses default_project_type default_project_status copy_source js + 'scalar --get_set_init' => [ qw(requirement_spec customers types statuses complexities risks projects project_types project_statuses default_project_type default_project_status copy_source current_text_block_output_position models time_based_units html_template cvar_configs includeable_cvar_configs include_cvars) ], ); @@ -84,7 +83,7 @@ sub action_ajax_edit { $self->js ->hide('#basic_settings') ->after('#basic_settings', $html) - ->render($self); + ->render; } sub action_ajax_edit_project_link { @@ -95,7 +94,7 @@ sub action_ajax_edit_project_link { $self->js ->hide('#basic_settings') ->after('#basic_settings', $html) - ->render($self); + ->render; } sub action_ajax_show_time_and_cost_estimate { @@ -116,7 +115,7 @@ sub action_ajax_edit_time_and_cost_estimate { ->after('#time_cost_estimate', $html) ->on('#time_cost_estimate INPUT[type=text]', 'keydown', 'kivi.requirement_spec.time_cost_estimate_input_key_down') ->action_if($first && $first->id, 'focus', '#time_and_cost_estimate_form_complexity_id_' . $first->id) - ->render($self); + ->render; } sub action_ajax_save_time_and_cost_estimate { @@ -140,7 +139,7 @@ sub action_ajax_save_time_and_cost_estimate { my $html = $self->render('requirement_spec/_show_time_and_cost_estimate', { output => 0 }, initially_hidden => !!$::form->{keep_open}); $self->js->replaceWith('#time_cost_estimate', $html); - return $self->js->render($self) if $::form->{keep_open}; + return $self->js->render if $::form->{keep_open}; $self->js->remove('#time_cost_estimate_form_container'); @@ -149,7 +148,7 @@ sub action_ajax_save_time_and_cost_estimate { $self->js->html('#column-content', $html); } - $self->js->render($self); + $self->js->render; } sub action_show { @@ -200,7 +199,7 @@ sub action_destroy { sub action_revert_to { my ($self, %params) = @_; - return $self->js->error(t8('Cannot revert a versioned copy.'))->render($self) if $self->requirement_spec->working_copy_id; + return $self->js->error(t8('Cannot revert a versioned copy.'))->render if $self->requirement_spec->working_copy_id; my $versioned_copy = SL::DB::RequirementSpec->new(id => $::form->{versioned_copy_id})->load; @@ -209,7 +208,7 @@ sub action_revert_to { $version->update_attributes(working_copy_id => $self->requirement_spec->id); flash_later('info', t8('The requirement spec has been reverted to version #1.', $versioned_copy->version->version_number)); - $self->js->redirect_to($self->url_for(action => 'show', id => $self->requirement_spec->id))->render($self); + $self->js->redirect_to($self->url_for(action => 'show', id => $self->requirement_spec->id))->render; } sub action_create_pdf { @@ -269,7 +268,7 @@ sub action_paste_template { my $template = SL::DB::RequirementSpec->new(id => $::form->{template_id})->load; my %result = $self->requirement_spec->paste_template($template); - return $self->js->error($self->requirement_spec->error)->render($self) if !%result; + return $self->js->error($self->requirement_spec->error)->render if !%result; $self->render_pasted_text_block($_) for sort { $a->position <=> $b->position } @{ $result{text_blocks} }; $self->render_pasted_section($_) for sort { $a->position <=> $b->position } @{ $result{sections} }; @@ -284,7 +283,7 @@ sub action_paste_template { ->show( '#additional_parts_list_container') ->remove( '#additional_parts_form_container'); - $self->invalidate_version->render($self); + $self->invalidate_version->render; } sub action_renumber_sections { @@ -329,7 +328,6 @@ sub setup { return 1; } -sub init_js { SL::ClientJS->new } sub init_complexities { SL::DB::Manager::RequirementSpecComplexity->get_all_sorted } sub init_default_project_status { SL::DB::Manager::ProjectStatus->find_by(name => 'planning') } sub init_default_project_type { SL::DB::ProjectType->new(id => 1)->load } @@ -411,7 +409,7 @@ sub create_or_update { my @errors = $self->requirement_spec->validate; if (@errors) { - return $self->js->error(@errors)->render($self) if $::request->is_ajax; + return $self->js->error(@errors)->render if $::request->is_ajax; flash('error', @errors); $self->render('requirement_spec/new', title => $title); @@ -428,7 +426,7 @@ sub create_or_update { })) { $::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error); @errors = ($::locale->text('Saving failed. Error message from the database: #1', $db->error)); - return $self->js->error(@errors)->render($self) if $::request->is_ajax; + return $self->js->error(@errors)->render if $::request->is_ajax; $self->requirement_spec->id(undef) if $is_new; flash('error', @errors); @@ -445,7 +443,7 @@ sub create_or_update { ->replaceWith('#basic_settings', $basics_html) ->remove('#basic_settings_form') ->flash('info', $info) - ->render($self); + ->render; } flash_later('info', $info); @@ -612,7 +610,7 @@ sub update_project_link_none_keep_existing { ->replaceWith('#basic_settings', $self->render('requirement_spec/_show_basic_settings', { output => 0 })) ->remove('#project_link_form') ->flash('info', t8('The project link has been updated.')) - ->render($self); + ->render; } sub update_project_link_new { @@ -620,7 +618,7 @@ sub update_project_link_new { return $self->js ->replaceWith('#project_link_form', $self->render('requirement_spec/_new_project_form', { output => 0 })) - ->render($self); + ->render; } sub update_project_link_create { @@ -634,7 +632,7 @@ sub update_project_link_create { my @errors = $project->validate; - return $self->js->error(@errors)->render($self) if @errors; + return $self->js->error(@errors)->render if @errors; my $db = $self->requirement_spec->db; if (!$db->do_transaction(sub { @@ -643,7 +641,7 @@ sub update_project_link_create { })) { $::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error); - return $self->js->error(t8('Saving failed. Error message from the database: #1', $db->error))->render($self); + return $self->js->error(t8('Saving failed. Error message from the database: #1', $db->error))->render; } return $self->invalidate_version @@ -651,7 +649,7 @@ sub update_project_link_create { ->remove('#project_link_form') ->flash('info', t8('The project has been created.')) ->flash('info', t8('The project link has been updated.')) - ->render($self); + ->render; } sub init_models { diff --git a/SL/Controller/RequirementSpecItem.pm b/SL/Controller/RequirementSpecItem.pm index c8119be35..c6026ce08 100644 --- a/SL/Controller/RequirementSpecItem.pm +++ b/SL/Controller/RequirementSpecItem.pm @@ -23,7 +23,7 @@ use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(item visible_item visible_section clicked_item sections) ], - 'scalar --get_set_init' => [ qw(complexities risks js predefined_texts) ], + 'scalar --get_set_init' => [ qw(complexities risks predefined_texts) ], ); __PACKAGE__->run_before('check_auth'); @@ -39,7 +39,7 @@ sub action_ajax_list { if (!$::form->{clicked_id}) { # Clicked on "sections" in the tree. Do nothing. - return $self->render($self->js); + return $self->render; } my $clicked_item = SL::DB::RequirementSpecItem->new(id => $::form->{clicked_id})->load; @@ -98,7 +98,7 @@ sub action_dragged_and_dropped { my $new_section = $self->item->section; my $new_visible_section = SL::DB::RequirementSpecItem->new(id => $self->visible_item->id)->load->section; - return $self->invalidate_version->render($self) if !$old_visible_section || ($new_type eq 'section'); + return $self->invalidate_version->render if !$old_visible_section || ($new_type eq 'section'); # From here on $old_visible_section is definitely set. @@ -533,11 +533,6 @@ sub init_predefined_texts { return SL::DB::Manager::RequirementSpecPredefinedText->get_all_sorted(where => [ useable_for_sections => 1 ]); } -sub init_js { - my ($self) = @_; - $self->js(SL::ClientJS->new); -} - sub replace_bottom { my ($self, $item_or_id) = @_; @@ -709,7 +704,7 @@ sub add_function_block { $self->js->show('#sub-function-block-container-' . $parent_id) if $new_type eq 'sub-function-block'; $self->add_new_item_form(insert_position => $insert_position, insert_reference => $insert_reference, display_reference => $display_reference); - $self->js->render($self); + $self->js->render; } sub is_item_visible { diff --git a/SL/Controller/RequirementSpecOrder.pm b/SL/Controller/RequirementSpecOrder.pm index c031a8935..f695a510a 100644 --- a/SL/Controller/RequirementSpecOrder.pm +++ b/SL/Controller/RequirementSpecOrder.pm @@ -8,7 +8,6 @@ use parent qw(SL::Controller::Base); use List::MoreUtils qw(uniq); use List::Util qw(first); -use SL::ClientJS; use SL::DB::Customer; use SL::DB::Order; use SL::DB::Part; @@ -23,7 +22,7 @@ use constant FORMS_SELECTOR => '#quotations_and_orders_article_assignment,#quota use Rose::Object::MakeMethods::Generic ( scalar => [ qw(parts) ], - 'scalar --get_set_init' => [ qw(requirement_spec rs_order js h_unit_name all_customers all_parts_time_unit section_order_part) ], + 'scalar --get_set_init' => [ qw(requirement_spec rs_order h_unit_name all_customers all_parts_time_unit section_order_part) ], ); __PACKAGE__->run_before('setup'); @@ -42,20 +41,20 @@ sub action_new { my ($self) = @_; if (!@{ $self->all_parts_time_unit }) { - 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); + return $self->js->flash('error', t8('This function requires the presence of articles with a time-based unit such as "h" or "min".'))->render; } 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); + ->render; } sub action_create { my ($self) = @_; if (!$::auth->assert($::form->{quotation} ? 'sales_quotation_edit' : 'sales_order_edit', 1)) { - return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render($self); + return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render; } # 1. Update sections with selected part IDs. @@ -85,7 +84,7 @@ sub action_create { $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); + ->render; } sub action_update { @@ -95,7 +94,7 @@ sub action_update { my $sections = $self->requirement_spec->sections_sorted; if (!$::auth->assert($order->quotation ? 'sales_quotation_edit' : 'sales_order_edit', 1)) { - return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render($self); + return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render; } my (@orderitems, %sections_seen); @@ -116,7 +115,7 @@ sub action_update { $self->js->hide(LIST_SELECTOR()) ->after(LIST_SELECTOR(), $html) - ->render($self); + ->render; } sub action_do_update { @@ -143,21 +142,21 @@ sub action_do_update { $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); + ->render; } sub action_edit_assignment { my ($self) = @_; if (!@{ $self->all_parts_time_unit }) { - 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); + return $self->js->flash('error', t8('This function requires the presence of articles with a time-based unit such as "h" or "min".'))->render; } my $html = $self->render('requirement_spec_order/edit_assignment', { output => 0 }, make_part_title => sub { $_[0]->partnumber . ' ' . $_[0]->description }); $self->js->hide(LIST_SELECTOR()) ->after(LIST_SELECTOR(), $html) ->reinit_widgets - ->render($self); + ->render; } sub action_save_assignment { @@ -168,7 +167,7 @@ sub action_save_assignment { my $html = $self->render('requirement_spec_order/list', { output => 0 }); $self->js->replaceWith(LIST_SELECTOR(), $html) ->remove(FORMS_SELECTOR()) - ->render($self); + ->render; } sub action_delete { @@ -182,7 +181,7 @@ sub action_delete { my $html = $self->render('requirement_spec_order/list', { output => 0 }); $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); + ->render; } # @@ -204,11 +203,6 @@ sub init_requirement_spec { $self->requirement_spec(SL::DB::RequirementSpec->new(id => $::form->{requirement_spec_id})->load) if $::form->{requirement_spec_id}; } -sub init_js { - my ($self) = @_; - $self->js(SL::ClientJS->new); -} - sub init_all_customers { SL::DB::Manager::Customer->get_all_sorted } sub init_h_unit_name { SL::DB::Manager::Unit->find_h_unit->name }; sub init_rs_order { SL::DB::RequirementSpecOrder->new(id => $::form->{rs_order_id})->load }; diff --git a/SL/Controller/RequirementSpecTextBlock.pm b/SL/Controller/RequirementSpecTextBlock.pm index d6e8c35a6..264b83b5a 100644 --- a/SL/Controller/RequirementSpecTextBlock.pm +++ b/SL/Controller/RequirementSpecTextBlock.pm @@ -8,7 +8,6 @@ use Carp; use Params::Validate (); use Time::HiRes (); -use SL::ClientJS; use SL::Clipboard; use SL::Controller::Helper::RequirementSpec; use SL::DB::RequirementSpec; @@ -23,7 +22,7 @@ use constant SORTABLE_PICTURE_LIST => 'kivi.requirement_spec.make_text_block_pic use Rose::Object::MakeMethods::Generic ( scalar => [ qw(text_block) ], - 'scalar --get_set_init' => [ qw(predefined_texts js picture) ], + 'scalar --get_set_init' => [ qw(predefined_texts picture) ], ); __PACKAGE__->run_before('check_auth'); @@ -66,7 +65,7 @@ sub action_ajax_add { $self->add_new_text_block_form(output_position => $new_where, insert_after_id => $::form->{id}, requirement_spec_id => $::form->{requirement_spec_id}); - $self->invalidate_version->render($self); + $self->invalidate_version->render; } sub action_ajax_edit { @@ -434,11 +433,6 @@ sub init_picture { return SL::DB::RequirementSpecPicture->new(id => $::form->{picture_id} || $::form->{id})->load; } -sub init_js { - my ($self) = @_; - $self->js(SL::ClientJS->new); -} - sub invalidate_version { my ($self) = @_; @@ -495,7 +489,7 @@ sub paste_picture { $self->text_block->save; })) { $::lxdebug->message(LXDebug::WARN(), "Error: " . $self->text_block->db->error); - return $self->js->error($::locale->text('Saving failed. Error message from the database: #1', $self->text_block->db->error))->render($self); + return $self->js->error($::locale->text('Saving failed. Error message from the database: #1', $self->text_block->db->error))->render; } my $html = $self->render('requirement_spec_text_block/_text_block_picture', { output => 0 }, picture => $self->picture); @@ -503,7 +497,7 @@ sub paste_picture { $self->invalidate_version ->append('#text-block-' . $self->text_block->id . '-pictures', $html) ->show('#text-block-' . $self->text_block->id . '-pictures') - ->render($self); + ->render; } 1; diff --git a/SL/Controller/RequirementSpecVersion.pm b/SL/Controller/RequirementSpecVersion.pm index e97d2252b..e225d77b3 100644 --- a/SL/Controller/RequirementSpecVersion.pm +++ b/SL/Controller/RequirementSpecVersion.pm @@ -7,7 +7,6 @@ use parent qw(SL::Controller::Base); use Carp; use List::MoreUtils qw(any); -use SL::ClientJS; use SL::DB::Customer; use SL::DB::Project; use SL::DB::RequirementSpec; @@ -17,7 +16,7 @@ use SL::Locale::String; use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(requirement_spec version js) ], + 'scalar --get_set_init' => [ qw(requirement_spec version) ], ); __PACKAGE__->run_before('check_auth'); @@ -69,14 +68,14 @@ sub action_create { my %attributes = %{ delete($::form->{rs_version}) || {} }; my @errors = SL::DB::RequirementSpecVersion->new(%attributes, version_number => 1)->validate; - return $self->js->error(@errors)->render($self) if @errors; + return $self->js->error(@errors)->render if @errors; my $db = $self->requirement_spec->db; my @result = $self->requirement_spec->create_version(%attributes); if (!@result) { $::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error); - return $self->js->error($::locale->text('Saving failed. Error message from the database: #1'), $db->error)->render($self); + return $self->js->error($::locale->text('Saving failed. Error message from the database: #1'), $db->error)->render; } $self->version($result[0]); @@ -87,7 +86,7 @@ sub action_create { ->html('#requirement_spec_version', $version_info_html) ->html('#versioned_copies_list', $version_list_html) ->dialog->close('#jqueryui_popup_dialog') - ->render($self); + ->render; } # @@ -113,11 +112,6 @@ sub init_version { $self->version(SL::DB::RequirementSpecVersion->new(id => $::form->{id})->load) if $::form->{id}; } -sub init_js { - my ($self, %params) = @_; - $self->js(SL::ClientJS->new); -} - sub has_item_changed { my ($previous, $current) = @_; croak "Missing previous/current" if !$previous || !$current;