Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8752239e

Von Werner Hahn vor 12 Monaten hinzugefügt

  • ID 8752239e1df0eba905347bc3dfdb6a8c437edcc0
  • Vorgänger fd721cc0
  • Nachfolger 0e2a4ae8

VariantenKonfiguration: Controller und js Dateien

Unterschiede anzeigen:

SL/Controller/VariantProperty.pm
use SL::DB::Manager::VariantProperty;
use Rose::Object::MakeMethods::Generic (
'scalar --get_set_init' => [ qw(variant_property) ]
'scalar --get_set_init' => [ qw(variant_property variant_property_value) ]
);
#__PACKAGE__->run_before('check_auth');
__PACKAGE__->run_before('add_javascripts', only => [ qw(edit_property) ]);
#
# actions
......
$self->render(\'', { type => 'json' }); # ' emacs happy again
}
sub action_edit_property_value {
my ($self) = @_;
$self->render_variant_edit_dialog();
}
sub action_save_property_value {
my ($self) = @_;
$self->create_or_update_property_value;
}
sub render_variant_edit_dialog {
my ($self) = @_;
$self->js
->run(
'kivi.VariantProperty.variant_dialog',
t8('Variant Value'),
$self->render('variant_property/variant_property_value_form', { output => 0 })
)
->reinit_widgets;
$self->js->render;
}
#sub action_list_property_values_list {
# my ($self) = @_;
#
......
SL::DB::Manager::VariantProperty->find_by_or_create(id => $::form->{id} || 0)->assign_attributes(%{ $::form->{variant_property} });
}
sub init_variant_property_value {
SL::DB::Manager::VariantPropertyValue->find_by_or_create(id => $::form->{variant_property_value_id} || 0)->assign_attributes(%{ $::form->{variant_property_value} });
}
sub add_javascripts {
$::request->{layout}->add_javascripts(qw(kivi.VariantProperty.js));
}
#
# helpers
#
......
$self->redirect_to(action => 'list_properties');
}
sub create_or_update_property_value {
my ($self) = @_;
$main::lxdebug->dump(0, "TST:FORM ", $::form);
my $is_new = !$self->variant_property_value->id;
# my @errors = $self->variant_property_value->validate;
# if (@errors) {
# flash('error', @errors);
# $self->action_edit_property();
# return;
# }
$main::lxdebug->dump(0, "TST:PV ", $self->variant_property_value);
$self->variant_property_value->assign_attributes( variant_property_id => $::form->{property_value_id});
$self->variant_property_value->save;
flash_later('info', $is_new ? t8('The Variant Property Value has been created.') : t8('The Variant Property Value has been saved.'));
$self->action_edit_property();
return;
}
sub _setup_form_action_bar {
my ($self) = @_;
js/kivi.VariantProperty.js
namespace('kivi.VariantProperty', function(ns) {
var $dialog;
ns.variant_dialog = function(title, html) {
var id = 'jqueryui_popup_dialog';
var dialog_params = {
id: id,
width: 800,
height: 500,
modal: true,
close: function(event, ui) { $dialog.remove(); },
};
$('#' + id).remove();
$dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
$dialog.attr('title', title);
$dialog.html(html);
$dialog.dialog(dialog_params);
$('.cancel').click(ns.close_dialog);
return true;
};
ns.save_variant_value = function() {
var form = $('#variant_property_value_form').serializeArray();
console.log("my", form)
form.push( { name: 'action', value: 'VariantProperty/save_property_value' }
);
$.post('controller.pl', form, function(data) {
kivi.eval_json_result(data);
});
};
ns.add_or_edit_variant_value = function(id) {
$.post('controller.pl', { action: 'VariantProperty/edit_property_value', id: id }, function(data) {
kivi.eval_json_result(data);
});
};
});

Auch abrufbar als: Unified diff