create "Edit Billing" modal, make validator happy

plus add a topmenu entry for Billing
plus better align actions column
agranig/1_0_subfix
Gerhard Jungwirth 13 years ago
parent 1f73491b9c
commit 3df437082c

@ -4,7 +4,7 @@ use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller'; }
use NGCP::Panel::Form::BillingProfile;
sub list :Chained('/') :PathPart('billing') :CaptureArgs(0) :Args(0) {
my ( $self, $c ) = @_;
@ -41,7 +41,7 @@ sub base :Chained('list') :PathPart('') :CaptureArgs(1) :Args(0) {
my $res = $c->model('billing')->resultset('billing_profiles')->find($profile_id);
unless(defined($res)) {
$c->flash(messages => [{type => 'error', text => 'Domain does not exist!'}]);
$c->flash(messages => [{type => 'error', text => 'Billing Profile does not exist!'}]);
$c->response->redirect($c->uri_for());
return;
}
@ -52,6 +52,21 @@ sub base :Chained('list') :PathPart('') :CaptureArgs(1) :Args(0) {
sub edit :Chained('base') :PathPart('edit') {
my ($self, $c) = @_;
my $posted = ($c->request->method eq 'POST');
my $form = NGCP::Panel::Form::BillingProfile->new;
$form->process(
posted => 1,
params => $posted ? $c->request->params : $c->stash->{profile},
action => $c->uri_for($c->stash->{profile}->{id}, 'edit'),
);
if($posted && $form->validated) {
#do the database update here
$c->flash(messages => [{type => 'success', text => 'Billing Profile successfully changed!'}]);
$c->response->redirect($c->uri_for());
return;
}
$c->stash(form => $form);
}
__PACKAGE__->meta->make_immutable;

@ -0,0 +1,118 @@
package NGCP::Panel::Form::BillingProfile;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler';
use Moose::Util::TypeConstraints;
use HTML::FormHandler::Widget::Block::Bootstrap;
has '+widget_wrapper' => ( default => 'Bootstrap' );
sub build_render_list {[qw/fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
#has_field 'submitid' => (
# type => 'Hidden'
#);
has_field 'name' => (
type => 'Text',
required => 1,
maxlength => 31,
);
has_field 'interval_charge' => (
type => 'Money',
);
has_field 'interval_free_time' => (
type => 'Integer',
);
has_field 'interval_free_cash' => (
type => 'Money',
);
has_field 'fraud_interval_limit' => (
type => 'Integer', #TODO: ???
label => 'Fraud Monthly Limit',
);
has_field 'fraud_interval_lock' => (
type => 'Select',
label => 'Fraud Monthly Lock',
options => [
{ value => 0, label => 'none' },
{ value => 1, label => 'foreign calls' },
{ value => 2, label => 'all outgoing calls' },
{ value => 3, label => 'incoming and outgoing' },
{ value => 4, label => 'global (including CSC)' },
],
);
has_field 'fraud_interval_notify' => (
type => 'Text', #Email?
label => 'Fraud Monthly Notify',
maxlength => 255,
);
has_field 'fraud_daily_limit' => (
type => 'Integer', #???
);
has_field 'fraud_daily_lock' => (
type => 'Select',
options => [
{ value => 0, label => 'none' },
{ value => 1, label => 'foreign calls' },
{ value => 2, label => 'all outgoing calls' },
{ value => 3, label => 'incoming and outgoing' },
{ value => 4, label => 'global (including CSC)' },
],
);
has_field 'fraud_daily_notify' => (
type => 'Text', #Email?
maxlength => 255,
);
has_field 'currency' => (
type => 'Text',
maxlength => 31,
);
has_field 'vat_rate' => (
type => 'Integer',
label => 'VAT Rate',
range_start => 0,
range_end => 100,
);
has_field 'vat_included' => (
type => 'Boolean',
label => 'VAT Included',
);
has_field 'save' => (
type => 'Submit',
value => 'Save',
element_class => [qw/btn btn-primary/],
label => '',
);
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/name interval_charge interval_free_time interval_free_cash
fraud_interval_limit fraud_interval_lock fraud_interval_notify
fraud_daily_limit fraud_daily_lock fraud_daily_notify
currency vat_rate vat_included/],
);
has_block 'actions' => (
tag => 'div',
class => [qw/modal-footer/],
render_list => [qw/save/],
);
1;
# vim: set tabstop=4 expandtab:

@ -109,10 +109,10 @@
$(function () {
Theme.init ();
$('.sw_actions').hide();
$('.sw_actions').css('visibility','hidden');
$('.sw_action_row').hover(
function() { $(this).find('.sw_actions').show(); },
function() { $(this).find('.sw_actions').hide(); }
function() { $(this).find('.sw_actions').css('visibility','visible'); },
function() { $(this).find('.sw_actions').css('visibility','hidden'); }
);
$('a[data-confirm]').live("click", function(ev) {

@ -12,6 +12,11 @@
helper.has_edit = has_edit;
helper.has_preferences = has_preferences;
helper.extra_buttons = [
[ 'Edit Fees', 'fees'],
[ 'Edit Peak Times', 'peaktimes'],
];
PROCESS 'helpers/datatables.tt';
-%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -1,5 +1,4 @@
<script src="/js/libs/datatables-bootstrap-paging.js"></script>
<style>
<style scoped="scoped">
div.modal {
max-width: 816px;
width: 100%;
@ -114,7 +113,12 @@ div.modal .control-group.error .dataTables_wrapper input[type="text"] {
border: 1px solid #cccccc;
}
.actions-column { /* TODO: use responsive design */
white-space: nowrap;
}
</style>
<script src="/js/libs/datatables-bootstrap-paging.js"></script>
<script type="text/javascript">
$.extend( $.fn.dataTableExt.oStdClasses, {
@ -151,10 +155,19 @@ $(document).ready(function() {
'<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" data-confirm="Delete">' +
'<i class="icon-trash" style="line-height:1em;margin-top:2px"></i> Delete' +
'</a>' +
[%- IF helper.extra_buttons.size > 0 %]
[% FOR b IN helper.extra_buttons %]
'<a style="display:inline;line-height:16px;margin-left:5px;" class="btn btn-small btn-tertiary" href="[% c.uri_for( c.controller.action_for("") ) %]/' + full[0] + '/' +
'[% b.1 %]' + '">' +
'[% b.0 %]' +
'</a>' +
[% END %]
[% END %]
'</div>';
},
"mData": null,
"bSortable": false
"bSortable": false,
"sClass": "actions-column",
}
],
"aoColumnDefs": [
@ -170,10 +183,10 @@ $(document).ready(function() {
[%- END %]
],
"fnDrawCallback": function( oSettings ) {
$('.sw_actions').hide();
$('.sw_actions').css('visibility','hidden');
$('.sw_action_row').hover(
function() { $(this).find('.sw_actions').show(); },
function() { $(this).find('.sw_actions').hide(); }
function() { $(this).find('.sw_actions').css('visibility','visible'); },
function() { $(this).find('.sw_actions').css('visibility','hidden'); }
);
},
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
@ -206,7 +219,7 @@ $(document).ready(function() {
<th>[% t %]</th>
[% END -%]
[% # one for actions -%]
<th class="span3"></th>
<th class="actions-column"></th>
</tr>
</thead>
<tbody>

@ -83,7 +83,7 @@ body {
[% END %]
</td>
<td>
<div class="sw_actions pull-right" style="display:none;">
<div class="sw_actions pull-right" style="visibility:hidden;">
<a style="display:inline;line-height:16px;" class="btn btn-small btn-primary" href="[% c.uri_for(helper.domain_id,'preferences', r.id, 'edit') %]"><i class="icon-edit" style="line-height:1em;margin-top:2px"></i> Edit</a>
</div>
</td>

@ -7,6 +7,7 @@
<ul class="dropdown-menu">
<li><a href="[% c.uri_for('/reseller') %]">Resellers</a></li>
<li><a href="[% c.uri_for('/domain') %]">Domains</a></li>
<li><a href="[% c.uri_for('/billing') %]">Billing</a></li>
</ul>
</li>
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save