lib/lurker/templates/lurker/rendering/_submit_form.html.erb in lurker-0.6.9 vs lib/lurker/templates/lurker/rendering/_submit_form.html.erb in lurker-0.6.10
- old
+ new
@@ -7,18 +7,18 @@
return window.location.hostname == '127.0.0.1' || window.location.hostname == 'localhost'
},
getInitialState: function() {
var state = {
- payload: JSON.parse('<%= @post_params.to_json.html_safe %>'),
- values: JSON.parse('<%= @url_params.map { |k,v| { label:k, value: v} } .to_json.html_safe %>'),
- hosts: JSON.parse('<%= @service_presenter.domains.to_json.html_safe %>'),
- template: '<%= @endpoint_presenter.named_path %>',
- method: '<%= @endpoint_presenter.verb %>',
- host: '<%= @service_presenter.default_domain %>',
- requestMediaTypes: JSON.parse('<%= @service_presenter.request_media_types.to_json.html_safe %>'),
- requestMediaType: '<%= @service_presenter.default_request_media_type %>'
+ payload: JSON.parse('<%= endpoint.post_params.to_json.html_safe %>'),
+ values: JSON.parse('<%= endpoint.url_params.map { |k,v| { label:k, value: v} } .to_json.html_safe %>'),
+ hosts: JSON.parse('<%= service.domains.to_json.html_safe %>'),
+ template: '<%= endpoint.named_path %>',
+ method: '<%= endpoint.verb %>',
+ host: '<%= service.default_domain %>',
+ requestMediaTypes: JSON.parse('<%= service.request_media_types.to_json.html_safe %>'),
+ requestMediaType: '<%= service.default_request_media_type %>'
};
if (state.method === 'GET') {
state.requestMediaType = 'application/x-www-form-urlencoded';
state.requestMediaTypes = [state.requestMediaType];
}
@@ -77,21 +77,21 @@
render: function() {
var actionUrl = Lurker.buildActionUrl(this.state.host, this.state.template, this.state.values);
var curl = Lurker.generateCurlCommand(actionUrl, this.state.method, this.state.payload, this.state.requestMediaType);
return (
- <form accept-charset="UTF-8" action={actionUrl} onSubmit={this.handleSubmit} id="payload" className="bs-example hidden-print form-horizontal" method="<%= @endpoint_presenter.form_verb %>">
- <input name="_method" value="<%= @endpoint_presenter.verb %>" type="hidden" />
+ <form accept-charset="UTF-8" action={actionUrl} onSubmit={this.handleSubmit} id="payload" className="bs-example hidden-print form-horizontal" method="<%= endpoint.form_verb %>">
+ <input name="_method" value="<%= endpoint.verb %>" type="hidden" />
<div className="form-group">
<label className="control-label col-sm-3" forHtml="hostname">Target Host</label>
<div className="col-sm-9">
<select id="hostname" className="form-control" valueLink={this.linkState('host')}>
{this.renderHostOptions()}
</select>
</div>
</div>
- <% if @endpoint_presenter.verb != 'GET' && @service_presenter.request_media_types.size > 1 %>
+ <% if endpoint.verb != 'GET' && service.request_media_types.size > 1 %>
<div className="form-group">
<label className="control-label col-sm-3" forHtml="requestMediaType">Request Media Type</label>
<div className="col-sm-9">
<select id="requestMediaType" className="form-control" valueLink={this.linkState('requestMediaType')}>
{this.renderRequestMediaTypeOptions()}
@@ -105,14 +105,14 @@
<div className="col-sm-9">
<pre>{curl}</pre>
</div>
</div>
- <% if @url_params.present? %>
+ <% if endpoint.url_params.present? %>
<div className="bs-example url-params" id="url-payload">
<fieldset ref="url-params">
- <% @url_params.each_with_index do |(label, value), i| %>
+ <% endpoint.url_params.each_with_index do |(label, value), i| %>
<div className="form-group">
<label className="control-label col-sm-3" htmlFor="<%= label %>"><%= label %></label>
<div className="col-sm-9">
<input type="text" valueLink={this.linkState('values.<%= i %>.value')} className="form-control"></input>
</div>
@@ -120,14 +120,14 @@
<% end %>
</fieldset>
</div>
<% end %>
- <% if @post_params.present? %>
+ <% if endpoint.post_params.present? %>
<div className="bs-example post-params" id="post-payload">
<fieldset ref="post-params">
- <%= Lurker::FormBuilder.new(@post_params).html.html_safe %>
+ <%= Lurker::FormBuilder.new(endpoint.post_params).html.html_safe %>
</fieldset>
</div>
<% end %>
<div className="form-group row">
@@ -138,10 +138,10 @@
</form>
);
}
});
- var submitForm = <SubmitForm template="<%= @endpoint_presenter.named_path %>" />;
+ var submitForm = <SubmitForm template="<%= endpoint.named_path %>" />;
// FIXME: see multidomain feature - cannot select node in phantomjs
window.submitForm = submitForm;
React.renderComponent(submitForm, document.getElementById('submit-form'));
</script>
<div id="submit-form"></div>