First version of using rendering helpers.

agranig/1_0_subfix
Andreas Granig 13 years ago
parent d06c66626f
commit e7cafadcc3

@ -24,7 +24,7 @@ Catalyst Controller.
=cut
sub reseller : Path Chained('/') CaptureArgs(0) {
my ( $self, $c ) = @_;
my ($self, $c) = @_;
my $resellers = [
{id => 1, contract_id => 1, name => 'reseller 1', status => 'active'},
@ -40,7 +40,7 @@ sub reseller : Path Chained('/') CaptureArgs(0) {
sub edit : Chained('reseller') PathPart('edit') :Args(1) {
my ( $self, $c, $reseller_id ) = @_;
my ($self, $c, $reseller_id) = @_;
my $reseller;
if($c->flash->{reseller}) {
@ -59,6 +59,11 @@ sub edit : Chained('reseller') PathPart('edit') :Args(1) {
$c->stash(edit => $reseller);
}
sub create : Chained('reseller') PathPart('create') :Args(0) {
my ($self, $c) = @_;
$c->response->redirect($c->uri_for('/reseller'));
}
sub save : Path('/reseller/save') :Args(1) {
my ($self, $c, $reseller_id) = @_;
@ -80,7 +85,13 @@ sub save : Path('/reseller/save') :Args(1) {
}
sub delete : Path('/reseller/delete') :Args(1) {
my ( $self, $c, $reseller_id) = @_;
my ($self, $c, $reseller_id) = @_;
$c->response->redirect($c->uri_for('/reseller'));
}
sub search : Path('/reseller/search') :Args(0) {
my ($self, $c) = @_;
$c->response->redirect($c->uri_for('/reseller'));
}
=head1 AUTHOR

@ -0,0 +1,52 @@
<div class="row">
<a class="btn btn-primary btn-large" href="[% c.uri_for_action("/${helper.controller}/create") %]"><i class="icon-star"></i> Create [% helper.name %]</a>
<a class="btn btn-primary btn-large" href="[% c.uri_for_action("/${helper.controller}/search") %]"><i class="icon-search"></i> Search [% helper.name %]</a>
</div>
<div class="row">
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
[% FOREACH t IN helper.column_titles -%]
<th>[% t %]</th>
[% END -%]
[% # one for actions -%]
<th></th>
</tr>
</thead>
<tbody>
[% FOREACH set IN helper.data -%]
<tr class="sw_action_row">
[% FOREACH field IN helper.column_fields -%]
<td>[% set.$field %]</td>
[% END -%]
<td class="span3">
<div class="sw_actions pull-right">
<a class="btn btn-small btn-primary" href="[% c.uri_for_action("/${helper.controller}/edit", set.id) %]"><i class="icon-edit" style="line-height:1em;margin-top:2px"></i> Edit</a>
<a class="btn btn-small btn-secondary" href="[% c.uri_for_action("/${helper.controller}/delete", set.id) %]" data-confirm="Delete"><i class="icon-trash" style="line-height:1em;margin-top:2px"></i> Delete</a>
</div>
</td>
</tr>
[% END -%]
</tbody>
</table>
</div>
[% IF helper.edit_object -%]
<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 [% helper.form_title %]</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("/${helper.controller}") %]";
});
});
</script>
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -1,55 +1,14 @@
[% META title = 'Resellers' -%]
<div class="row">
<a class="btn btn-primary btn-large" data-toggle="modal" href="#mod_create" ><i class="icon-star"></i> Create Reseller</a>
<a href="#" class="btn btn-primary btn-large"><i class="icon-search"></i> Search Reseller</a>
</div>
<div class="row">
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Contract #</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
[% FOREACH r IN resellers -%]
<tr class="sw_action_row">
<td>[% r.id %]</td>
<td>[% r.name %]</td>
<td>[% r.contract_id %]</td>
<td>[% r.status %]</td>
<td class="span3">
<div class="sw_actions pull-right">
<a class="btn btn-small btn-primary" href="[% c.uri_for_action('/reseller/edit', r.id) %]"><i class="icon-edit" style="line-height:1em;margin-top:2px"></i> Edit</a>
<a class="btn btn-small btn-secondary" href="[% c.uri_for_action('/reseller/delete', r.id) %]" data-confirm="Delete"><i class="icon-trash" style="line-height:1em;margin-top:2px"></i> Delete</a>
</div>
</td>
</tr>
[% END -%]
</tbody>
</table>
</div>
[%
helper.name = 'Reseller';
helper.controller = 'reseller';
helper.data = resellers;
helper.column_titles = [ '#', 'Name', 'Contract #', 'Status' ];
helper.column_fields = [ 'id', 'name', 'contract_id', 'status' ];
[% IF edit.defined -%]
<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 Reseller</h3>
</div>
[% form.render %]
</div>
<script>
$(function () {
$('#mod_edit').modal({keyboard: false, backdrop: 'static'});
$('#mod_close').click(function(event) {
window.location.href="[% c.uri_for('/reseller') %]";
});
});
</script>
[% END -%]
helper.edit_object = edit;
helper.form_object = form;
PROCESS 'helpers/table_form.tt';
-%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save