pari: trunk r360 - /trunk/config/numberplan.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Sun Feb 18 01:28:31 MST 2007


Author: pari
Date: Sun Feb 18 02:28:31 2007
New Revision: 360

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=360
Log:
Donot allow a duplicate calling rules

Modified:
    trunk/config/numberplan.html

Modified: trunk/config/numberplan.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/numberplan.html?view=diff&rev=360&r1=359&r2=360
==============================================================================
--- trunk/config/numberplan.html (original)
+++ trunk/config/numberplan.html Sun Feb 18 02:28:31 2007
@@ -60,6 +60,7 @@
 
 function add_callingrule(){
 	isnewrule = true;
+	iscustom = false;
 	$('rulename').value = "";
 	$('trunks').selectedIndex = -1 ;
 	$('pattern').value = "";
@@ -120,8 +121,6 @@
 						var commentstring = "custom";
 					}else{
 						var commentstring = "standard";
-						//build a pattern into $('pattern').value
-						buildpatternstring();
 					}
 
 					var rule_string = $('pattern').value + ',' + this_priority + ',Macro(trunkdial,${' + $('trunks').value + '}/'+ $('prepend').value +'${EXTEN:' + $('strip').value + '})' ;
@@ -156,15 +155,24 @@
 
 function saverule(){
 	if ( !checkfields() ) return false;
+	if( !iscustom){
+		buildpatternstring();
+	}
 	 if(isnewrule){ 
 					var newpriority=1;
 					var m = numberplansdata[$('extensions').value]['npdata'];
-					if( typeof m[$('pattern').value] !="undefined" ){
-						for ( var y in m[$('pattern').value] ){
-							if ( y == "extend"){break;}
-							newpriority++;
-						}
+
+					if(  m.hasOwnProperty($('pattern').value)  && m[$('pattern').value].hasOwnProperty(''+newpriority)  ) { 
+						alert("A rule for this pattern is already defined !") ; 
+						return ;
 					}
+
+//					if( typeof m[$('pattern').value] !="undefined" ){
+//						for ( var y in m[$('pattern').value] ){
+//							if ( m[$('pattern').value].hasOwnProperty( y ) ){break;}
+//							newpriority++;
+//						}
+//					}
 					add_rule_fromeditform( newpriority, oncomplete = function(){ show_npdata_table( $('extensions').value ); } );
 	 }else{	// update exiting rule
 			// delete existing rule



More information about the asterisk-gui-commits mailing list