10 |
10 |
use SL::DB::Manager::VariantProperty;
|
11 |
11 |
|
12 |
12 |
use Rose::Object::MakeMethods::Generic (
|
13 |
|
'scalar --get_set_init' => [ qw(variant_property) ]
|
|
13 |
'scalar --get_set_init' => [ qw(variant_property variant_property_value) ]
|
14 |
14 |
);
|
15 |
15 |
|
16 |
16 |
#__PACKAGE__->run_before('check_auth');
|
|
17 |
__PACKAGE__->run_before('add_javascripts', only => [ qw(edit_property) ]);
|
17 |
18 |
|
18 |
19 |
#
|
19 |
20 |
# actions
|
... | ... | |
61 |
62 |
$self->render(\'', { type => 'json' }); # ' emacs happy again
|
62 |
63 |
}
|
63 |
64 |
|
|
65 |
sub action_edit_property_value {
|
|
66 |
my ($self) = @_;
|
|
67 |
|
|
68 |
$self->render_variant_edit_dialog();
|
|
69 |
}
|
|
70 |
|
|
71 |
sub action_save_property_value {
|
|
72 |
my ($self) = @_;
|
|
73 |
|
|
74 |
$self->create_or_update_property_value;
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
sub render_variant_edit_dialog {
|
|
79 |
my ($self) = @_;
|
|
80 |
$self->js
|
|
81 |
->run(
|
|
82 |
'kivi.VariantProperty.variant_dialog',
|
|
83 |
t8('Variant Value'),
|
|
84 |
$self->render('variant_property/variant_property_value_form', { output => 0 })
|
|
85 |
)
|
|
86 |
->reinit_widgets;
|
|
87 |
|
|
88 |
$self->js->render;
|
|
89 |
}
|
|
90 |
|
64 |
91 |
#sub action_list_property_values_list {
|
65 |
92 |
# my ($self) = @_;
|
66 |
93 |
#
|
... | ... | |
87 |
114 |
SL::DB::Manager::VariantProperty->find_by_or_create(id => $::form->{id} || 0)->assign_attributes(%{ $::form->{variant_property} });
|
88 |
115 |
}
|
89 |
116 |
|
|
117 |
sub init_variant_property_value {
|
|
118 |
SL::DB::Manager::VariantPropertyValue->find_by_or_create(id => $::form->{variant_property_value_id} || 0)->assign_attributes(%{ $::form->{variant_property_value} });
|
|
119 |
}
|
|
120 |
|
|
121 |
sub add_javascripts {
|
|
122 |
$::request->{layout}->add_javascripts(qw(kivi.VariantProperty.js));
|
|
123 |
}
|
|
124 |
|
90 |
125 |
#
|
91 |
126 |
# helpers
|
92 |
127 |
#
|
... | ... | |
109 |
144 |
$self->redirect_to(action => 'list_properties');
|
110 |
145 |
}
|
111 |
146 |
|
|
147 |
sub create_or_update_property_value {
|
|
148 |
my ($self) = @_;
|
|
149 |
|
|
150 |
$main::lxdebug->dump(0, "TST:FORM ", $::form);
|
|
151 |
my $is_new = !$self->variant_property_value->id;
|
|
152 |
|
|
153 |
# my @errors = $self->variant_property_value->validate;
|
|
154 |
# if (@errors) {
|
|
155 |
# flash('error', @errors);
|
|
156 |
# $self->action_edit_property();
|
|
157 |
# return;
|
|
158 |
# }
|
|
159 |
$main::lxdebug->dump(0, "TST:PV ", $self->variant_property_value);
|
|
160 |
$self->variant_property_value->assign_attributes( variant_property_id => $::form->{property_value_id});
|
|
161 |
$self->variant_property_value->save;
|
|
162 |
|
|
163 |
flash_later('info', $is_new ? t8('The Variant Property Value has been created.') : t8('The Variant Property Value has been saved.'));
|
|
164 |
$self->action_edit_property();
|
|
165 |
return;
|
|
166 |
}
|
|
167 |
|
112 |
168 |
sub _setup_form_action_bar {
|
113 |
169 |
my ($self) = @_;
|
114 |
170 |
|
VariantenKonfiguration: Controller und js Dateien