design of edit/delete buttons, permission handling, bugfix

- hide edit/delete buttons and show them on hover
- show a 403 error on ../ajax urls when user is not logged in
- distinguish between totalRecords and totalDisplayRecords
- fix missing ; in Makefile.PL
agranig/1_0_subfix
Gerhard Jungwirth 13 years ago
parent f5afd4911b
commit 93968c3a11

@ -16,7 +16,7 @@ requires 'Catalyst::Action::RenderView';
requires 'Moose';
requires 'namespace::autoclean';
requires 'Config::General'; # This should reflect the config file format you've chosen
requires 'Catalyst::Helper::View::JSON'
requires 'Catalyst::Helper::View::JSON';
# See Catalyst::Plugin::ConfigLoader for supported formats
requires 'Log::Log4perl::Catalyst';
test_requires 'Test::More' => '0.88';

@ -34,12 +34,20 @@ sub auto :Private {
if($c->controller =~ /::Root\b/
or $c->controller =~ /::Login\b/) {
$c->log->debug("*** Root::auto grant access to root and login controller");
$c->log->debug("*** Root::auto grant access to " . $c->request->path);
return 1;
}
unless($c->user_exists) {
$c->log->debug("*** Root::auto user not authenticated");
# don't redirect to login page for ajax uris
if($c->request->path =~ /\/ajax$/) {
$c->response->body("403 - Permission denied");
$c->response->status(403);
return;
}
# store uri for redirect after login
my $target = undef;
if($c->request->method eq 'GET') {
@ -125,6 +133,7 @@ sub ajax_process :Private {
}
}
my $totalRecords = scalar(@$aaData);
my $totalDisplayRecords = scalar(@$data);
#Pagination
if($iDisplayStart || $iDisplayLength ) {
my $endIndex = $iDisplayLength+$iDisplayStart-1;
@ -134,7 +143,7 @@ sub ajax_process :Private {
$c->stash(aaData => $aaData,
iTotalRecords => $totalRecords,
iTotalDisplayRecords => $totalRecords);
iTotalDisplayRecords => $totalDisplayRecords);
$c->stash(sEcho => $sEcho);

@ -18,14 +18,31 @@ $(document).ready(function() {
{ "sName": "[% f %]" },
[% END -%]
{ "mRender": function ( data, type, full ) {
return '<a class="btn btn-small btn-primary" href="[% c.uri_for( c.controller.action_for("") ) %]/' +full[0]+'/edit"><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( c.controller.action_for("") ) %]/' +full[0]+'/delete"><i class="icon-trash" style="line-height:1em;margin-top:2px"></i>Delete</a>';
return '' +
'<div class="sw_actions pull-right">' +
'<a style="display:inline;line-height:16px;" class="btn btn-small btn-primary" href="[% c.uri_for( c.controller.action_for("") ) %]/' + full[0] + '/edit">' +
'<i class="icon-edit" style="line-height:1em;margin-top:2px"></i> Edit' +
'</a>' +
'<a style="display:inline;line-height:16px;margin-left:5px;" class="btn btn-small btn-secondary" href="[% c.uri_for( c.controller.action_for("") ) %]/' + full[0] + '/delete">' +
'<i class="icon-trash" style="line-height:1em;margin-top:2px"></i> Delete' +
'</a>' +
'</div>';
},
"mData": null,
"sWidth": "132px",
"bSortable": false
}
],
"fnDrawCallback": function( oSettings ) {
$('.sw_actions').hide();
$('.sw_action_row').hover(
function() { $(this).find('.sw_actions').show(); },
function() { $(this).find('.sw_actions').hide(); }
);
},
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
nRow.className = "sw_action_row";
return nRow;
},
} );
} );
@ -50,7 +67,7 @@ $(document).ready(function() {
<th>[% t %]</th>
[% END -%]
[% # one for actions -%]
<th></th>
<th class="span3"></th>
</tr>
</thead>
<tbody>

Loading…
Cancel
Save