@@ -14,7 +14,6 @@
<% end %>
<% if category[:name] == 'contributors' %>
- <%# todo reorganize the files for all these panels? %>
<%= render partial: 'content/form/contributors', locals: { f: f, content: content } %>
<% end %>
@@ -23,162 +22,51 @@
<% if field[:type] == 'link' %>
- <%# Relation-setting UI %>
- <% through_class = raw_model.class.reflect_on_association(field[:old_column_source]).options[:through].to_s %>
<%=
- render 'content/form/relation_input',
+ render partial: 'content/form/field_types/legacy_link', locals: {
f: f,
attribute: field[:old_column_source],
- label: field[:label],
- relation: through_class
+ label: field[:label],
+ relation: raw_model.class.reflect_on_association(field[:old_column_source]).options[:through].to_s
+ }
%>
<% elsif field[:type] == 'tags' %>
-
-
- <%= content_for :javascript do %>
- function update_hidden_page_tag_value(e) {
- var chips = M.Chips.getInstance($('.chips')).chipsData.map(function (c) {
- return c['tag'];
- });
-
- var hidden_input = $('#hidden_page_tags_value').first();
- hidden_input.val(chips.join('<%= PageTag::SUBMISSION_DELIMITER %>'));
+ <%=
+ render partial: 'content/form/field_types/tags', locals: {
+ f: f,
+ page: @content,
+ field: field
}
-
- var chips = $('.chips-autocomplete').chips({
- placeholder: 'Tag this page',
- secondaryPlaceholder: '+ Tag',
- autocompleteOptions: {
- data: {
- <% @content.page_tags.pluck(:tag).each do |tag| %>
- '<%= tag %>': null,
- <% end %>
- },
- limit: 100,
- minLength: 1
- },
- data: [
- <% @content.page_tags.pluck(:tag).each do |tag| %>
- {tag: '<%= tag %>'},
- <% end %>
- ],
- onChipAdd: update_hidden_page_tag_value,
- onChipDelete: update_hidden_page_tag_value
- });
- <% end %>
+ %>
<% elsif field[:type] == 'universe' %>
-
-
- <% elsif field[:label].start_with?('Private') %>
- <%#
- This field is shown if and only if:
- * A user is signed in AND
- * That user is the owner of this universe, if it's a universe, or
- * That user is the owner of this content's universe, if it's content
- * That user is the owner of this content, if it's not in a universe
+ <%=
+ render partial: 'content/form/field_types/universe', locals: {
+ f: f,
+ field: field,
+ page: @content,
+ raw_model: raw_model
+ }
%>
- <% if user_signed_in? && (
- (raw_model.is_a?(Universe) && content.user == current_user) ||
- (raw_model.respond_to?(:universe) && raw_model.universe && raw_model.universe.user == current_user) ||
- (raw_model.respond_to?(:universe) && raw_model.universe.nil? && content.user == current_user)
- )
+
+ <% elsif field[:type] == 'name' %>
+ <%=
+ render partial: 'content/form/field_types/name', locals: {
+ f: f,
+ content: @content,
+ field: field
+ }
%>
-
-
- <%= render 'content/form/rich_text_input', f: f, content: content, field: field %>
-
-
- <% end %>
-
- <% elsif field[:type] == 'name' && @entity.present? %>
- <%= render 'content/form/rich_text_input', f: f, content: content, field: field, value: @entity.try(:text) %>
- <%= f.hidden_field :document_entity_id, value: @entity.id %>
<% else %>
- <%= render 'content/form/rich_text_input',
- f: f,
- content: content,
- field: field,
- autocomplete: AutocompleteService.for_field_label(content_model: raw_model.class, label: field[:label])
+ <%=
+ render partial: 'content/form/field_types/text', locals: {
+ f: f,
+ content: @content,
+ raw_model: raw_model,
+ field: field,
+ }
%>
<% end %>
diff --git a/app/views/content/form/_rich_text_input.html.erb b/app/views/content/form/_rich_text_input.html.erb
index 30627ca8..1c6bcbc3 100644
--- a/app/views/content/form/_rich_text_input.html.erb
+++ b/app/views/content/form/_rich_text_input.html.erb
@@ -8,48 +8,33 @@
value = field[:value]
end
%>
-
-
+<% end %>
<% if defined?(autocomplete) && autocomplete && autocomplete.any? %>
<%= content_for :javascript do %>
diff --git a/app/views/content/form/_relation_input.html.erb b/app/views/content/form/field_types/_legacy_link.html.erb
similarity index 79%
rename from app/views/content/form/_relation_input.html.erb
rename to app/views/content/form/field_types/_legacy_link.html.erb
index df05b26b..7768ce19 100644
--- a/app/views/content/form/_relation_input.html.erb
+++ b/app/views/content/form/field_types/_legacy_link.html.erb
@@ -1,7 +1,7 @@
-<%# Usage: render 'content/form/relation_input', f: f, attribute: attribute, relation: through_class %>
-
-
+
+
+ link
<%= f.label attribute, I18n.translate(
"attributes.#{f.object.class.name.downcase}.#{attribute}",
scope: :activerecord,
@@ -9,7 +9,7 @@
) %>
-
+
<%= f.fields_for relation do |builder| %>
<%= render 'content/form/groupship_fields', f: builder, attribute: attribute.singularize, parent: f.object %>
<% end %>
diff --git a/app/views/content/form/field_types/_name.html.erb b/app/views/content/form/field_types/_name.html.erb
new file mode 100644
index 00000000..ff228eba
--- /dev/null
+++ b/app/views/content/form/field_types/_name.html.erb
@@ -0,0 +1,20 @@
+
\ No newline at end of file
diff --git a/app/views/content/form/field_types/_tags.html.erb b/app/views/content/form/field_types/_tags.html.erb
new file mode 100644
index 00000000..7123e5c6
--- /dev/null
+++ b/app/views/content/form/field_types/_tags.html.erb
@@ -0,0 +1,56 @@
+
+<%= content_for :javascript do %>
+ function update_hidden_page_tag_value(e) {
+ var chips = M.Chips.getInstance($('.chips')).chipsData.map(function (c) {
+ return c['tag'];
+ });
+
+ var hidden_input = $('#hidden_page_tags_value').first();
+ hidden_input.val(chips.join('<%= PageTag::SUBMISSION_DELIMITER %>'));
+ }
+
+ var chips = $('.chips-autocomplete').chips({
+ placeholder: 'Tag this page',
+ secondaryPlaceholder: '+ Tag',
+ autocompleteOptions: {
+ data: {
+ <% page.page_tags.pluck(:tag).each do |tag| %>
+ '<%= tag %>': null,
+ <% end %>
+ },
+ limit: 100,
+ minLength: 1
+ },
+ data: [
+ <% page.page_tags.pluck(:tag).each do |tag| %>
+ {tag: '<%= tag %>'},
+ <% end %>
+ ],
+ onChipAdd: update_hidden_page_tag_value,
+ onChipDelete: update_hidden_page_tag_value
+ });
+<% end %>
\ No newline at end of file
diff --git a/app/views/content/form/field_types/_text.html.erb b/app/views/content/form/field_types/_text.html.erb
new file mode 100644
index 00000000..61421b0b
--- /dev/null
+++ b/app/views/content/form/field_types/_text.html.erb
@@ -0,0 +1,49 @@
+<%
+ autocomplete_options = AutocompleteService.for_field_label(content_model: raw_model.class, label: field[:label])
+%>
+
+
\ No newline at end of file
diff --git a/app/views/content/form/field_types/_universe.html.erb b/app/views/content/form/field_types/_universe.html.erb
new file mode 100644
index 00000000..48a36f27
--- /dev/null
+++ b/app/views/content/form/field_types/_universe.html.erb
@@ -0,0 +1,60 @@
+
\ No newline at end of file