Skip to content

Commit

Permalink
required as property list
Browse files Browse the repository at this point in the history
  • Loading branch information
lepinay authored and jdorn committed Aug 13, 2015
1 parent 54ba7d2 commit 24ccab3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ JSONEditor.AbstractEditor = Class.extend({
isEnabled: function() {
return !this.disabled;
},
isRequired: function() {
if(typeof this.schema.required === "boolean") return this.schema.required;
else if(this.parent && this.parent.schema && Array.isArray(this.parent.schema.required)) return this.parent.schema.required.indexOf(this.key) > -1;
else if(this.jsoneditor.options.required_by_default) return true;
else return false;
},
getDisplayText: function(arr) {
var disp = [];
var used = {};
Expand Down
4 changes: 2 additions & 2 deletions src/editors/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({
self.enum_values[i] = self.typecast(option);
});

if(!this.schema.required){
if(!this.isRequired()){
self.enum_display.unshift(' ');
self.enum_options.unshift('undefined');
self.enum_values.unshift(undefined);
Expand All @@ -82,7 +82,7 @@ JSONEditor.defaults.editors.select = JSONEditor.AbstractEditor.extend({
self.enum_options = ['1',''];
self.enum_values = [true,false];

if(!this.schema.required){
if(!this.isRequired()){
self.enum_display.unshift(' ');
self.enum_options.unshift('undefined');
self.enum_values.unshift(undefined);
Expand Down

0 comments on commit 24ccab3

Please sign in to comment.