Updated UI to handle object structure for list allowed values

This commit is contained in:
rpidikiti
2011-10-19 16:08:27 -07:00
parent 010b3c130a
commit b3b8dffba3
6 changed files with 89 additions and 9 deletions

View File

@@ -80,7 +80,7 @@
{{if required == false }}
%option{:value => "", :selected => 'selected'}
{{/if}}
{{each allowableValues}}
{{each allowableValues.values}}
{{if $value == defaultValue && required == true }}
%option{:value => "${$value}", :selected => 'selected'} ${$value}
{{else}}

View File

@@ -219,17 +219,57 @@ function SwaggerService(baseUrl, _apiKey, statusCallback) {
if (atts) this.load(atts);
this.name = this.name || this.dataType;
if(this.allowableValues){
var value = this.allowableValues;
if(value.valueType == "LIST"){
this.allowableValues = AllowableListValues.sub();
} else if (value.valueType == "RANGE"){
this.allowableValues = AllowableRangeValues.sub();
}
if (value) this.allowableValues = this.allowableValues.create(value);
}
},
toString: function() {
if (this.allowableValues && this.allowableValues.length > 0)
return this.name + ": " + this.dataType + " [" + this.allowableValues + "]";
if (this.allowableValues)
return this.name + ": " + this.dataType + " " + this.allowableValues;
else
return this.name + ": " + this.dataType;
}
});
var AllowableListValues = Spine.Model.setup("AllowableListValues", ["valueType", "values"]);
AllowableListValues.include({
init: function(atts) {
if (atts) this.load(atts);
this.name = "allowableValues";
},
toString: function() {
if (this.values)
return "["+this.values+"]";
else
return "";
}
});
var AllowableRangeValues = Spine.Model.setup("AllowableRangeValues", ["valueType", "inclusive", "min", "max"]);
AllowableRangeValues.include({
init: function(atts) {
if (atts) this.load(atts);
this.name = "allowableValues";
},
toString: function() {
if (this.min && this.max)
return "[" + min + "," + max + "]";
else
return "";
}
});
// Model: ApiModel
var ApiModel = Spine.Model.setup("ApiModel", ["id", "fields"]);
ApiModel.include({

View File

@@ -237,7 +237,7 @@ jQuery(function($) {
templateName: function(){
var n = "#paramTemplate";
if (this.allowableValues && this.allowableValues.length > 0) {
if (this.allowableValues && this.allowableValues.valueType == "LIST") {
n += "Select";
} else {
if (this.required) n += "Required";