Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fe1af881

Von Werner Hahn vor 12 Monaten hinzugefügt

  • ID fe1af8816f286395369d96d3f4fb17f725aee55f
  • Vorgänger cd076a15
  • Nachfolger 89821947

VariantProperty: EIgenschaft anlegen

Unterschiede anzeigen:

SL/Controller/VariantProperty.pm
my ($self) = @_;
$self->_setup_list_action_bar;
$self->render('variant_property/list',
$self->render('variant_property/variant_property_list',
title => t8('Variant Property'),
VARIANTPROPERTIES => SL::DB::Manager::VariantProperty->get_all_sorted,
);
......
my $is_new = !$self->variant_property->id;
$self->_setup_form_action_bar;
$self->render('variant_property/variant_propertie_form', title => ($is_new ? t8('Add Variant Property') : t8('Edit Variant Property')));
$self->render('variant_property/variant_property_form', title => ($is_new ? t8('Add Variant Property') : t8('Edit Variant Property')));
}
sub action_save_property {
my ($self) = @_;
$self->create_or_update;
$self->create_or_update_property;
}
sub action_delete_property {
......
} else {
flash_later('error', $::locale->text('The shop is in use and cannot be deleted.'));
};
$self->redirect_to(action => 'list');
$self->redirect_to(action => 'list_properties');
}
sub action_reorder_properties {
......
#
sub init_variant_property {
SL::DB::Manager::VariantProperty::find_by_or_create(id => $::form->{id} || 0)->assign_attributes(%{ $::form->{variant_property} });
SL::DB::Manager::VariantProperty->find_by_or_create(id => $::form->{id} || 0)->assign_attributes(%{ $::form->{variant_property} });
}
#
......
my @errors = $self->variant_property->validate;
if (@errors) {
flash('error', @errors);
$self->action_edit();
$self->action_edit_property();
return;
}
$self->variant_property->save;
flash_later('info', $is_new ? t8('The Variant Property has been created.') : t8('The Variant Property has been saved.'));
$self->redirect_to(action => 'list_property');
$self->redirect_to(action => 'list_properties');
}
sub _setup_form_action_bar {
SL/DB/VariantProperty.pm
__PACKAGE__->meta->initialize;
sub validate {
my ($self) = @_;
my @errors;
# critical checks
push @errors, $::locale->text('The name is missing.') unless $self->{name};
push @errors, $::locale->text('The unique name is missing.') unless $self->{unique_name};
push @errors, $::locale->text('The abbreviation is missing') unless $self->{abbreviation};
return @errors;
}
1;
templates/design40_webpages/variant_property/variant_property_list.html
</tr>
</thead>
<tbody>
[% FOREACH row = SELF.VARIANTPROPERTIES %]
[% FOREACH row = VARIANTPROPERTIES %]
<tr>
<td>[% row.name | html %]</td>
<td>[% row.unique_name | html %]</td>
<td>[% row.abbraviation | html %]</td>
<td>[% row.abbreviation | html %]</td>
</tr>
[% END %]
</tbody>

Auch abrufbar als: Unified diff