From 4bbbee3aa19296af310bcb753a3e44baf364be39 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Mon, 1 Jul 2013 22:35:48 +0200 Subject: [PATCH] Finish migration to new button handling. You can now define in your datatables template which buttons to show on top and which to show per row while defining an arbitrary action for it. Buttons with name "Delete" pop up a confirm dialog automatically. --- lib/NGCP/Panel/Controller/Billing.pm | 4 ---- lib/NGCP/Panel/Controller/Domain.pm | 1 - lib/NGCP/Panel/Controller/NCOS.pm | 4 ---- lib/NGCP/Panel/Controller/Peering.pm | 2 -- lib/NGCP/Panel/Controller/Rewrite.pm | 4 ---- share/templates/billing/fees.tt | 1 - share/templates/billing/peaktimes.tt | 11 +++++++++-- share/templates/billing/zones.tt | 1 - share/templates/domain/list.tt | 11 ++++++++--- share/templates/domain/preferences.tt | 4 ++++ share/templates/helpers/datatables.tt | 3 ++- share/templates/ncos/list.tt | 12 +++++++----- share/templates/ncos/pattern_list.tt | 15 ++++++++++----- share/templates/peering/list.tt | 2 -- share/templates/peering/preferences.tt | 4 ++-- share/templates/peering/servers_rules.tt | 4 ---- share/templates/reseller/list.tt | 9 ++++++++- share/templates/rewrite/rules_list.tt | 7 +++++-- share/templates/rewrite/set_list.tt | 11 +++++++---- 19 files changed, 62 insertions(+), 48 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Billing.pm b/lib/NGCP/Panel/Controller/Billing.pm index 885282f082..ee00dfbd57 100644 --- a/lib/NGCP/Panel/Controller/Billing.pm +++ b/lib/NGCP/Panel/Controller/Billing.pm @@ -33,8 +33,6 @@ sub profile_list :Chained('/') :PathPart('billing') :CaptureArgs(0) { my $profiles_rs = $self->$dispatch_to($c); $c->stash(profiles_rs => $profiles_rs); - $c->stash(has_edit => 1); - $c->stash(has_delete => 0); $c->stash(template => 'billing/list.tt'); } @@ -134,7 +132,6 @@ sub create :Chained('profile_list') :PathPart('create') :Args(0) { sub fees_list :Chained('base') :PathPart('fees') :CaptureArgs(0) { my ($self, $c) = @_; - $c->stash(has_edit => 1); $c->stash(template => 'billing/fees.tt'); } @@ -318,7 +315,6 @@ sub zones_list :Chained('base') :PathPart('zones') :CaptureArgs(0) { $c->uri_for_action('/billing/zones', [$c->req->captures->[0]]) ); - $c->stash(has_edit => 0); $c->stash(template => 'billing/zones.tt'); } diff --git a/lib/NGCP/Panel/Controller/Domain.pm b/lib/NGCP/Panel/Controller/Domain.pm index c5a8cec9ae..1e4e15c5ae 100644 --- a/lib/NGCP/Panel/Controller/Domain.pm +++ b/lib/NGCP/Panel/Controller/Domain.pm @@ -15,7 +15,6 @@ sub auto :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRol sub dom_list :Chained('/') :PathPart('domain') :CaptureArgs(0) { my ($self, $c) = @_; - $c->stash(has_edit => 0); $c->stash(template => 'domain/list.tt'); } diff --git a/lib/NGCP/Panel/Controller/NCOS.pm b/lib/NGCP/Panel/Controller/NCOS.pm index 4deaa5c8d6..6d910057c4 100644 --- a/lib/NGCP/Panel/Controller/NCOS.pm +++ b/lib/NGCP/Panel/Controller/NCOS.pm @@ -21,8 +21,6 @@ sub levels_list :Chained('/') :PathPart('ncos') :CaptureArgs(0) { my $levels_rs = $self->$dispatch_to($c); $c->stash(levels_rs => $levels_rs); - $c->stash(has_edit => 1); - $c->stash(has_delete => 1); $c->stash(template => 'ncos/list.tt'); } @@ -157,8 +155,6 @@ sub pattern_list :Chained('base') :PathPart('pattern') :CaptureArgs(0) { return; } - $c->stash(has_edit => 1); - $c->stash(has_delete => 1); $c->stash(template => 'ncos/pattern_list.tt'); } diff --git a/lib/NGCP/Panel/Controller/Peering.pm b/lib/NGCP/Panel/Controller/Peering.pm index 3edc735856..95c651dc26 100644 --- a/lib/NGCP/Panel/Controller/Peering.pm +++ b/lib/NGCP/Panel/Controller/Peering.pm @@ -20,8 +20,6 @@ sub group_list :Chained('/') :PathPart('peering') :CaptureArgs(0) { NGCP::Panel::Utils::check_redirect_chain(c => $c); - $c->stash(has_edit => 1); - $c->stash(has_delete => 1); $c->stash(template => 'peering/list.tt'); } diff --git a/lib/NGCP/Panel/Controller/Rewrite.pm b/lib/NGCP/Panel/Controller/Rewrite.pm index d22a32376b..46c337f7d3 100644 --- a/lib/NGCP/Panel/Controller/Rewrite.pm +++ b/lib/NGCP/Panel/Controller/Rewrite.pm @@ -16,8 +16,6 @@ sub auto :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRol sub set_list :Chained('/') :PathPart('rewrite') :CaptureArgs(0) { my ( $self, $c ) = @_; - $c->stash(has_edit => 1); - $c->stash(has_delete => 1); $c->stash(template => 'rewrite/set_list.tt'); } @@ -119,8 +117,6 @@ sub rules_list :Chained('set_base') :PathPart('rules') :CaptureArgs(0) { $c->stash(rules_rs => $rules_rs); $c->stash(rules_uri => $c->uri_for_action("/rewrite/rules_root", [$c->req->captures->[0]])); - $c->stash(has_edit => 1); - $c->stash(has_delete => 1); $c->stash(template => 'rewrite/rules_list.tt'); } diff --git a/share/templates/billing/fees.tt b/share/templates/billing/fees.tt index 6b59c70ef0..436517d068 100644 --- a/share/templates/billing/fees.tt +++ b/share/templates/billing/fees.tt @@ -10,7 +10,6 @@ helper.create_flag = create_flag; helper.edit_flag = edit_fee_flag; helper.form_object = form; - helper.has_edit = has_edit; helper.ajax_uri = c.uri_for_action('/billing/fees_ajax', [c.req.captures.0]); helper.tmpuri = c.uri_for( profile.id, 'fees'); diff --git a/share/templates/billing/peaktimes.tt b/share/templates/billing/peaktimes.tt index 63c61a2854..2e05a612a8 100644 --- a/share/templates/billing/peaktimes.tt +++ b/share/templates/billing/peaktimes.tt @@ -58,12 +58,19 @@ helper.create_flag = peaktimes_special_createflag; helper.edit_flag = peaktimes_special_editflag; - helper.has_edit = 1; helper.ajax_uri = c.uri_for_action("/billing/peaktime_specials_ajax", [c.req.captures.0]); - helper.base_uri = c.uri_for(c.req.captures.0, "peaktimes","date"); helper.form_object = peaktimes_special_form; helper.close_target = close_target; + helper.tmpuri = c.uri_for(c.req.captures.0, "peaktimes","date"); + helper.dt_buttons = [ + { name = 'Edit', uri = helper.tmpuri _ "/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' }, + { name = 'Delete', uri = helper.tmpuri _ "/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' }, + ]; + helper.top_buttons = [ + { name = 'Create Special Off-Peak Date', uri = helper.tmpuri _ "/create", icon = 'icon-star' }, + ]; + PROCESS 'helpers/datatables.tt'; -%] diff --git a/share/templates/billing/zones.tt b/share/templates/billing/zones.tt index c108f787b8..517a09909b 100644 --- a/share/templates/billing/zones.tt +++ b/share/templates/billing/zones.tt @@ -9,7 +9,6 @@ helper.create_flag = create_flag; helper.edit_flag = edit_fee_flag; helper.form_object = form; - helper.has_edit = has_edit; helper.ajax_uri = c.uri_for_action( '/billing/zones_ajax',[c.req.captures.0] ); helper.tmpuri = c.uri_for( profile.id, 'zones'); diff --git a/share/templates/domain/list.tt b/share/templates/domain/list.tt index 7bebb0aaea..bd5a79e8f6 100644 --- a/share/templates/domain/list.tt +++ b/share/templates/domain/list.tt @@ -10,10 +10,15 @@ helper.create_flag = create_flag; helper.edit_flag = edit_flag; helper.form_object = form; - helper.has_edit = has_edit; helper.ajax_uri = c.uri_for( c.controller.action_for('ajax') ); - helper.base_uri = c.uri_for( c.controller.action_for("") ); - helper.extra_buttons = [["Preferences", "preferences"]]; + + helper.dt_buttons = [ + { name = 'Delete', uri = "/domain/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' }, + { name = 'Preferences', uri = "/domain/'+full[0]+'/preferences", class = 'btn-small btn-tertiary', icon = 'icon-list' }, + ]; + helper.top_buttons = [ + { name = 'Create Domain', uri = c.uri_for('/domain/create'), icon = 'icon-star' }, + ]; PROCESS 'helpers/datatables.tt'; -%] diff --git a/share/templates/domain/preferences.tt b/share/templates/domain/preferences.tt index 9d6aae6a8b..5c4d6e879d 100644 --- a/share/templates/domain/preferences.tt +++ b/share/templates/domain/preferences.tt @@ -11,6 +11,10 @@ helper.form = form; helper.base_uri = c.uri_for(domain.id,'preferences'); + helper.top_buttons = [ + { name = 'Back', uri = c.uri_for(), icon = 'icon-arrow-left' }, + ]; + PROCESS 'helpers/pref_table.tt'; %] diff --git a/share/templates/helpers/datatables.tt b/share/templates/helpers/datatables.tt index d9e1fe1063..19e94ea12b 100644 --- a/share/templates/helpers/datatables.tt +++ b/share/templates/helpers/datatables.tt @@ -28,7 +28,8 @@ $(document).ready(function() { return '' + '
' [% FOR button IN helper.dt_buttons -%] - + '' + + [% confirm_delete = 'data-confirm="Delete"' IF button.name == "Delete" -%] + + '' + ' [% button.name %]' + '' [% END -%] diff --git a/share/templates/ncos/list.tt b/share/templates/ncos/list.tt index 69fcfcdaff..4a0076d7fc 100644 --- a/share/templates/ncos/list.tt +++ b/share/templates/ncos/list.tt @@ -9,13 +9,15 @@ helper.create_flag = create_flag; helper.edit_flag = edit_flag; helper.form_object = form; - helper.has_edit = has_edit; - helper.has_delete = has_delete; helper.ajax_uri = c.uri_for_action( "/ncos/ajax" ); - helper.base_uri = c.uri_for_action( "/ncos/root" ); - helper.extra_buttons = [ - [ 'Patterns', 'pattern'], + helper.dt_buttons = [ + { name = 'Edit', uri = "/ncos/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' }, + { name = 'Delete', uri = "/ncos/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' }, + { name = 'Patterns', uri = "/ncos/'+full[0]+'/pattern", class = 'btn-small btn-tertiary', icon = 'icon-list' }, + ]; + helper.top_buttons = [ + { name = 'Create NCOS Level', uri = c.uri_for('/ncos/create'), icon = 'icon-star' }, ]; PROCESS 'helpers/datatables.tt'; diff --git a/share/templates/ncos/pattern_list.tt b/share/templates/ncos/pattern_list.tt index 330296c428..e4b4608ab2 100644 --- a/share/templates/ncos/pattern_list.tt +++ b/share/templates/ncos/pattern_list.tt @@ -1,7 +1,5 @@ [% site_config.title = 'Number Patterns for ' _ level_result.level -%] -< Back - [% helper.name = 'Number Pattern'; helper.messages = messages; @@ -12,10 +10,17 @@ helper.create_flag = create_flag; helper.edit_flag = edit_flag; helper.form_object = form; - helper.has_edit = has_edit; - helper.has_delete = has_delete; helper.ajax_uri = c.uri_for_action( "/ncos/pattern_ajax", [c.req.captures.0] ); - helper.base_uri = c.uri_for_action( "/ncos/pattern_root", [c.req.captures.0] ); + + helper.tmpuri = c.uri_for_action( "/ncos/pattern_root", [c.req.captures.0] ) + helper.dt_buttons = [ + { name = 'Edit', uri = helper.tmpuri _ "/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' }, + { name = 'Delete', uri = helper.tmpuri _ "/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' }, + ]; + helper.top_buttons = [ + { name = 'Back', uri = c.uri_for(), icon = 'icon-arrow-left' }, + { name = 'Create Pattern Entry', uri = c.uri_for_action( "/ncos/pattern_root", [c.req.captures.0] ) _ "/create", icon = 'icon-star' }, + ]; PROCESS 'helpers/datatables.tt'; -%] diff --git a/share/templates/peering/list.tt b/share/templates/peering/list.tt index 79933eca13..ee3aeb6eed 100644 --- a/share/templates/peering/list.tt +++ b/share/templates/peering/list.tt @@ -9,8 +9,6 @@ helper.create_flag = create_flag; helper.edit_flag = edit_flag; helper.form_object = form; - helper.has_edit = has_edit; - helper.has_delete = has_delete; helper.ajax_uri = c.uri_for_action( "/peering/ajax" ); helper.dt_buttons = [ diff --git a/share/templates/peering/preferences.tt b/share/templates/peering/preferences.tt index 1120be088f..51ad5d3dd4 100644 --- a/share/templates/peering/preferences.tt +++ b/share/templates/peering/preferences.tt @@ -12,10 +12,10 @@ [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' }, + { name = 'Edit', uri = c.uri_for_action("/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' }, + { name = 'Back', uri = c.uri_for(group.id, "servers"), icon = 'icon-arrow-left' }, ]; PROCESS 'helpers/pref_table.tt'; diff --git a/share/templates/peering/servers_rules.tt b/share/templates/peering/servers_rules.tt index 987a1d8583..96af4a4867 100644 --- a/share/templates/peering/servers_rules.tt +++ b/share/templates/peering/servers_rules.tt @@ -9,8 +9,6 @@ helper.create_flag = servers_create_flag; helper.edit_flag = servers_edit_flag; helper.form_object = servers_form; - helper.has_edit = 1; - helper.has_delete = 1; helper.ajax_uri = c.uri_for_action( "/peering/servers_ajax", [c.req.captures.0] ); helper.tmpuri = c.uri_for_action("/peering/servers_root", [c.req.captures.0]); @@ -36,8 +34,6 @@ helper.create_flag = rules_create_flag; helper.edit_flag = rules_edit_flag; helper.form_object = rules_form; - helper.has_edit = 1; - helper.has_delete = 1; helper.ajax_uri = c.uri_for_action( "/peering/rules_ajax", [c.req.captures.0] ); helper.tmpuri = c.uri_for(group.id, "rules"); diff --git a/share/templates/reseller/list.tt b/share/templates/reseller/list.tt index 5b1acaf4f0..3cf6162974 100644 --- a/share/templates/reseller/list.tt +++ b/share/templates/reseller/list.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 = "/reseller/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' }, + { name = 'Delete', uri = "/domain/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' }, + ]; + helper.top_buttons = [ + { name = 'Create Reseller', uri = c.uri_for('/reseller/create'), icon = 'icon-star' }, + ]; PROCESS 'helpers/datatables.tt'; -%] diff --git a/share/templates/rewrite/rules_list.tt b/share/templates/rewrite/rules_list.tt index 14adff0aa2..01bc7dd84c 100644 --- a/share/templates/rewrite/rules_list.tt +++ b/share/templates/rewrite/rules_list.tt @@ -1,9 +1,12 @@ [% site_config.title = 'Rewrite Rules for ' _ set_result.name -%] -< Back - [% IF messages -%] diff --git a/share/templates/rewrite/set_list.tt b/share/templates/rewrite/set_list.tt index d1e84880a3..e0f838eec8 100644 --- a/share/templates/rewrite/set_list.tt +++ b/share/templates/rewrite/set_list.tt @@ -9,13 +9,16 @@ helper.create_flag = create_flag; helper.edit_flag = edit_flag; helper.form_object = form; - helper.has_edit = has_edit; - helper.has_delete = has_delete; helper.ajax_uri = c.uri_for_action( "/rewrite/set_ajax" ); helper.base_uri = c.uri_for_action( "/rewrite/set_root" ); - helper.extra_buttons = [ - [ 'Rules', 'rules'], + helper.dt_buttons = [ + { name = 'Edit', uri = "/rewrite/'+full[0]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' }, + { name = 'Delete', uri = "/rewrite/'+full[0]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' }, + { name = 'Rules', uri = "/rewrite/'+full[0]+'/rules", class = 'btn-small btn-tertiary', icon = 'icon-list' }, + ]; + helper.top_buttons = [ + { name = 'Create Rewrite Rule Set', uri = c.uri_for('/rewrite/create'), icon = 'icon-star' }, ]; PROCESS 'helpers/datatables.tt';