thingspeak/app/views/channels/_edit.html.erb

174 lines
5.7 KiB
Plaintext
Raw Normal View History

<div class="FL">
2014-03-14 00:16:35 +01:00
<%= form_for @channel, :html => {:method => 'put'} do |c| %>
<% unless session[:errors].nil?
session[:errors].each do |attr, msg|
@channel.errors.add(attr, msg)
end
session[:errors] = nil %>
<% end %>
<p>
<%= error_messages_for 'channel', :header_message => t(:try_again), :message => t(:channel_error) %>
</p>
<input name='userlogin' class='userlogin' />
<table class="table_no_header">
<tr>
<td class="left"><%= t(:channel_ranking) %></td>
<td><%= @channel.ranking %>%</td>
</tr>
<tr>
<td class="left"><%= t(:channel_id) %></td>
<td><%= @channel.id %></td>
</tr>
<tr>
<td class="left"><%= t(:channel_name) %></td>
<td><%= c.text_field :name %></td>
</tr>
<tr>
<td class="left"><%= t(:channel_description) %></td>
<td><%= c.text_area :description, :cols => 30, :rows => 4 %></td>
</tr>
2014-06-30 19:16:22 +02:00
<tr>
<td class="left"><%= t(:metadata).capitalize %></td>
<td><%= c.text_area :metadata, :cols => 30, :rows => 4 %></td>
</tr>
<%= fields_for :tags do |t| %>
<tr>
<td class="left"><%= t(:tags) %></td>
<td><%= t.text_area :name, :cols => 30, :rows => 2, :value => @channel.list_tags %></td>
</tr>
<% end %>
<tr>
<td class="left"><%= t(:latitude) %></td>
<td><%= c.text_field :latitude %></td>
</tr>
<tr>
<td class="left"><%= t(:longitude) %></td>
<td><%= c.text_field :longitude %></td>
</tr>
<tr>
<td class="left"><%= t(:elevation) %></td>
<td><%= c.text_field :elevation %></td>
</tr>
<tr>
<td class="left"><%= t(:public) %></td>
<td><%= c.check_box :public_flag %></td>
</tr>
<tr>
<td class="left"><%= t(:channel_url) %></td>
<td><%= c.text_field :url %></td>
</tr>
<tr>
<td class="left"><%= t(:video_id) %></td>
<td >
<%= c.text_field :video_id, :class=>'video_narrow'%>
<%= c.radio_button :video_type, 'youtube' %>
<span class="small"><%= t(:youtube) %></span>
<%= c.radio_button :video_type, 'vimeo' %>
<span class="small"><%= t(:vimeo) %></span>
</td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 1</td>
<td><%= c.text_field :field1, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 2</td>
<td><%= c.text_field :field2, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 3</td>
<td><%= c.text_field :field3, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 4</td>
<td><%= c.text_field :field4, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 5</td>
<td><%= c.text_field :field5, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 6</td>
<td><%= c.text_field :field6, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 7</td>
<td><%= c.text_field :field7, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 8</td>
<td><%= c.text_field :field8, :class => 'field' %></td>
</tr>
<tr>
<td class="left"></td>
2014-08-05 20:44:39 +02:00
<td><%= c.submit t(:channel_update), class: 'btn btn-primary' %></td>
</tr>
</table>
<% end %>
2014-03-14 00:16:35 +01:00
<br><br>
2014-02-18 00:54:26 +01:00
<h4><%= t(:channel_clear_message) %></h4>
2014-08-05 20:44:39 +02:00
<%= button_to t(:channel_clear), "/channels/#{@channel.id}/clear", :data => { :confirm => t(:confirm_channel_clear) }, class: 'btn btn-danger' %>
2014-03-14 00:16:35 +01:00
<br><br>
2014-02-18 00:54:26 +01:00
<h4><%= t(:channel_delete_message) %></h4>
2014-08-05 20:44:39 +02:00
<%= button_to t(:channel_delete), channel_path(@channel.id), :method => 'delete', :data => { :confirm => t(:confirm_channel_delete) }, class: 'btn btn-danger' %>
</div>
2014-02-18 01:51:30 +01:00
<div id="sidebar_old">
<ul>
<li>
<h2><%= t(:help) %></h2>
<%= t(:help_channel_public) %>
2014-03-14 00:16:35 +01:00
<br><br>
<%= t(:help_channel_url) %>
2014-03-14 00:16:35 +01:00
<br><br>
<%= t(:help_channel_video) %>
2014-03-14 00:16:35 +01:00
<br><br>
<%= t(:help_channel_fields) %>
2014-03-14 00:16:35 +01:00
<br><br>
<%= t(:help_channel_clear) %>
2014-03-14 00:16:35 +01:00
<br><br>
<%= t(:help_channel_ranking) %>
2014-03-14 00:16:35 +01:00
<br><br>
</li>
</ul>
</div>
<script type="text/javascript">
// remember default field label
var default_label = '<%= t(:channel_default_field) %>';
// when document is ready
2014-08-01 21:57:02 +02:00
$(document).on('page:load ready', function() {
// iterate through each field textbox
$('.field').each(function() {
// if a value is present, show the 'remove' checkbox
if ($(this).val()) {
$(this).after('<span class="small" id="span_' + $(this).attr('id') + '"><input type="checkbox" onclick="removeField(\'' + $(this).attr('id') + '\')" /><span class="up2">remove field</span></span>');
// else disable
} else {
$(this).after('<span class="small" id="span_' + $(this).attr('id') + '"><input type="checkbox" onclick="addField(\'' + $(this).attr('id') + '\')" /><span class="up2">add field</span></span>');
}
});
});
// adds a field
function addField(id) {
$('#span_'+id).remove()
$('#'+id).val(default_label + ' ' + id.substring(id.length-1));
$('#'+id).after('<span class="small" id="span_' + id + '"><input type="checkbox" onclick="removeField(\'' + id + '\')" /><span class="up2">remove field</span></span>');
$('#'+id).select();
}
// removes a field
function removeField(id) {
$('#span_'+id).remove();
$('#'+id).val('');
$('#'+id).after('<span class="small" id="span_' + id + '"><input type="checkbox" onclick="addField(\'' + id + '\')" /><span class="up2">add field</span></span>');
}
</script>