Revision f24b365c
Von Sven Schöling vor mehr als 7 Jahren hinzugefügt
SL/Controller/PriceSource.pm | ||
---|---|---|
87 | 87 |
|
88 | 88 |
$class = 'SL::DB::' . $class; |
89 | 89 |
|
90 |
my %translated_methods = ( |
|
91 |
'SL::DB::OrderItem' => { |
|
92 |
id => 'parts_id', |
|
93 |
orderitems_id => 'id', |
|
94 |
}, |
|
95 |
'SL::DB::DeliveryOrderItem' => { |
|
96 |
id => 'parts_id', |
|
97 |
delivery_order_items_id => 'id', |
|
98 |
}, |
|
99 |
'SL::DB::InvoiceItem' => { |
|
100 |
id => 'parts_id', |
|
101 |
invoice_id => 'id', |
|
102 |
}, |
|
103 |
); |
|
104 |
|
|
90 | 105 |
eval "require $class"; |
91 | 106 |
|
92 | 107 |
my $obj = $::form->{"orderitems_id_$row"} |
93 | 108 |
? $class->meta->convention_manager->auto_manager_class_name->find_by(id => $::form->{"orderitems_id_$row"}) |
94 | 109 |
: $class->new; |
95 | 110 |
|
96 |
for my $method (apply { s/_$row$// } grep { /_$row$/ } keys %$::form) { |
|
111 |
for my $key (grep { /_$row$/ } keys %$::form) { |
|
112 |
my $method = $key; |
|
113 |
$method =~ s/_$row$//; |
|
114 |
$method = $translated_methods{$class}{$method} // $method; |
|
115 |
my $value = $::form->{$key}; |
|
97 | 116 |
if ($obj->meta->column($method)) { |
98 | 117 |
if ($obj->meta->column($method)->isa('Rose::DB::Object::Metadata::Column::Date')) { |
99 |
$obj->${\"$method\_as_date"}($::form->{"$method\_$row"});
|
|
118 |
$obj->${\"$method\_as_date"}($value);
|
|
100 | 119 |
} elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::(?:Numeric|Float|DoublePrecsion)$/) { |
101 |
$obj->${\"$method\_as_number"}($::form->{"$method\_$row"});
|
|
120 |
$obj->${\"$method\_as_number"}($value);
|
|
102 | 121 |
} elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::Boolean$/) { |
103 |
$obj->$method(!!$::form->{$method});
|
|
122 |
$obj->$method(!!$value);
|
|
104 | 123 |
} else { |
105 |
$obj->$method($::form->{"$method\_$row"});
|
|
124 |
$obj->$method($value);
|
|
106 | 125 |
} |
107 | 126 |
} else { |
108 |
$obj->{__additional_form_attributes}{$method} = $::form->{"$method\_$row"};
|
|
127 |
$obj->{__additional_form_attributes}{$method} = $value;
|
|
109 | 128 |
} |
110 | 129 |
} |
111 | 130 |
|
Auch abrufbar als: Unified diff
PriceSource Controller: parts_id/orderitems_id translation