Updated UI to handle object structure for list allowed values
This commit is contained in:
@@ -123,7 +123,7 @@
|
|||||||
{{if required == false }}
|
{{if required == false }}
|
||||||
<option selected='selected' value=''></option>
|
<option selected='selected' value=''></option>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{each allowableValues}}
|
{{each allowableValues.values}}
|
||||||
{{if $value == defaultValue && required == true}}
|
{{if $value == defaultValue && required == true}}
|
||||||
<option selected='selected' value='${$value}'>${$value}</option>
|
<option selected='selected' value='${$value}'>${$value}</option>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ function SwaggerService(baseUrl, _apiKey, statusCallback) {
|
|||||||
this.path_xml = this.path.replace("{format}", "xml");
|
this.path_xml = this.path.replace("{format}", "xml");
|
||||||
this.baseUrl = apiHost;
|
this.baseUrl = apiHost;
|
||||||
//execluded 9 letters to remove .{format} from name
|
//execluded 9 letters to remove .{format} from name
|
||||||
this.name = this.path.substr(1, this.path.length - formatString.length - 1);
|
this.name = this.path.substr(1, this.path.length - formatString.length - 1).replace(/\//g, "_");
|
||||||
this.apiList = Api.sub();
|
this.apiList = Api.sub();
|
||||||
this.modelList = ApiModel.sub();
|
this.modelList = ApiModel.sub();
|
||||||
},
|
},
|
||||||
@@ -219,17 +219,57 @@ function SwaggerService(baseUrl, _apiKey, statusCallback) {
|
|||||||
if (atts) this.load(atts);
|
if (atts) this.load(atts);
|
||||||
|
|
||||||
this.name = this.name || this.dataType;
|
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() {
|
toString: function() {
|
||||||
if (this.allowableValues && this.allowableValues.length > 0)
|
if (this.allowableValues)
|
||||||
return this.name + ": " + this.dataType + " [" + this.allowableValues + "]";
|
return this.name + ": " + this.dataType + " " + this.allowableValues;
|
||||||
else
|
else
|
||||||
return this.name + ": " + this.dataType;
|
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
|
// Model: ApiModel
|
||||||
var ApiModel = Spine.Model.setup("ApiModel", ["id", "fields"]);
|
var ApiModel = Spine.Model.setup("ApiModel", ["id", "fields"]);
|
||||||
ApiModel.include({
|
ApiModel.include({
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ jQuery(function($) {
|
|||||||
templateName: function(){
|
templateName: function(){
|
||||||
var n = "#paramTemplate";
|
var n = "#paramTemplate";
|
||||||
|
|
||||||
if (this.allowableValues && this.allowableValues.length > 0) {
|
if (this.allowableValues && this.allowableValues.valueType == "LIST") {
|
||||||
n += "Select";
|
n += "Select";
|
||||||
} else {
|
} else {
|
||||||
if (this.required) n += "Required";
|
if (this.required) n += "Required";
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
{{if required == false }}
|
{{if required == false }}
|
||||||
%option{:value => "", :selected => 'selected'}
|
%option{:value => "", :selected => 'selected'}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{each allowableValues}}
|
{{each allowableValues.values}}
|
||||||
{{if $value == defaultValue && required == true }}
|
{{if $value == defaultValue && required == true }}
|
||||||
%option{:value => "${$value}", :selected => 'selected'} ${$value}
|
%option{:value => "${$value}", :selected => 'selected'} ${$value}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|||||||
@@ -219,17 +219,57 @@ function SwaggerService(baseUrl, _apiKey, statusCallback) {
|
|||||||
if (atts) this.load(atts);
|
if (atts) this.load(atts);
|
||||||
|
|
||||||
this.name = this.name || this.dataType;
|
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() {
|
toString: function() {
|
||||||
if (this.allowableValues && this.allowableValues.length > 0)
|
if (this.allowableValues)
|
||||||
return this.name + ": " + this.dataType + " [" + this.allowableValues + "]";
|
return this.name + ": " + this.dataType + " " + this.allowableValues;
|
||||||
else
|
else
|
||||||
return this.name + ": " + this.dataType;
|
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
|
// Model: ApiModel
|
||||||
var ApiModel = Spine.Model.setup("ApiModel", ["id", "fields"]);
|
var ApiModel = Spine.Model.setup("ApiModel", ["id", "fields"]);
|
||||||
ApiModel.include({
|
ApiModel.include({
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ jQuery(function($) {
|
|||||||
templateName: function(){
|
templateName: function(){
|
||||||
var n = "#paramTemplate";
|
var n = "#paramTemplate";
|
||||||
|
|
||||||
if (this.allowableValues && this.allowableValues.length > 0) {
|
if (this.allowableValues && this.allowableValues.valueType == "LIST") {
|
||||||
n += "Select";
|
n += "Select";
|
||||||
} else {
|
} else {
|
||||||
if (this.required) n += "Required";
|
if (this.required) n += "Required";
|
||||||
|
|||||||
Reference in New Issue
Block a user