docbrown/app/views/users/_response_templates.html.erb
rhymes 81fff248dd
Refactoring GitHub Repos functionality - step 1 (#7764)
* Rename find_or_create to upsert and improve validation and testing

* Add User.authenticated_through?

* Refactor settings/integrations

* Refactor profile github repositories rendering

* Refactor repos fetching

* Only fetch a single repo and improve error messages

* Remove unused code

* Cleanups

* Fix specs

* Remove trailing whitespace

* Fix spec

* Trigger Travis
2020-05-12 13:48:19 +02:00

57 lines
2.5 KiB
Text

<h3>Personal Response Templates</h3>
<p class="mb-6">Response templates are snippets that you can re-use for quick and accurate comments.</p>
<% if @response_templates.present? %>
<div class="crayons-card grid gap-6 p-6 mb-6">
<h3>Your templates</h3>
<div class="github-repos-container -mt-4">
<div class="github-repos">
<% @response_templates.each do |response_template| %>
<div class="github-repo-row <%= "github-repo-row-featured" if response_template.id == params[:id].to_i %>">
<div class="github-repo-row-name flex items-center crayons-card crayons-card--secondary p-2 pl-4 mt-2">
<div class="flex-1">
<%= response_template.title %>
</div>
<div class="flex">
<%= form_with url: response_template_path(response_template.id), method: :delete, local: true, html: { onsubmit: "return confirm('Are you sure you want to delete: #{response_template.title}?');" } do %>
<button type="submit" class="crayons-btn crayons-btn--secondary">Remove</button>
<% end %>
<a class="crayons-btn crayons-btn--secondary ml-2" href="/settings/response-templates/<%= response_template.id %>" role="button">Edit</a>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
<%= form_with model: @response_template do |f| %>
<div class="crayons-card grid gap-6 p-6 mb-6">
<header>
<% if @response_template.persisted? %>
<% title = params[:previous_title] || @response_template.title %>
<% content = params[:previous_content] || @response_template.content %>
<h3>Editing a response template</h3>
<a href="/settings/response-templates">Create a new response template</a>
<% else %>
<% title = params[:previous_title] %>
<% content = params[:previous_content] %>
<h3>Add a new response template</h3>
<% end %>
</header>
<div class="crayons-field">
<%= f.label :title, class: "crayons-field__label" %>
<%= f.text_field :title, placeholder: "...", value: title, class: "crayons-textfield" %>
<p class="crayons-field__description">Memorable cue for template</p>
</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">Save template</button></div>
</div>
<% end %>