Revision b48939fe
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpec.pm | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use parent qw(SL::Controller::Base); |
6 | 6 |
|
7 |
use SL::ClientJS; |
|
7 | 8 |
use SL::Controller::Helper::GetModels; |
8 | 9 |
use SL::Controller::Helper::Paginated; |
9 | 10 |
use SL::Controller::Helper::Sorted; |
... | ... | |
23 | 24 |
); |
24 | 25 |
|
25 | 26 |
__PACKAGE__->run_before('setup'); |
26 |
__PACKAGE__->run_before('load_requirement_spec', only => [ qw( edit update show destroy) ]); |
|
27 |
__PACKAGE__->run_before('load_select_options', only => [ qw(new edit create update list) ]); |
|
28 |
__PACKAGE__->run_before('load_search_select_options', only => [ qw( list) ]); |
|
27 |
__PACKAGE__->run_before('load_requirement_spec', only => [ qw( ajax_edit update show destroy) ]);
|
|
28 |
__PACKAGE__->run_before('load_select_options', only => [ qw(new ajax_edit create update list) ]);
|
|
29 |
__PACKAGE__->run_before('load_search_select_options', only => [ qw( list) ]);
|
|
29 | 30 |
|
30 | 31 |
__PACKAGE__->get_models_url_params('flat_filter'); |
31 | 32 |
__PACKAGE__->make_paginated( |
... | ... | |
68 | 69 |
sub action_new { |
69 | 70 |
my ($self) = @_; |
70 | 71 |
|
71 |
$self->{requirement_spec} = SL::DB::RequirementSpec->new;
|
|
72 |
$self->render('requirement_spec/form', title => t8('Create a new requirement spec'));
|
|
72 |
$self->requirement_spec(SL::DB::RequirementSpec->new);
|
|
73 |
$self->render('requirement_spec/new', title => t8('Create a new requirement spec'));
|
|
73 | 74 |
} |
74 | 75 |
|
75 |
sub action_edit { |
|
76 |
sub action_ajax_edit {
|
|
76 | 77 |
my ($self) = @_; |
77 |
$self->render('requirement_spec/form', title => t8('Edit requirement spec')); |
|
78 |
|
|
79 |
$self->render('requirement_spec/_form', { layout => 0 }, submit_as => 'ajax'); |
|
78 | 80 |
} |
79 | 81 |
|
80 | 82 |
sub action_show { |
... | ... | |
89 | 91 |
sub action_create { |
90 | 92 |
my ($self) = @_; |
91 | 93 |
|
92 |
$self->{requirement_spec} = SL::DB::RequirementSpec->new;
|
|
94 |
$self->requirement_spec(SL::DB::RequirementSpec->new);
|
|
93 | 95 |
$self->create_or_update; |
94 | 96 |
} |
95 | 97 |
|
... | ... | |
101 | 103 |
sub action_destroy { |
102 | 104 |
my ($self) = @_; |
103 | 105 |
|
104 |
if (eval { $self->{requirement_spec}->delete; 1; }) {
|
|
106 |
if (eval { $self->requirement_spec->delete; 1; }) {
|
|
105 | 107 |
flash_later('info', t8('The requirement spec has been deleted.')); |
106 | 108 |
} else { |
107 | 109 |
flash_later('error', t8('The requirement spec is in use and cannot be deleted.')); |
... | ... | |
135 | 137 |
|
136 | 138 |
sub load_requirement_spec { |
137 | 139 |
my ($self) = @_; |
138 |
$self->{requirement_spec} = SL::DB::RequirementSpec->new(id => $::form->{id})->load || die "No such requirement spec";
|
|
140 |
$self->requirement_spec(SL::DB::RequirementSpec->new(id => $::form->{id})->load || die "No such requirement spec");
|
|
139 | 141 |
} |
140 | 142 |
|
141 | 143 |
sub load_select_options { |
... | ... | |
163 | 165 |
|
164 | 166 |
sub create_or_update { |
165 | 167 |
my $self = shift; |
166 |
my $is_new = !$self->{requirement_spec}->id;
|
|
168 |
my $is_new = !$self->requirement_spec->id;
|
|
167 | 169 |
my $params = delete($::form->{requirement_spec}) || { }; |
168 | 170 |
my $title = $is_new ? t8('Create a new requirement spec') : t8('Edit requirement spec'); |
169 | 171 |
|
170 |
$self->{requirement_spec}->assign_attributes(%{ $params });
|
|
172 |
$self->requirement_spec->assign_attributes(%{ $params });
|
|
171 | 173 |
|
172 |
my @errors = $self->{requirement_spec}->validate;
|
|
174 |
my @errors = $self->requirement_spec->validate;
|
|
173 | 175 |
|
174 | 176 |
if (@errors) { |
177 |
return SL::ClientJS->new->error(@errors)->render($self) if $::request->is_ajax; |
|
178 |
|
|
175 | 179 |
flash('error', @errors); |
176 |
$self->render('requirement_spec/form', title => $title);
|
|
180 |
$self->render('requirement_spec/new', title => $title);
|
|
177 | 181 |
return; |
178 | 182 |
} |
179 | 183 |
|
180 |
$self->{requirement_spec}->save; |
|
184 |
$self->requirement_spec->save; |
|
185 |
|
|
186 |
if ($::request->is_ajax) { |
|
187 |
my $html = $self->render('requirement_spec/_header', { output => 0 }); |
|
188 |
return SL::ClientJS->new |
|
189 |
->replaceWith('#requirement-spec-header', $html) |
|
190 |
->flash('info', t8('The requirement spec has been saved.')) |
|
191 |
->render($self); |
|
192 |
} |
|
181 | 193 |
|
182 | 194 |
flash_later('info', $is_new ? t8('The requirement spec has been created.') : t8('The requirement spec has been saved.')); |
183 |
$self->redirect_to(action => 'list');
|
|
195 |
$self->redirect_to(action => 'show', id => $self->requirement_spec->id);
|
|
184 | 196 |
} |
185 | 197 |
|
186 | 198 |
sub setup_db_args_from_filter { |
... | ... | |
214 | 226 |
my @sortable = qw(title customer status type projectnumber); |
215 | 227 |
|
216 | 228 |
my %column_defs = ( |
217 |
title => { obj_link => sub { $self->url_for(action => 'edit', id => $_[0]->id, callback => $callback) } },
|
|
229 |
title => { obj_link => sub { $self->url_for(action => 'show', id => $_[0]->id, callback => $callback) } },
|
|
218 | 230 |
customer => { raw_data => sub { $self->presenter->customer($_[0]->customer, display => 'table-cell', callback => $callback) }, |
219 | 231 |
sub => sub { $_[0]->customer->name } }, |
220 | 232 |
projectnumber => { raw_data => sub { $self->presenter->project($_[0]->project, display => 'table-cell', callback => $callback) }, |
js/requirement_spec.js | ||
---|---|---|
1 |
/* Functions used for the requirement specs tree view */ |
|
1 |
/* Functions used for the requirement specs */ |
|
2 |
|
|
3 |
// ----------------------------------------------------------------------------- |
|
4 |
// ------------------------------ basic settings ------------------------------- |
|
5 |
// ----------------------------------------------------------------------------- |
|
6 |
|
|
7 |
function basic_settings_customer_changed(customer_ctrl, value_ctrl) { |
|
8 |
$.get( |
|
9 |
'controller.pl?action=Customer/get_hourly_rate', |
|
10 |
{ id: $(customer_ctrl).val() }, |
|
11 |
function(data) { if (data.hourly_rate_formatted) $(value_ctrl).val(data.hourly_rate_formatted); } |
|
12 |
); |
|
13 |
} |
|
2 | 14 |
|
3 | 15 |
// ----------------------------------------------------------------------------- |
4 | 16 |
// ------------------------------ the tree itself ------------------------------ |
locale/de/all | ||
---|---|---|
304 | 304 |
'Bank transfers via SEPA' => 'Überweisungen via SEPA', |
305 | 305 |
'Base unit' => 'Basiseinheit', |
306 | 306 |
'Basic Data' => 'Basisdaten', |
307 |
'Basic settings' => 'Grundeinstellungen', |
|
307 | 308 |
'Batch Printing' => 'Druck', |
308 | 309 |
'Bcc' => 'Bcc', |
309 | 310 |
'Bcc E-mail' => 'BCC (E-Mail)', |
templates/webpages/requirement_spec/_form.html | ||
---|---|---|
1 |
[%- USE LxERP -%][%- USE L -%] |
|
2 |
[%- DEFAULT id_prefix = 'basic_settings_form' |
|
3 |
submit_as = 'post' |
|
4 |
%] |
|
5 |
<form method="post" action="controller.pl" id="[% id_prefix %]"> |
|
6 |
[% L.hidden_tag("id", SELF.requirement_spec.id, id=id_prefix _ '_id') %] |
|
7 |
|
|
8 |
<table class="rs_input_field"> |
|
9 |
<tr> |
|
10 |
<td>[% LxERP.t8("Title") %]</td> |
|
11 |
<td>[% L.input_tag("requirement_spec.title", SELF.requirement_spec.title, id=id_prefix _ '_title') %]</td> |
|
12 |
</tr> |
|
13 |
|
|
14 |
<tr> |
|
15 |
<td>[% LxERP.t8("Requirement Spec Type") %]</td> |
|
16 |
<td>[% L.select_tag("requirement_spec.type_id", SELF.types, default=SELF.requirement_spec.type_id, title_key="description", id=id_prefix _ '_type_id') %]</td> |
|
17 |
</tr> |
|
18 |
|
|
19 |
<tr> |
|
20 |
<td>[% LxERP.t8("Requirement Spec Status") %]</td> |
|
21 |
<td>[% L.select_tag("requirement_spec.status_id", SELF.statuses, default=SELF.requirement_spec.status_id, title_key="description", id=id_prefix _ '_status_id') %]</td> |
|
22 |
</tr> |
|
23 |
|
|
24 |
<tr> |
|
25 |
<td>[% LxERP.t8("Customer") %]</td> |
|
26 |
<td>[% L.select_tag("requirement_spec.customer_id", SELF.customers, default=SELF.requirement_spec.customer_id, title_key="name", id=id_prefix _ '_customer_id', |
|
27 |
onchange="basic_settings_customer_changed('#" _ id_prefix _ "_customer_id', '#" _ id_prefix _ "_hourly_rate_as_number')") %]</td> |
|
28 |
</tr> |
|
29 |
|
|
30 |
<tr> |
|
31 |
<td>[% LxERP.t8("Hourly Rate") %]</td> |
|
32 |
<td>[% L.input_tag(form_prefix _ "hourly_rate_as_number", SELF.requirement_spec.hourly_rate_as_number, id=id_prefix _ '_hourly_rate_as_number') %]</td> |
|
33 |
</tr> |
|
34 |
|
|
35 |
</table> |
|
36 |
|
|
37 |
<p> |
|
38 |
[% IF submit_as == 'post' %] |
|
39 |
[% L.hidden_tag("action", "RequirementSpec/dispatch", id=id_prefix _ '_action') %] |
|
40 |
[% L.submit_tag("action_" _ (SELF.requirement_spec.id ? "update" : "create"), LxERP.t8('Save'), id=id_prefix _ '_action_update') %] |
|
41 |
[%- IF SELF.requirement_spec.id %] |
|
42 |
[% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?'), id=id_prefix _ '_action_destroy') %] |
|
43 |
[%- END %] |
|
44 |
<a href="[% SELF.url_for(action="list") %]">[% LxERP.t8('Abort') %]</a> |
|
45 |
[% ELSE %] |
|
46 |
[% L.button_tag("submit_ajax_form('controller.pl?action=RequirementSpec/update', '#" _ id_prefix _ "')", LxERP.t8("Save")) %] |
|
47 |
[% L.button_tag("submit_ajax_form('controller.pl?action=RequirementSpec/destroy', '#" _ id_prefix _ "')", LxERP.t8("Delete"), confirm=LxERP.t8("Do you really want to delete this object?")) %] |
|
48 |
[% END %] |
|
49 |
</p> |
|
50 |
</form> |
templates/webpages/requirement_spec/_header.html | ||
---|---|---|
1 |
[%- USE HTML -%][%- USE LxERP -%] |
|
2 |
<div id="requirement-spec-header"> |
|
3 |
<h1> |
|
4 |
[%- HTML.escape(SELF.requirement_spec.displayable_name('format', 'with_customer')) %] |
|
5 |
[% LxERP.t8("for") %] |
|
6 |
[% HTML.escape(SELF.requirement_spec.customer.displayable_name) -%] |
|
7 |
</h1> |
|
8 |
</div> |
templates/webpages/requirement_spec/form.html | ||
---|---|---|
1 |
[% USE HTML %][% USE L %][% USE LxERP %] |
|
2 |
|
|
3 |
<form method="post" action="controller.pl"> |
|
4 |
<div class="listtop">[% FORM.title %]</div> |
|
5 |
|
|
6 |
[%- INCLUDE 'common/flash.html' %] |
|
7 |
|
|
8 |
<table class="rs_input_field"> |
|
9 |
<tr> |
|
10 |
<td>[% LxERP.t8("Title") %]</td> |
|
11 |
<td>[% L.input_tag("requirement_spec.title", SELF.requirement_spec.description) %]</td> |
|
12 |
</tr> |
|
13 |
|
|
14 |
<tr> |
|
15 |
<td>[% LxERP.t8("Requirement Spec Type") %]</td> |
|
16 |
<td>[% L.select_tag("requirement_spec.type_id", SELF.types, default=SELF.requirement_spec.type_id, title_key="description") %]</td> |
|
17 |
</tr> |
|
18 |
|
|
19 |
<tr> |
|
20 |
<td>[% LxERP.t8("Requirement Spec Status") %]</td> |
|
21 |
<td>[% L.select_tag("requirement_spec.status_id", SELF.statuses, default=SELF.requirement_spec.status_id, title_key="description") %]</td> |
|
22 |
</tr> |
|
23 |
|
|
24 |
<tr> |
|
25 |
<td>[% LxERP.t8("Customer") %]</td> |
|
26 |
<td>[% L.select_tag("requirement_spec.customer_id", SELF.customers, default=SELF.requirement_spec.customer_id, title_key="name", id="customer_id") %]</td> |
|
27 |
</tr> |
|
28 |
|
|
29 |
<tr> |
|
30 |
<td>[% LxERP.t8("Hourly Rate") %]</td> |
|
31 |
<td>[% L.input_tag("requirement_spec.hourly_rate_as_number", SELF.requirement_spec.hourly_rate_as_number, id="hourly_rate") %]</td> |
|
32 |
</tr> |
|
33 |
|
|
34 |
</table> |
|
35 |
|
|
36 |
<p> |
|
37 |
[% L.hidden_tag("id", SELF.requirement_spec.id) %] |
|
38 |
[% L.hidden_tag("action", "RequirementSpec/dispatch") %] |
|
39 |
[% L.submit_tag("action_" _ (SELF.requirement_spec.id ? "update" : "create"), LxERP.t8('Save')) %] |
|
40 |
[%- IF SELF.requirement_spec.id %] |
|
41 |
[% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) %] |
|
42 |
[%- END %] |
|
43 |
<a href="[% SELF.url_for(action="list") %]">[% LxERP.t8('Abort') %]</a> |
|
44 |
</p> |
|
45 |
</form> |
|
46 |
|
|
47 |
<script type="text/javascript"> |
|
48 |
<!-- |
|
49 |
function on_customer_changed() { |
|
50 |
$.ajax({ |
|
51 |
url: 'controller.pl?action=Customer/get_hourly_rate', |
|
52 |
dataType: "json", |
|
53 |
data: { id: $("#customer_id").attr('value') }, |
|
54 |
success: function(data) { if (data["hourly_rate"] > 0) $("#hourly_rate").attr("value", data["hourly_rate_formatted"]); } |
|
55 |
}); |
|
56 |
} |
|
57 |
|
|
58 |
$(document).ready(function() { |
|
59 |
$("#customer_id").change(on_customer_changed); |
|
60 |
}); |
|
61 |
--> |
|
62 |
</script> |
templates/webpages/requirement_spec/new.html | ||
---|---|---|
1 |
<h1>[% FORM.title %]</h1> |
|
2 |
|
|
3 |
[%- INCLUDE 'common/flash.html' %] |
|
4 |
|
|
5 |
[%- INCLUDE 'requirement_spec/_form.html' %] |
templates/webpages/requirement_spec/show.html | ||
---|---|---|
2 | 2 |
|
3 | 3 |
[%- INCLUDE 'common/flash.html' %] |
4 | 4 |
|
5 |
<h1>[%- HTML.escape(SELF.requirement_spec.displayable_name('format', 'with_customer')) %] |
|
6 |
[% LxERP.t8("for") %] |
|
7 |
[% HTML.escape(SELF.requirement_spec.customer.displayable_name) -%] |
|
8 |
</h1> |
|
5 |
[%- INCLUDE 'requirement_spec/_header.html' %] |
|
9 | 6 |
|
10 | 7 |
[%- L.hidden_tag('requirement_spec_id', SELF.requirement_spec.id) -%] |
11 | 8 |
|
12 |
<div id="requirement_spec_version"> |
|
13 |
[%- INCLUDE 'requirement_spec/_version.html' requirement_spec=SELF.requirement_spec -%] |
|
14 |
</div> |
|
15 |
|
|
16 |
<div id="column-container"> |
|
17 |
<div id="tree-column"> |
|
18 |
<div id="tree"></div> |
|
19 |
</div> |
|
9 |
<div class="tabwidget"> |
|
10 |
<ul> |
|
11 |
<li><a href="#function-blocks-tab">[%- LxERP.t8("Content") %]</a></li> |
|
12 |
<li><a href="controller.pl?action=RequirementSpec/ajax_edit&id=[% HTML.url(SELF.requirement_spec.id) %]">[%- LxERP.t8("Basic settings") %]</a></li> |
|
13 |
</ul> |
|
20 | 14 |
|
21 |
<div id="content-column" class="clearfix"> |
|
22 |
[% L.hidden_tag('current_content_type', SELF.requirement_spec_item.id ? 'section' : '') %] |
|
23 |
[% L.hidden_tag('current_content_id', SELF.requirement_spec_item.id) %] |
|
15 |
<div id="function-blocks-tab"> |
|
16 |
<div id="requirement_spec_version"> |
|
17 |
[%- INCLUDE 'requirement_spec/_version.html' requirement_spec=SELF.requirement_spec -%] |
|
18 |
</div> |
|
24 | 19 |
|
25 |
<div id="column-content"> |
|
26 |
[%- IF SELF.requirement_spec_item -%] |
|
27 |
[%- INCLUDE 'requirement_spec_item/_section.html' requirement_spec_item=SELF.requirement_spec_item -%] |
|
28 |
[%- ELSE -%] |
|
29 |
[%- INCLUDE 'requirement_spec_item/_no_section.html' -%] |
|
30 |
[%- END -%] |
|
20 |
<div id="column-container" class="clearfix"> |
|
21 |
<div id="tree-column"> |
|
22 |
<div id="tree"></div> |
|
23 |
</div> |
|
24 |
|
|
25 |
<div id="content-column" class="clearfix"> |
|
26 |
[% L.hidden_tag('current_content_type', SELF.requirement_spec_item.id ? 'section' : '') %] |
|
27 |
[% L.hidden_tag('current_content_id', SELF.requirement_spec_item.id) %] |
|
28 |
|
|
29 |
<div id="column-content"> |
|
30 |
[%- IF SELF.requirement_spec_item -%] |
|
31 |
[%- INCLUDE 'requirement_spec_item/_section.html' requirement_spec_item=SELF.requirement_spec_item -%] |
|
32 |
[%- ELSE -%] |
|
33 |
[%- INCLUDE 'requirement_spec_item/_no_section.html' -%] |
|
34 |
[%- END -%] |
|
35 |
</div> |
|
36 |
</div> |
|
31 | 37 |
</div> |
32 | 38 |
</div> |
33 | 39 |
</div> |
Auch abrufbar als: Unified diff
Pflichtenhefte: show & Bearbeiten in eigenen Tab