-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turbo Frames in Rails. Dynamic adding, editing and deleting records. Some features of these frames.
- Loading branch information
Showing
14 changed files
with
194 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="<%= I18n.locale %>"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title><%= full_title(yield(:page_title)) %></title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
<%= stylesheet_link_tag "application", media: 'all' %> | ||
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> | ||
</head> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title><%= full_title(yield(:page_title)) %></title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload", media: 'all' %> | ||
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> | ||
</head> | ||
|
||
<body data-lang="<%= I18n.locale %>"> | ||
<%= yield :main_menu %> | ||
|
||
<main class="container mt-3"> | ||
<% flash.each do |k, v| %> | ||
<%= tag.div v, class: "alert alert-#{k}", role: 'alert' %> | ||
<% end %> | ||
<body data-lang="<%= I18n.locale %>"> | ||
<%= yield :main_menu %> | ||
|
||
<%= yield %> | ||
</main> | ||
</body> | ||
</html> | ||
<main class="container mt-3"> | ||
<div id="flash"> | ||
<%= render 'shared/flash' %> | ||
</div> | ||
|
||
<%= yield %> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
<%= render 'shared/errors', object: question %> | ||
<%= turbo_frame_tag question do %> | ||
<%= form_with model: question do |f| %> | ||
<%= render 'shared/errors', object: question %> | ||
|
||
<%= form_with model: question do |f| %> | ||
<div class="mb-3 row"> | ||
<div class="col-sm-2 col-form-label"> | ||
<%= f.label :title %> | ||
</div> | ||
<div class="mb-3 row"> | ||
<div class="col-sm-2 col-form-label"> | ||
<%= f.label :title %> | ||
</div> | ||
|
||
<div class="col-sm-10"> | ||
<%= f.text_field :title, class: 'form-control' %> | ||
<div class="col-sm-10"> | ||
<%= f.text_field :title, class: 'form-control' %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3 row"> | ||
<div class="col-sm-2 col-form-label"> | ||
<%= f.label :body %> | ||
</div> | ||
<div class="mb-3 row"> | ||
<div class="col-sm-2 col-form-label"> | ||
<%= f.label :body %> | ||
</div> | ||
|
||
<div class="col-sm-10"> | ||
<%= f.text_area :body, class: 'form-control' %> | ||
<div class="col-sm-10"> | ||
<%= f.text_area :body, class: 'form-control' %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3 row"> | ||
<div class="col-sm-2 col-form-label"> | ||
<%= f.label :tags %> | ||
</div> | ||
<div class="mb-3 row"> | ||
<div class="col-sm-2 col-form-label"> | ||
<%= f.label :tags %> | ||
</div> | ||
|
||
<div class="col-sm-10"> | ||
<%= f.collection_select :tag_ids, question.tags, :id, :title, {}, multiple: true, | ||
class: 'js-multiple-select js-ajax-select w-100', data: {'ajax-url': '/api/tags'} %> | ||
<div class="col-sm-10"> | ||
<%= f.collection_select :tag_ids, question.tags, :id, :title, {}, multiple: true, | ||
class: 'js-multiple-select', data: {'ajax-url': '/api/tags'} %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%= f.submit t('global.button.submit'), class: 'btn btn-primary' %> | ||
<%= f.submit t('global.button.submit'), class: 'btn btn-primary' %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
<article class="card my-3"> | ||
<section class="card-header"> | ||
<%= question.user.gravatar %> | ||
<%= question.user.name_or_email %> | ||
</section> | ||
<%= turbo_frame_tag question do %> | ||
<article class="card my-3"> | ||
<section class="card-header"> | ||
<%= question.user.gravatar %> | ||
<%= question.user.name_or_email %> | ||
</section> | ||
|
||
<div class="card-body"> | ||
<h2><%= link_to question.title, question_path(question) %></h2> | ||
<div class="card-body"> | ||
<h2><%= link_to question.title, question_path(question), | ||
data: {turbo_frame: '_top'} %></h2> | ||
|
||
<section class="card-text"> | ||
<%= tag.time datetime: question.formatted_created_at do %> | ||
<small><%= question.formatted_created_at %></small> | ||
<% end %> | ||
|
||
<div class="my-2"> | ||
<%= render question.tags %> | ||
</div> | ||
<section class="card-text"> | ||
<%= tag.time datetime: question.formatted_created_at do %> | ||
<small><%= question.formatted_created_at %></small> | ||
<% end %> | ||
|
||
<p class="my-2"> | ||
<%= truncate strip_tags(question.body), length: 150, omission: t('global.text.omission') %> | ||
</p> | ||
</section> | ||
<div class="my-2"> | ||
<%= render question.tags %> | ||
</div> | ||
|
||
<%= link_to t('global.button.show'), question_path(question), class: 'btn btn-primary' %> | ||
<p class="my-2"> | ||
<%= sanitize question.body %> | ||
</p> | ||
</section> | ||
|
||
<% if policy(question).edit? %> | ||
<%= link_to t('global.button.edit'), edit_question_path(question), class: 'btn btn-secondary' %> | ||
<% end %> | ||
<% if policy(question).destroy? %> | ||
<%= link_to t('global.button.delete'), question_path(question), class: 'btn btn-danger', | ||
data: {turbo_method: :delete, turbo_confirm: t('global.dialog.you_sure')} %> | ||
<% end %> | ||
</div> | ||
</article> | ||
<% if policy(question).edit? %> | ||
<%= link_to t('global.button.edit'), edit_question_path(question), class: 'btn btn-secondary' %> | ||
<% end %> | ||
<% if policy(question).destroy? %> | ||
<%= link_to t('global.button.delete'), question_path(question), class: 'btn btn-danger', | ||
data: {turbo_method: :delete, turbo_confirm: t('global.dialog.you_sure')} %> | ||
<% end %> | ||
</div> | ||
</article> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= turbo_stream.prepend 'questions', render(@question) %> | ||
<%= prepend_flash %> |
Oops, something went wrong.