A subadmin can use the field alias_select to select any number of alias numbers, which he is allowed to manage. If he selects one, it moves to this subscribers alias_numbers. If he unselects one, it moves to his own alias numbers.gjungwirth/fix_tests
							parent
							
								
									5e5fbeeda6
								
							
						
					
					
						commit
						2c7a0c4e6b
					
				| @ -0,0 +1,48 @@ | ||||
| package NGCP::Panel::Form::Customer::PbxExtensionSubscriberEditSubadmin; | ||||
| 
 | ||||
| use HTML::FormHandler::Moose; | ||||
| use NGCP::Panel::Field::PosInteger; | ||||
| extends 'NGCP::Panel::Form::Customer::PbxExtensionSubscriberEdit'; | ||||
| 
 | ||||
| has_field 'alias_select' => ( | ||||
|     type => '+NGCP::Panel::Field::DataTable', | ||||
|     label => 'Numbers', | ||||
|     do_label => 0, | ||||
|     do_wrapper => 0, | ||||
|     required => 0, | ||||
|     template => 'helpers/datatables_multifield.tt', | ||||
|     ajax_src => '/invalid', | ||||
|     table_titles => ['#', 'Number', 'Subscriber'], | ||||
|     table_fields => ['id', 'number', 'subscriber_username'], | ||||
| ); | ||||
| 
 | ||||
| has_block 'fields' => ( | ||||
|     tag => 'div', | ||||
|     class => [qw/modal-body/], | ||||
|     render_list => [qw/group extension display_name webusername webpassword password status external_id alias_select/ ], | ||||
| ); | ||||
| 
 | ||||
| 1; | ||||
| 
 | ||||
| =head1 NAME | ||||
| 
 | ||||
| NGCP::Panel::Form::Customer::PbxExtensionSubscriberEditSubadmin | ||||
| 
 | ||||
| =head1 DESCRIPTION | ||||
| 
 | ||||
| Form to modify a subscriber. | ||||
| 
 | ||||
| =head1 METHODS | ||||
| 
 | ||||
| =head1 AUTHOR | ||||
| 
 | ||||
| Gerhard Jungwirth | ||||
| 
 | ||||
| =head1 LICENSE | ||||
| 
 | ||||
| This library is free software. You can redistribute it and/or modify | ||||
| it under the same terms as Perl itself. | ||||
| 
 | ||||
| =cut | ||||
| 
 | ||||
| # vim: set tabstop=4 expandtab: | ||||
| @ -0,0 +1,48 @@ | ||||
| package NGCP::Panel::Form::Customer::PbxExtensionSubscriberEditSubadminNoGroup; | ||||
| 
 | ||||
| use HTML::FormHandler::Moose; | ||||
| use NGCP::Panel::Field::PosInteger; | ||||
| extends 'NGCP::Panel::Form::Customer::PbxSubscriber'; | ||||
| 
 | ||||
| has_field 'alias_select' => ( | ||||
|     type => '+NGCP::Panel::Field::DataTable', | ||||
|     label => 'Numbers', | ||||
|     do_label => 0, | ||||
|     do_wrapper => 0, | ||||
|     required => 0, | ||||
|     template => 'helpers/datatables_multifield.tt', | ||||
|     ajax_src => '/invalid', | ||||
|     table_titles => ['#', 'Number', 'Subscriber'], | ||||
|     table_fields => ['id', 'number', 'subscriber_username'], | ||||
| ); | ||||
| 
 | ||||
| has_block 'fields' => ( | ||||
|     tag => 'div', | ||||
|     class => [qw/modal-body/], | ||||
|     render_list => [qw/display_name webusername webpassword password status external_id alias_select/ ], | ||||
| ); | ||||
| 
 | ||||
| 1; | ||||
| 
 | ||||
| =head1 NAME | ||||
| 
 | ||||
| NGCP::Panel::Form::Customer::PbxExtensionSubscriberEditSubadmin | ||||
| 
 | ||||
| =head1 DESCRIPTION | ||||
| 
 | ||||
| Form to modify a subscriber. | ||||
| 
 | ||||
| =head1 METHODS | ||||
| 
 | ||||
| =head1 AUTHOR | ||||
| 
 | ||||
| Gerhard Jungwirth | ||||
| 
 | ||||
| =head1 LICENSE | ||||
| 
 | ||||
| This library is free software. You can redistribute it and/or modify | ||||
| it under the same terms as Perl itself. | ||||
| 
 | ||||
| =cut | ||||
| 
 | ||||
