docbrown/app/views/users/_response_templates.html.erb
yheuhtozr a1e8f29fe6
user settings i18n (#15098)
Co-authored-by: Nick Taylor <nick@dev.to>
2021-12-02 11:35:08 -05:00

68 lines
2.9 KiB
Text

<div class="crayons-card crayons-card--content-rows">
<header>
<h2 class="crayons-subtitle-1">
<%= t("views.settings.extensions.comment.heading") %>
</h2>
<p class="color-base-70"><%= t("views.settings.extensions.comment.desc_html") %></p>
</p>
</header>
<% if @response_templates.present? %>
<section>
<h3 class="crayons-subtitle-3">
<%= t("views.settings.extensions.comment.saved") %>
</h3>
<% @response_templates.each do |response_template| %>
<div class="<%= "github-repo-row-featured" if response_template.id == params[:id].to_i %> mb-4">
<div class="flex items-center py-2 mt-2">
<div class="flex-1 ff-monospace">
<%= response_template.title %>
</div>
<div class="flex">
<%= form_with url: response_template_path(response_template.id), method: :delete, local: true, html: { onsubmit: "return confirm('#{t('views.settings.extensions.comment.confirm', template: response_template.title)}');" } do %>
<button type="submit" class="crayons-btn crayons-btn--secondary"><%= t("views.settings.extensions.comment.remove") %></button>
<% end %>
<a class="crayons-btn crayons-btn--secondary ml-2" href="/settings/response-templates/<%= response_template.id %>" role="button"><%= t("views.settings.extensions.comment.edit") %></a>
</div>
</div>
</div>
<% end %>
</section>
<% end %>
<%= form_with model: @response_template do |f| %>
<section class="grid gap-3">
<% if @response_template&.persisted? %>
<% title = params[:previous_title] || @response_template.title %>
<% content = params[:previous_content] || @response_template.content %>
<h3 class="crayons-subtitle-3">
<%= t("views.settings.extensions.comment.edit_template") %>
</h3>
<a href="/settings/response-templates"><%= t("views.settings.extensions.comment.create") %></a>
<% else %>
<% title = params[:previous_title] %>
<% content = params[:previous_content] %>
<h3 class="crayons-subtitle-3">
<%= t("views.settings.extensions.comment.add") %>
</h3>
<% end %>
<div class="crayons-field">
<%= f.label :title, class: "crayons-field__label" %>
<p class="crayons-field__description">
<%= t("views.settings.extensions.comment.cue") %>
</p>
<%= f.text_field :title, placeholder: "...", value: title, class: "crayons-textfield" %>
</div>
<div class="crayons-field">
<%= f.label :content, "Comment body (Markdown)", class: "crayons-field__label" %>
<%= f.text_area :content, value: content, class: "crayons-textfield" %>
</div>
<div>
<button type="submit" class="crayons-btn"><%= t("views.settings.extensions.comment.save") %></button>
</div>
</section>
<% end %>
</div>