Group learning goals
This commit is contained in:
parent
80c2841e3d
commit
01e08c2656
|
@ -13,3 +13,14 @@
|
|||
ul#learning_goals {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
ul.todos {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
ul.tags {
|
||||
list-style-type: none;
|
||||
> li {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
form#blog_post_form, form#learning_goal_form, form#todo_form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 55em;
|
||||
|
||||
> h2 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
> trix-toolbar {
|
||||
max-width: 95%;
|
||||
}
|
||||
|
||||
> trix-editor {
|
||||
width: 95%;
|
||||
> ul {
|
||||
list-style-type: disc;
|
||||
}
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
> input[type=submit] {
|
||||
width: 95%;
|
||||
}
|
||||
}
|
||||
|
||||
.blog_post {
|
||||
margin: 1em auto;
|
||||
padding: .5em;
|
||||
background-color: var(--inset-background-color);
|
||||
border: 1px solid var(--border-color);
|
||||
|
||||
> .created_at {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
}
|
||||
}
|
||||
|
||||
ul#blog_posts {
|
||||
list-style-type: none;
|
||||
}
|
|
@ -4,11 +4,7 @@ class LearningGoalsController < ApplicationController
|
|||
skip_before_action :require_login, only: [:index, :show]
|
||||
before_action :set_learning_goal, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@learning_goals = LearningGoal.all
|
||||
.order(created_at: :desc)
|
||||
.page(params[:page])
|
||||
end
|
||||
def index ; end
|
||||
|
||||
def new
|
||||
@learning_goal = LearningGoal.new
|
||||
|
|
|
@ -7,9 +7,12 @@ class LearningGoal < ApplicationRecord
|
|||
has_rich_text :description
|
||||
has_rich_text :retrospective
|
||||
validates :completed, inclusion: { in: [true, false] }
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
scope :current, -> { where(starts_on: ..Date.today, ends_on: Date.today..) }
|
||||
scope :past, -> { where(ends_on: ..Date.today) }
|
||||
scope :future, -> { where(starts_on: Date.today..) }
|
||||
|
||||
def microposts
|
||||
microposts = Micropost.none
|
||||
tags.each { |tag| microposts = microposts.or(tag.microposts) }
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<div id="learning_goal_<%= learning_goal.id %>" class="learning_goal">
|
||||
<h2><%= link_to learning_goal.title, learning_goal %></h2>
|
||||
<%= learning_goal.description %>
|
||||
</div>
|
|
@ -3,13 +3,23 @@
|
|||
<%= link_to t(".new"), new_learning_goal_path if logged_in? %>
|
||||
<%= link_to t(".new_todo"), new_todo_path if logged_in? %>
|
||||
|
||||
<% if @learning_goals.empty? %>
|
||||
<p><%= t(".empty") %></p>
|
||||
<h3><%= t(".current") %></h3>
|
||||
<% if LearningGoal.current.any? %>
|
||||
<%= render LearningGoal.current %>
|
||||
<% else %>
|
||||
<ul id="learning_goals">
|
||||
<% @learning_goals.each do |learning_goal| %>
|
||||
<li><%= link_to learning_goal.title, learning_goal %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= paginate @learning_goals %>
|
||||
<p><%= t(".no_current_goals") %></p>
|
||||
<% end %>
|
||||
|
||||
<h3><%= t(".future") %></h3>
|
||||
<% if LearningGoal.future.any? %>
|
||||
<%= render LearningGoal.future %>
|
||||
<% else %>
|
||||
<p><%= t(".no_future_goals") %></p>
|
||||
<% end %>
|
||||
|
||||
<h3><%= t(".past") %></h3>
|
||||
<% if LearningGoal.past.any? %>
|
||||
<%= render LearningGoal.past %>
|
||||
<% else %>
|
||||
<p><%= t(".no_past_goals") %></p>
|
||||
<% end %>
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
<% end %>
|
||||
|
||||
<h3><%= t(".todos") %></h3>
|
||||
<ul>
|
||||
<ul class="todos">
|
||||
<% @learning_goal.todos.each do |todo| %>
|
||||
<li><%= render todo %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<h3><%= t(".tags") %></h3>
|
||||
<ul>
|
||||
<ul class="tags">
|
||||
<% @learning_goal.tags.each do |tag| %>
|
||||
<li><%= link_to tag.name, tag %></li>
|
||||
<% end %>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
checked
|
||||
<% end %>>
|
||||
<%= todo.title %>
|
||||
<%= todo.description %>
|
||||
<% if todo.user == current_user %>
|
||||
<%= link_to t(".edit"), edit_todo_path(todo) %>
|
||||
<%= link_to t(".delete"), todo, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>
|
||||
<% end %>
|
||||
<%= todo.description %>
|
||||
|
|
|
@ -2,9 +2,14 @@ en:
|
|||
learning_goals:
|
||||
index:
|
||||
learning_goals: Learning Goals
|
||||
empty: You have no learning goals yet.
|
||||
new: New learning goal
|
||||
new_todo: New todo
|
||||
current: Current
|
||||
future: Future
|
||||
past: Past
|
||||
no_current_goals: You have no current goals
|
||||
no_future_goals: You have no future goals
|
||||
no_past_goals: You have no past goals
|
||||
new:
|
||||
create: Create learning goal
|
||||
edit:
|
||||
|
|
|
@ -9,6 +9,6 @@ en:
|
|||
form:
|
||||
title: Title
|
||||
todo:
|
||||
edit: Edit todo
|
||||
delete: Delete todo
|
||||
edit: Edit
|
||||
delete: Delete
|
||||
confirm: Are you sure you want to delete this todo?
|
||||
|
|
Loading…
Reference in New Issue