From 93cc0157161476f242f3304b1950f80d0ba5ef08 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 17 Feb 2015 15:10:55 +0100 Subject: [PATCH] =?utf8?q?Pflichtenheft:=20nach=20benutzerdefinierten=20Va?= =?utf8?q?riablen=20suchen=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/RequirementSpec.pm | 5 +-- SL/DB/Manager/RequirementSpec.pm | 1 + .../common/render_cvar_filter_input.html | 35 +++++++++++++++++++ .../webpages/requirement_spec/_filter.html | 25 ++++++++----- 4 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 templates/webpages/common/render_cvar_filter_input.html diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index e249196d1..7e77457fa 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -30,7 +30,7 @@ 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 - current_text_block_output_position models time_based_units html_template) ], + current_text_block_output_position models time_based_units html_template cvar_configs) ], ); __PACKAGE__->run_before('setup'); @@ -323,7 +323,7 @@ sub setup { $::auth->assert('requirement_spec_edit'); $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec); - $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec ckeditor/ckeditor ckeditor/adapters/jquery autocomplete_part); + $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu jquery/jquery.hotkeys requirement_spec ckeditor/ckeditor ckeditor/adapters/jquery autocomplete_part autocomplete_customer); $self->init_visible_section; return 1; @@ -340,6 +340,7 @@ sub init_risks { SL::DB::Manager::RequirementSpecRisk->get_all_ sub init_statuses { SL::DB::Manager::RequirementSpecStatus->get_all_sorted } sub init_time_based_units { SL::DB::Manager::Unit->time_based_units } sub init_types { SL::DB::Manager::RequirementSpecType->get_all_sorted } +sub init_cvar_configs { SL::DB::Manager::CustomVariableConfig->get_all_sorted(where => [ module => 'RequirementSpecs' ]) } sub init_customers { my ($self) = @_; diff --git a/SL/DB/Manager/RequirementSpec.pm b/SL/DB/Manager/RequirementSpec.pm index fecd9d358..fa35de0b8 100644 --- a/SL/DB/Manager/RequirementSpec.pm +++ b/SL/DB/Manager/RequirementSpec.pm @@ -5,6 +5,7 @@ use strict; use SL::DB::Helper::Manager; use base qw(SL::DB::Helper::Manager); +use SL::DB::Helper::Filtered; use SL::DB::Helper::Paginated; use SL::DB::Helper::Sorted; diff --git a/templates/webpages/common/render_cvar_filter_input.html b/templates/webpages/common/render_cvar_filter_input.html new file mode 100644 index 000000000..b1467c215 --- /dev/null +++ b/templates/webpages/common/render_cvar_filter_input.html @@ -0,0 +1,35 @@ +[%- USE HTML -%][%- USE L -%][%- USE LxERP -%][%- USE T8 -%] +[%- SET id__ = cvar_cfg.id + name__ = 'filter.cvar.' _ id__ + value__ = filter.cvar.$id__ %] +[%- IF cvar_cfg.type == 'bool' %] + [%- L.select_tag(name__, [ '', [ 1, LxERP.t8('Yes') ], [ 0, LxERP.t8('No') ] ], default=value__, class=cvar_class) %] + +[%- ELSIF cvar_cfg.type == 'number' %] + [% L.select_tag(name__ _ '::', [ [ 'eq', '==' ], [ 'ne', '=/=' ], [ 'gt', '>' ], [ 'ge', '>=' ], [ 'lt', '<' ], [ 'le', '<=' ] ]) %] + [% L.input_tag(name__, value__, class=cvar_class) %] + +[%- ELSIF cvar_cfg.type == 'date' %] + [% L.select_tag(name__ _ '::', [ [ 'eq', '==' ], [ 'ne', '=/=' ], [ 'gt', '>' ], [ 'ge', '>=' ], [ 'lt', '<' ], [ 'le', '<=' ] ]) %] + [% L.date_tag(name__, value__, class=cvar_class) %] + +[% ELSIF cvar_cfg.type == 'select' %] + [% options__ = [ '' ]; + options__ = options__.import(cvar_cfg.processed_options); + L.select_tag(name__, options__, default=value__, class=cvar_class) %] + +[% ELSIF cvar_cfg.type == 'customer' %] + [%- L.customer_vendor_picker(name__, value__, type='customer', class=cvar_class) %] + +[% ELSIF cvar_cfg.type == 'vendor' %] + [%- L.customer_vendor_picker(name__, value__, type='vendor', class=cvar_class) %] + +[% ELSIF cvar_cfg.type == 'part' %] + [%- L.part_picker(name__, value__, class=cvar_class) %] + +[%- ELSE %] + [% SET value_name__ = id__ _ '_substr__ilike' + value__ = filter.cvar.$value_name__ %] + [%- L.input_tag(name__ _ ':substr::ilike', value__, maxlength=cvar_cfg.maxlength, class=cvar_class) %] + +[%- END %] diff --git a/templates/webpages/requirement_spec/_filter.html b/templates/webpages/requirement_spec/_filter.html index 19c03dae0..db493b37c 100644 --- a/templates/webpages/requirement_spec/_filter.html +++ b/templates/webpages/requirement_spec/_filter.html @@ -11,41 +11,50 @@ [%- L.hidden_tag("is_template", is_template) %]

- +
- + [%- UNLESS is_template %] - + - + - + - + - + - + + + [% FOREACH cvar_cfg = SELF.cvar_configs %] + [%- IF cvar_cfg.searchable %] + + + + + [% END %] + [% END %] [%- END %]
[% LxERP.t8("Title") %][% L.input_tag('filter.title:substr::ilike', filter.title_substr__ilike) %][% L.input_tag('filter.title:substr::ilike', filter.title_substr__ilike, class="rs_input_field") %]
[% LxERP.t8("Customer") %][% L.input_tag('filter.customer.name:substr::ilike', filter.customer.name_substr__ilike) %][% L.input_tag('filter.customer.name:substr::ilike', filter.customer.name_substr__ilike, class="rs_input_field") %]
[% LxERP.t8("Customer Number") %][% L.input_tag('filter.customer.customernumber:substr::ilike', filter.customer.customernumber_substr__ilike) %][% L.input_tag('filter.customer.customernumber:substr::ilike', filter.customer.customernumber_substr__ilike, class="rs_input_field") %]
[% LxERP.t8("Requirement Spec Type") %][% L.select_tag('filter.type_id', SELF.types, default=filter.type_id, title_key="description", with_empty=1) %][% L.select_tag('filter.type_id', SELF.types, default=filter.type_id, title_key="description", with_empty=1, class="rs_input_field") %]
[% LxERP.t8("Requirement Spec Status") %][% L.select_tag('filter.status_id[]', SELF.statuses, default=filter.status_id_, title_key="description", multiple=1) %][%# NOTE: the trailing '_' is NOT a mistake -- look at SL::Controller::Helper::Filtered for the explanation! %][% L.select_tag('filter.status_id[]', SELF.statuses, default=filter.status_id_, title_key="description", multiple=1, class="rs_input_field") %][%# NOTE: the trailing '_' is NOT a mistake -- look at SL::Controller::Helper::Filtered for the explanation! %]
[% LxERP.t8("Project Number") %][% L.input_tag('filter.project.projectnumber:substr::ilike', filter.project.projectnumber_substr__ilike) %][% L.input_tag('filter.project.projectnumber:substr::ilike', filter.project.projectnumber_substr__ilike, class="rs_input_field") %]
[% LxERP.t8("Project Description") %][% L.input_tag('filter.project.description:substr::ilike', filter.project.description_substr__ilike) %][% L.input_tag('filter.project.description:substr::ilike', filter.project.description_substr__ilike, class="rs_input_field") %]
[% HTML.escape(cvar_cfg.description) %][% INCLUDE 'common/render_cvar_filter_input.html' cvar_cfg=cvar_cfg cvar_class="rs_input_field" %]

-- 2.20.1