Part 1 of making template buttons more flexible.

agranig/1_0_subfix
Andreas Granig 13 years ago
parent 8245329a76
commit 490c38ab9e

@ -11,7 +11,14 @@
helper.edit_flag = edit_flag;
helper.form_object = form;
helper.ajax_uri = c.uri_for( c.controller.action_for('ajax') );
helper.base_uri = c.uri_for( c.controller.action_for("") );
helper.dt_buttons = [
{ name = 'Edit', uri = "/administrator/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
{ name = 'Delete', uri = "/administrator/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
];
helper.top_buttons = [
{ name = 'Create Administrator', uri = c.uri_for('/administrator/create'), icon = 'icon-star' },
];
PROCESS 'helpers/datatables.tt';
-%]

@ -11,7 +11,14 @@
helper.edit_flag = edit_flag;
helper.form_object = form;
helper.ajax_uri = c.uri_for( c.controller.action_for('ajax') );
helper.base_uri = c.uri_for( c.controller.action_for("") );
helper.dt_buttons = [
{ name = 'Edit', uri = "/contact/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
{ name = 'Delete', uri = "/contact/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
];
helper.top_buttons = [
{ name = 'Create Contact', uri = c.uri_for('/contact/create'), icon = 'icon-star' },
];
PROCESS 'helpers/datatables.tt';
-%]

@ -11,7 +11,15 @@
helper.edit_flag = edit_flag;
helper.form_object = form;
helper.ajax_uri = c.uri_for('/contract/customer/ajax');
helper.base_uri = c.uri_for('/contract');
helper.dt_buttons = [
{ name = 'Edit', uri = "/contract/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
{ name = 'Delete', uri = "/contract/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
{ name = 'Details', uri = "/customer/'+full[0]+'/details", class = 'btn-small btn-tertiary' },
];
helper.top_buttons = [
{ name = 'Create Customer', uri = c.uri_for('/customer/create'), icon = 'icon-star' },
];
PROCESS 'helpers/datatables.tt';
-%]

@ -26,26 +26,13 @@ $(document).ready(function() {
[% END -%]
{ "mRender": function ( data, type, full ) {
return '' +
'<div class="sw_actions pull-right">' +
[%- IF helper.has_edit != 0 %]
'<a class="btn btn-small btn-primary" href="[% helper.base_uri %]/' + full[0] + '/edit">' +
'<i class="icon-edit"></i> Edit' +
'</a>' +
[%- END %]
[%- IF helper.has_delete != 0 %]
'<a class="btn btn-small btn-secondary" href="[% helper.base_uri %]/' + full[0] + '/delete" data-confirm="Delete">' +
'<i class="icon-trash"></i> Delete' +
'</a>' +
[%- END %]
[%- IF helper.extra_buttons.size %]
[% FOR b IN helper.extra_buttons %]
'<a class="btn btn-small btn-tertiary" href="[% helper.base_uri %]/' + full[0] + '/' +
'[% b.1 %]' + '">' +
'[% b.0 %]' +
'</a>' +
[% END %]
[% END %]
'</div>';
'<div class="sw_actions pull-right">'
[% FOR button IN helper.dt_buttons -%]
+ '<a class="btn [% button.class %]" href="[% button.uri %]">' +
'<i class="[% button.icon %]"></i> [% button.name %]' +
'</a>'
[% END -%]
+ '</div>';
},
"mData": null,
"bSortable": false,
@ -70,7 +57,11 @@ $(document).ready(function() {
<div class="row">
<a class="btn btn-primary btn-large" href="[% helper.base_uri _ '/create' %]"><i class="icon-star"></i> Create [% helper.name %]</a>
[% FOR button IN helper.top_buttons -%]
<span>
<a class="btn btn-primary btn-large" href="[% button.uri %]"><i class="[% button.icon %]"></i> [% button.name %]</a>
</span>
[% END -%]
</div>
[% IF helper.messages -%]
<div class="row">

@ -1,4 +1,10 @@
<a href="[% c.uri_for() %]">&lt; Back</a>
<div class="row">
[% FOR button IN helper.top_buttons -%]
<span>
<a class="btn btn-primary btn-large" href="[% button.uri %]"><i class="[% button.icon %]"></i> [% button.name %]</a>
</span>
[% END -%]
</div>
[% IF helper.messages -%]
<div class="row">

@ -12,10 +12,14 @@
helper.has_edit = has_edit;
helper.has_delete = has_delete;
helper.ajax_uri = c.uri_for_action( "/peering/ajax" );
helper.base_uri = c.uri_for_action( "/peering/root" );
helper.extra_buttons = [
[ 'Peering Servers/Rules', 'servers'],
helper.dt_buttons = [
{ name = 'Edit', uri = "/peering/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
{ name = 'Delete', uri = "/peering/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
{ name = 'Details', uri = "/peering/'+full[0]+'/servers", class = 'btn-small btn-tertiary', icon = 'icon-list' },
];
helper.top_buttons = [
{ name = 'Create Peering Group', uri = c.uri_for('/peering/create'), icon = 'icon-star' },
];
PROCESS 'helpers/datatables.tt';

@ -1,7 +1,6 @@
[% site_config.title = 'Peer Host "' _ server.name _ '" Preferences' -%]
[%
#helper.name = 'Domain';
helper.messages = messages;
helper.edit_preference = edit_preference;
@ -12,6 +11,13 @@
helper.base_uri = c.uri_for_action("/peering/servers_preferences_root",
[c.req.captures.0, c.req.captures.1]);
helper.dt_buttons = [
{ name = 'Edit', uri = "/peering/servers_preferences_root/" _ c.req.captures.0 _ "/" _ c.req.captures.1, class = 'btn-small btn-primary', icon = 'icon-edit' },
];
helper.top_buttons = [
{ name = 'Back', uri = "/peering/" _ c.req.captures.0 _ "/servers/", icon = 'icon-arrow-left' },
];
PROCESS 'helpers/pref_table.tt';
%]

@ -12,10 +12,14 @@
helper.has_edit = 1;
helper.has_delete = 1;
helper.ajax_uri = c.uri_for_action( "/peering/servers_ajax", [c.req.captures.0] );
helper.base_uri = c.uri_for_action( "/peering/servers_root", [c.req.captures.0] );
helper.extra_buttons = [
[ 'Preferences', 'preferences'],
helper.dt_buttons = [
{ name = 'Edit', uri = "/peering/" _ c.req.captures.0 _ "/servers/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
{ name = 'Delete', uri = "/peering/" _ c.req.captures.0 _ "/servers/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
{ name = 'Preferences', uri = "/peering/" _ c.req.captures.0 _ "/servers/'+full[0]+'/preferences", class = 'btn-small btn-tertiary', icon = 'icon-list' },
];
helper.top_buttons = [
{ name = 'Create Peering Server', uri = "/peering/" _ c.req.captures.0 _ "/servers/create", icon = 'icon-star' },
];
PROCESS 'helpers/datatables.tt';
@ -34,10 +38,15 @@
helper.has_edit = 1;
helper.has_delete = 1;
helper.ajax_uri = c.uri_for_action( "/peering/rules_ajax", [c.req.captures.0] );
helper.base_uri = c.uri_for( group.id, "rules" );
helper.extra_buttons = undef;
helper.dt_buttons = [
{ name = 'Edit', uri = "/peering/" _ c.req.captures.0 _ "/rules/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
{ name = 'Delete', uri = "/peering/" _ c.req.captures.0 _ "/rules/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
];
helper.top_buttons = [
{ name = 'Create Peering Rule', uri = "/peering/" _ c.req.captures.0 _ "/rules/create", icon = 'icon-star' },
];
PROCESS 'helpers/datatables.tt';
-%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save