@@ -506,19 +506,40 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
506
506
if ( this . editing_json ) this . hideEditJSON ( ) ;
507
507
else this . showEditJSON ( ) ;
508
508
} ,
509
+ insertPropertyControlUsingPropertyOrder : function ( property , control , container ) {
510
+ var propertyOrder = this . schema . properties [ property ] . propertyOrder ;
511
+ if ( typeof propertyOrder !== "number" ) propertyOrder = 1000 ;
512
+ control . propertyOrder = propertyOrder ;
513
+
514
+ for ( var i = 0 ; i < container . childNodes . length ; i ++ ) {
515
+ var child = container . childNodes [ i ] ;
516
+ if ( control . propertyOrder < child . propertyOrder ) {
517
+ this . addproperty_list . insertBefore ( control , child ) ;
518
+ control = null ;
519
+ break ;
520
+ }
521
+ }
522
+ if ( control ) {
523
+ this . addproperty_list . appendChild ( control ) ;
524
+ }
525
+ } ,
509
526
addPropertyCheckbox : function ( key ) {
510
527
var self = this ;
511
- var checkbox , label , control ;
512
-
528
+ var checkbox , label , labelText , control ;
529
+
513
530
checkbox = self . theme . getCheckbox ( ) ;
514
531
checkbox . style . width = 'auto' ;
515
- label = self . theme . getCheckboxLabel ( key ) ;
532
+
533
+ labelText = this . schema . properties [ key ] . title ? this . schema . properties [ key ] . title : key ;
534
+ label = self . theme . getCheckboxLabel ( labelText ) ;
535
+
516
536
control = self . theme . getFormControl ( label , checkbox ) ;
517
537
control . style . paddingBottom = control . style . marginBottom = control . style . paddingTop = control . style . marginTop = 0 ;
518
538
control . style . height = 'auto' ;
519
539
//control.style.overflowY = 'hidden';
520
- self . addproperty_list . appendChild ( control ) ;
521
-
540
+
541
+ this . insertPropertyControlUsingPropertyOrder ( key , control , this . addproperty_list ) ;
542
+
522
543
checkbox . checked = key in this . editors ;
523
544
checkbox . addEventListener ( 'change' , function ( ) {
524
545
if ( checkbox . checked ) {
@@ -626,7 +647,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
626
647
this . _super ( editor ) ;
627
648
} ,
628
649
canHaveAdditionalProperties : function ( ) {
629
- return this . schema . additionalProperties !== false && ! this . jsoneditor . options . no_additional_properties ;
650
+ return ( this . schema . additionalProperties === true ) || ! this . jsoneditor . options . no_additional_properties ;
630
651
} ,
631
652
destroy : function ( ) {
632
653
$each ( this . cached_editors , function ( i , el ) {
@@ -666,7 +687,7 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
666
687
if ( this . adding_property ) this . refreshAddProperties ( ) ;
667
688
} ,
668
689
refreshAddProperties : function ( ) {
669
- if ( this . options . disable_properties || this . jsoneditor . options . disable_properties ) {
690
+ if ( this . options . disable_properties || ( this . options . disable_properties !== false && this . jsoneditor . options . disable_properties ) ) {
670
691
this . addproperty_controls . style . display = 'none' ;
671
692
return ;
672
693
}
@@ -726,7 +747,6 @@ JSONEditor.defaults.editors.object = JSONEditor.AbstractEditor.extend({
726
747
if ( this . cached_editors [ i ] ) continue ;
727
748
show_modal = true ;
728
749
this . addPropertyCheckbox ( i ) ;
729
- this . addproperty_checkboxes [ i ] . disabled = ! can_add ;
730
750
}
731
751
732
752
// If no editors can be added or removed, hide the modal button
0 commit comments