diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index eaf69c44..61367293 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -62,6 +62,15 @@ p.long-form { textarea.materialize-textarea { height: 80px; } + + &.link { + padding-bottom: 2em; + } + + .field-actions { + position: relative; + top: -0.4em; + } } .content-field.focused { @@ -185,6 +194,7 @@ p.long-form { margin-bottom: 0rem; padding-left: 1em; padding-right: 0.75em; + padding-top: 0.5em; i.left, i.right { font-size: 1.5em; diff --git a/app/views/content/display/sidebar/_actions.html.erb b/app/views/content/display/sidebar/_actions.html.erb index 701ebbdb..8ed5eeee 100644 --- a/app/views/content/display/sidebar/_actions.html.erb +++ b/app/views/content/display/sidebar/_actions.html.erb @@ -12,6 +12,13 @@ Actions +
  • + <%= link_to '#', class: "expand" do %> + format_line_spacing + Expand all categories + <% end %> +
  • + <% if raw_model.persisted? %>
  • <%= link_to '#', class: 'share' do %> @@ -21,13 +28,6 @@
  • <% end %> -
  • - <%= link_to '#', class: "expand" do %> - format_line_spacing - Expand all categories - <% end %> -
  • - <% if user_signed_in? && current_user.id == content.user.id %>
  • <%= link_to attribute_customization_path(content_type: raw_model.class.name.downcase) do %> diff --git a/app/views/content/display/sidebar/_categories.html.erb b/app/views/content/display/sidebar/_categories.html.erb index b7635be0..ed78552e 100644 --- a/app/views/content/display/sidebar/_categories.html.erb +++ b/app/views/content/display/sidebar/_categories.html.erb @@ -50,7 +50,7 @@ <% else %> - <%= category[:percent_complete] %>% + <%= category[:percent_complete] %>% <% end %> diff --git a/app/views/content/form/_panel.html.erb b/app/views/content/form/_panel.html.erb index 5dc68341..aebea767 100644 --- a/app/views/content/form/_panel.html.erb +++ b/app/views/content/form/_panel.html.erb @@ -3,7 +3,7 @@ %>
    _panel" class="panel card" style="display: none"> -
    +
    <%= category[:icon] %> <%= category[:label] %>
    @@ -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' %> - -
    -
    - <%= f.label field[:id], field[:label] %> -
    - <%= f.hidden_field :page_tags, value: content.page_tags.join(PageTag::SUBMISSION_DELIMITER), id: 'hidden_page_tags_value' %> - -
    - label - Type and press enter to create a new tag, or click any of the suggested tags below to add it. -
    -
    - <% @suggested_page_tags.each do |tag| %> - <%= - link_to '#', class: 'js-add-tag' do - %> - - <% end %> - <% end %> -
    -
    -
    -
    - <%= 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' %> -
    -
    - <%= f.label field[:id], field[:label] %>
    - - <% if !f.object.persisted? || (f.object.persisted? && f.object.universe && f.object.universe.user == current_user) || f.object.universe_id.nil? %> - <%# todo not like this %> - <% - valid_universes = [] - show_premium_notice = false - - if Rails.application.config.content_types[:free].map(&:name).include?(raw_model.class.name) - valid_universes += current_user.universes - valid_universes += current_user.contributable_universes - else - # Premium content - if current_user.on_premium_plan? \ - || (raw_model.persisted? && content.user == current_user) \ - || PermissionService.user_has_active_promotion_for_this_content_type(user: current_user, content_type: f.object.class.name) - - valid_universes += current_user.universes - - # Allow premium users to add premium content to non-premium universes - valid_universes += current_user.contributable_universes - else - show_premium_notice = true - end - - current_user.contributable_universes.each do |potential_universe| - if potential_universe.user.on_premium_plan? - valid_universes += [potential_universe] - end - end - end - %> - - <%= hidden_field_tag "#{raw_model.class.name.downcase}[custom_attribute_values][][name]", field[:id] %> - <%= - @universe_dropdown_options ||= valid_universes.uniq.sort_by(&:name).map { |u| [u.name, u.id] } - select_tag "#{raw_model.class.name.downcase}[custom_attribute_values][][value]", - options_for_select( - @universe_dropdown_options.compact, - content.is_a?(ContentSerializer) ? content.universe.try(:id) : @universe_scope.try(:id) - ), - include_blank: current_user.on_premium_plan? || Rails.application.config.content_types[:free].map(&:name).include?(raw_model.class.name) - %> - <% if show_premium_notice %> -
    - info - While on a <%= link_to 'Starter plan', subscription_path %>, you can only create premium content in universes you're a contributor to. -
    - <% end %> - <% else %> -
    - <%= link_to(f.object.universe.name, f.object.universe) if f.object.universe %> - <% end %> -
    -
    - - <% 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 %> -
    -
    - <% unless defined?(show_label) && !show_label %> - <%= f.label field do %> - <%= field[:label].present? ? field[:label] : ' ' %> - <% if defined?(autocomplete) && autocomplete && autocomplete.any? %> - - offline_bolt - - <% end %> - <% end %> - <% end %> - <% - placeholder = I18n.translate "attributes.#{content_name}.#{field[:label].downcase.gsub(/\s/, '_')}", - scope: :serendipitous_questions, - name: f.object.send('name') || "this #{content_name}", - default: 'Write as little or as much as you want!' - %> +<% unless defined?(show_label) && !show_label %> + <%= f.label field do %> + <%= field[:label].present? ? field[:label] : ' ' %> + <% end %> +<% end %> - <%= hidden_field_tag "#{content_name}[custom_attribute_values][][name]", field[:id] %> - <%= - text_area_tag "#{content_name}[custom_attribute_values][][value]", - value, - class: "js-can-mention-pages materialize-textarea #{defined?(autocomplete) && autocomplete ? ('autocomplete ' + 'js-autocomplete-' + field[:id].to_s) : ''}", - placeholder: placeholder - %> +<% + placeholder = I18n.translate "attributes.#{content_name}.#{field[:label].downcase.gsub(/\s/, '_')}", + scope: :serendipitous_questions, + name: f.object.send('name') || "this #{content_name}", + default: 'Write as little or as much as you want!' +%> -

    - Tip: You can press @ to insert a link to your other pages. -

    - <% if field[:label].start_with?('Private') %> -
    - Private notes are always visible to only you, even if content is made public and shared. -
    - <% end %> +<%= hidden_field_tag "#{content_name}[custom_attribute_values][][name]", field[:id] %> +<%= + text_area_tag "#{content_name}[custom_attribute_values][][value]", + value, + class: "js-can-mention-pages materialize-textarea #{defined?(autocomplete) && autocomplete ? ('autocomplete ' + 'js-autocomplete-' + field[:id].to_s) : ''}", + placeholder: placeholder +%> + +<% if field[:label].start_with?('Private') %> +
    + Private notes are always visible to only you, even if content is made public and shared.
    -
    +<% 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 %> -
    -
    +