Finish MVP for content editing
This commit is contained in:
@@ -1,42 +1,20 @@
|
||||
<%= render HeaderComponent.new(title: "Contributions") %>
|
||||
|
||||
<%= render MainWithTabnavComponent.new(tabnav_partial: "shared/tabnav_contributions") do %>
|
||||
<% if @edit_content %>
|
||||
<section>
|
||||
<%= form_with model: [:admin, @content_title] do |form| %>
|
||||
<p class="mb-2">
|
||||
<%= form.label :content, @content_title.key.capitalize, class: 'font-bold' %>
|
||||
</p>
|
||||
<p class="flex gap-1">
|
||||
<%= form.text_field :content %>
|
||||
<%# <%= form.submit "Save", class: "btn-md btn-blue" %>
|
||||
<%= button_tag type: 'submit', name: nil, title: "Save", class: 'btn-md btn-icon btn-outline' do %>
|
||||
<%= render partial: "icons/save", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
</section>
|
||||
<section>
|
||||
<%= form_with model: [:admin, @content_body] do |form| %>
|
||||
<p class="mb-2">
|
||||
<%= form.label :content, @content_body.key.capitalize, class: 'font-bold' %>
|
||||
</p>
|
||||
<p>
|
||||
<%= form.textarea :content, class: "w-full h-96" %>
|
||||
</p>
|
||||
<p class="text-right">
|
||||
<%= link_to 'Cancel', request.path, class: 'btn-md btn-gray' %>
|
||||
<%= form.submit "Save", class: "ml-2 btn-md btn-blue" %>
|
||||
</p>
|
||||
<% end %>
|
||||
</section>
|
||||
<% else %>
|
||||
<section>
|
||||
<% if @content_body.content.present? %>
|
||||
<%= markdown_to_html @content_body.content %>
|
||||
<% else %>
|
||||
No content yet
|
||||
<% end %>
|
||||
</section>
|
||||
<% end %>
|
||||
<section>
|
||||
<%= render EditableContentComponent.new(
|
||||
context: "contributions/other", key: "body", rich_text: true,
|
||||
default: "No content yet") %>
|
||||
|
||||
<% if current_user.is_admin? %>
|
||||
<div class="mt-8 pt-6 border-t border-gray-200 text-right">
|
||||
<%= render EditContentButtonComponent.new(
|
||||
context: "contributions/other", key: "title",
|
||||
redirect_to: request.path) do %>Edit title<% end %>
|
||||
<%= render EditContentButtonComponent.new(
|
||||
context: "contributions/other", key: "body", rich_text: true,
|
||||
redirect_to: request.path) do %>Edit content<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</section>
|
||||
<% end %>
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
active: current_page?(contributions_donations_path)
|
||||
) %>
|
||||
<%= render TabnavLinkComponent.new(
|
||||
name: editable_content_for("contributions/other", "title", default: "Other"),
|
||||
name: render(EditableContentComponent.new(
|
||||
context: "contributions/other", key: "title", default: "Other"
|
||||
)),
|
||||
path: contributions_other_path,
|
||||
active: current_page?(contributions_other_path)
|
||||
) %>
|
||||
|
||||
Reference in New Issue
Block a user