use File::Spec ();
-use SL::ClientJS;
use SL::Common ();
use SL::Controller::Helper::GetModels;
use SL::Controller::Helper::ReportGenerator;
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) ],
);
$self->js
->hide('#basic_settings')
->after('#basic_settings', $html)
- ->render($self);
+ ->render;
}
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 {
->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 {
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');
$self->js->html('#column-content', $html);
}
- $self->js->render($self);
+ $self->js->render;
}
sub action_show {
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;
$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 {
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} };
->show( '#additional_parts_list_container')
->remove( '#additional_parts_form_container');
- $self->invalidate_version->render($self);
+ $self->invalidate_version->render;
}
sub action_renumber_sections {
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 }
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);
})) {
$::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);
->replaceWith('#basic_settings', $basics_html)
->remove('#basic_settings_form')
->flash('info', $info)
- ->render($self);
+ ->render;
}
flash_later('info', $info);
->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 {
return $self->js
->replaceWith('#project_link_form', $self->render('requirement_spec/_new_project_form', { output => 0 }))
- ->render($self);
+ ->render;
}
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 {
})) {
$::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
->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 {
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');
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;
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.
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) = @_;
$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 {
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;
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');
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.
$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 {
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);
$self->js->hide(LIST_SELECTOR())
->after(LIST_SELECTOR(), $html)
- ->render($self);
+ ->render;
}
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 {
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 {
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;
}
#
$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 };
use Params::Validate ();
use Time::HiRes ();
-use SL::ClientJS;
use SL::Clipboard;
use SL::Controller::Helper::RequirementSpec;
use SL::DB::RequirementSpec;
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');
$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 {
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) = @_;
$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);
$self->invalidate_version
->append('#text-block-' . $self->text_block->id . '-pictures', $html)
->show('#text-block-' . $self->text_block->id . '-pictures')
- ->render($self);
+ ->render;
}
1;
use Carp;
use List::MoreUtils qw(any);
-use SL::ClientJS;
use SL::DB::Customer;
use SL::DB::Project;
use SL::DB::RequirementSpec;
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');
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]);
->html('#requirement_spec_version', $version_info_html)
->html('#versioned_copies_list', $version_list_html)
->dialog->close('#jqueryui_popup_dialog')
- ->render($self);
+ ->render;
}
#
$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;