mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
57 lines
2.1 KiB
Plaintext
57 lines
2.1 KiB
Plaintext
<%
|
|
content_name = f.object.class.content_name
|
|
|
|
field_id = "#{content_name}_#{field.name}"
|
|
value = nil
|
|
if f.object.respond_to?(field.name.to_sym)
|
|
value = f.object.send(field.name.to_sym)
|
|
else
|
|
value = Attribute.where(user: current_user, attribute_field: field, entity: f.object).first
|
|
end
|
|
%>
|
|
|
|
<div class="input-field content-field">
|
|
<%= f.label field do %>
|
|
<%= field.label.present? ? field.label : ' ' %>
|
|
<% if defined?(autocomplete) %>
|
|
<i class="material-icons grey-text lighten-2 tooltipped" style="font-size: 100%" data-tooltip="This field may suggest some ideas for you when you start typing." data-position="right">
|
|
offline_bolt
|
|
</i>
|
|
<% end %>
|
|
<% end %>
|
|
<%
|
|
placeholder = I18n.translate "attributes.#{content_name}.#{field.name}",
|
|
scope: :serendipitous_questions,
|
|
name: f.object.send('name') || "this #{content_name}",
|
|
attribute: "test",
|
|
default: 'Write as little or as much as you want!'
|
|
%>
|
|
|
|
<% if field.system? %>
|
|
<%= f.text_area field.name, value: value, class: "materialize-textarea #{'autocomplete' if defined?(autocomplete)}", placeholder: placeholder %>
|
|
<% else %>
|
|
<%= hidden_field_tag "#{content_name}[custom_attribute_values][][name]", field.name %>
|
|
<%= text_area_tag "#{content_name}[custom_attribute_values][][value]", value && value.value, class: "materialize-textarea #{'autocomplete' if defined?(autocomplete)}", placeholder: placeholder %>
|
|
<%= render 'content/form/attribute_field_dropdown', field: field %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<% if defined?(autocomplete) %>
|
|
<% content_for :javascript do %>
|
|
$(function() {
|
|
// This setTimeout is an unfortunate hack to ensure this runs after initializing materialize
|
|
setTimeout(function() {
|
|
console.log("Initializing autocomplete for #<%= "#{content_name}_#{field.name}" %>");
|
|
$('#<%= "#{content_name}_#{field.name}" %>').autocomplete({
|
|
limit: 5,
|
|
data: {
|
|
<% autocomplete.each do |autocomplete_option| %>
|
|
"<%= autocomplete_option %>": null,
|
|
<% end %>
|
|
}
|
|
});
|
|
}, 1000);
|
|
});
|
|
<% end %>
|
|
<% end %>
|