make preferences table

but keep preference form for now
agranig/1_0_subfix
Gerhard Jungwirth 12 years ago
parent 0b706763c2
commit b7a582c87a

@ -161,14 +161,29 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) {
return;
}
my $rs = $c->model('provisioning')->resultset('voip_preferences');
my @pref_rows = $rs->all();
$c->stash(pref_rows => \@pref_rows);
$c->stash(template => 'domain/preferences.tt');
}
sub preference_form :Chained('base') :PathPart('preferences_form') :Args(0) {
my ($self, $c) = @_;
unless ( defined($c->stash->{'domain_result'}) ) {
return;
}
my $rs = $c->model('provisioning')->resultset('voip_preferences');
my $pref_form = NGCP::Panel::Form::Preferences->new({pref_rs => $rs});
$pref_form->readonly(1);
$pref_form->create_my_fields();
$pref_form->process();
$c->stash(pref_form => $pref_form);
$c->stash(template => 'domain/preferences.tt');
$c->stash(template => 'domain/preference_form.tt');
}
=head1 AUTHOR

@ -13,6 +13,9 @@ sub build_render_list {[qw/fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has 'pref_rs' => (is => 'rw');
has 'readonly' => (is => 'rw',
isa => 'Int',
default => 0,);
sub create_my_fields {
my $self = shift;
@ -20,30 +23,44 @@ sub create_my_fields {
my @field_list = ();
foreach my $preference ($self->pref_rs->all) {
my $field_type;
if($preference->data_type eq "string") {
$field_type = "Text";
} elsif ($preference->data_type eq "boolean") {
$field_type = "Boolean";
} else {
$field_type = "Boolean";
}
if($preference->max_occur == 0) {
$field_type = "Select";
}
has_field $preference->attribute => (
type => $field_type,
element_attr => { title => encode_entities($preference->description) }
);
$self->create_one_field($preference);
push @field_list, $preference->attribute;
}
$self->create_structure(\@field_list);
}
sub create_structure {
my $self = shift;
my $field_list = shift;
has_block 'fields' => (
tag => 'div',
#class => [qw/modal-body/],
render_list => \@field_list,
#class => [qw/accordion/],
render_list => $field_list,
);
}
sub create_one_field {
my $self = shift;
my $preference = shift;
my $field_type;
if($preference->data_type eq "string") {
$field_type = "Text";
} elsif ($preference->data_type eq "boolean") {
$field_type = "Boolean";
} else {
$field_type = "Boolean";
}
if($preference->max_occur == 0) {
$field_type = "Select";
}
has_field $preference->attribute => (
type => $field_type,
element_attr => { title => encode_entities($preference->description),
$self->readonly ? (readonly => 1) : (), },
);
}

@ -0,0 +1,5 @@
[% META title = 'Domain Preferences (Backup)' -%]
[% pref_form.render() %]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -1,5 +1,8 @@
[% META title = 'Domain Preferences' -%]
[% pref_form.render() %]
[% helper.name = 'Domain'; -%]
[% helper.rows = c.stash.pref_rows; -%]
[% PROCESS 'helpers/pref_table.tt' -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -0,0 +1,42 @@
<table class="table table-bordered table-striped table-highlight table-hover" id="preferences_table">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Description</th>
[% # one for actions -%]
<th class="span3"></th>
</tr>
</thead>
<tbody>
[% FOREACH r IN helper.rows %]
<tr class="sw_action_row">
<td>[% r.attribute %]</td>
<td>nothing yet[% %]</td>
<td>[% r.description %]</td>
<td>Edit Button here</td>
</tr>
[% END %]
</tbody>
</table>
[% IF helper.edit_preference -%]
<div id="mod_edit" class="modal hide" style="display:block">
<div class="modal-header">
<button id="mod_close" type="button" class="close">×</button>
<h3>Edit Preference</h3>
</div>
[% helper.form_object.render -%]
</div>
<script>
$(function () {
$('#mod_edit').modal({keyboard: false, backdrop: 'static'});
$('#mod_close').click(function(event) {
window.location.href="[% c.uri_for(c.stash.domain.id, 'preferences') %]";
});
});
</script>
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]
Loading…
Cancel
Save