| # vim: set tabstop=4 expandtab: | ||||
| @ -0,0 +1,96 @@ | ||||
| <!-- datatables_multifield --> | ||||
| <script type="text/javascript"> | ||||
| 
 | ||||
| var checked_fields = {}; | ||||
| $(document).ready(function() { | ||||
|      | ||||
|     JSON.parse('[% value %]').map( function (val) { | ||||
|         checked_fields[val] = 1; | ||||
|     }); | ||||
|     $('#[% table_id %] tr td input[type="checkbox"]').live( "click", function() { | ||||
|      | ||||
|         var my_id = $(this).parents("tr").find("td:first").text(); | ||||
|         if($(this).attr("checked") == "checked") { | ||||
|             checked_fields[my_id] = 1; | ||||
|         } else { | ||||
|             delete checked_fields[my_id]; | ||||
|         } | ||||
|         $("#[% hidden_id %]").val( JSON.stringify(Object.keys(checked_fields)) ); | ||||
|      | ||||
|     }); | ||||
| 
 | ||||
| 	$('#[% table_id %]') | ||||
| 	    .dataTable( { | ||||
|         "sDom": "<'row-fluid'<'pull-left'r><'pull-right'f>>t<'row-fluid'<'pull-left'i><'pull-right'p>>", | ||||
| 		"bProcessing": true, | ||||
| 		"bServerSide": true, | ||||
| 		"bPaginate": true, | ||||
|         "sPaginationType": "bootstrap", | ||||
| 		"bLengthChange": false, | ||||
| 		"bSort": true, | ||||
| 		"bInfo": true, | ||||
| 		"iDisplayLength": 4, | ||||
|         'iShowPages': 5, | ||||
| 		"sAjaxSource": "[% ajax_src %]", | ||||
| 		 | ||||
| 		"aoColumns": [ | ||||
|                         [% FOREACH f IN table_fields -%] | ||||
| 		    		    {  | ||||
|                            "mData": "[% f %]", | ||||
|                            "mRender": function ( data, type, full ) { | ||||
|                                 if(data == null) | ||||
|                                     return ''; | ||||
|                                 return String(data).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); | ||||
|                             } | ||||
|                         }, | ||||
|                         [% END -%] | ||||
| 		    		    { "mRender": function ( data, type, full ) { | ||||
|                                 return '<input type="checkbox" value="' + full.id + '"/>'; | ||||
|                             }, | ||||
|                           "mData": null, | ||||
|                           "bSortable": false | ||||
|                         } | ||||
| 		], | ||||
|         "fnRowCallback": function(nRow, aData, iDisplayIndex) { | ||||
|             nRow.className = "sw_action_row"; | ||||
|             if($(nRow).find("td:first").text() in checked_fields) | ||||
|             { | ||||
|                 $(nRow).find("td input[type='checkbox']").attr("checked", "checked"); | ||||
|             } | ||||
|             return nRow; | ||||
|         }, | ||||
|         "fnServerParams": function ( aoData ) { | ||||
|             //aoData.push( {"name":"iIdOnTop","value":"[% value %]"} ); | ||||
|         }, | ||||
| 	} ); | ||||
| 
 | ||||
| } ); | ||||
| </script> | ||||
| 
 | ||||
| <div class="control-group [% IF errors.size %]error[% END %]"> | ||||
|      <label class="control-label" for="[% table_id %]">[% label %]</label> | ||||
|      <div class="controls"> | ||||
|          <input type="hidden" name="[% field_name %]" value="[% value | html %]" id="[% hidden_id %]"/> | ||||
|          <table class="table table-bordered table-striped table-highlight table-hover" id="[% table_id %]"> | ||||
|             <thead> | ||||
|                 <tr> | ||||
|                     [% FOREACH t IN table_titles %] | ||||
|                         <th>[% t %]</th> | ||||
|                     [% END %] | ||||
|                     <th class="span"></th> | ||||
|                 </tr> | ||||
|             </thead> | ||||
|             <tbody> | ||||
|                 <tr class="sw_action_row"> | ||||
|                     <td>Loading</td> | ||||
|                 </tr> | ||||
|             </tbody> | ||||
|         </table> | ||||
|         [% IF errors.size -%] | ||||
|         <span class="help-inline"> | ||||
|             [% errors.join('<br/>') %] | ||||
|         </span> | ||||
|         [% END -%] | ||||
|     </div> | ||||
| </div> | ||||
| [% # vim: set tabstop=4 syntax=html expandtab: -%] | ||||
					Loading…
					
					
				
		Reference in new issue