Group learning goals
This commit is contained in:
parent
80c2841e3d
commit
01e08c2656
|
@ -13,3 +13,14 @@
|
||||||
ul#learning_goals {
|
ul#learning_goals {
|
||||||
list-style-type: none;
|
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]
|
skip_before_action :require_login, only: [:index, :show]
|
||||||
before_action :set_learning_goal, only: [:show, :edit, :update, :destroy]
|
before_action :set_learning_goal, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index ; end
|
||||||
@learning_goals = LearningGoal.all
|
|
||||||
.order(created_at: :desc)
|
|
||||||
.page(params[:page])
|
|
||||||
end
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@learning_goal = LearningGoal.new
|
@learning_goal = LearningGoal.new
|
||||||
|
|
|
@ -7,9 +7,12 @@ class LearningGoal < ApplicationRecord
|
||||||
has_rich_text :description
|
has_rich_text :description
|
||||||
has_rich_text :retrospective
|
has_rich_text :retrospective
|
||||||
validates :completed, inclusion: { in: [true, false] }
|
validates :completed, inclusion: { in: [true, false] }
|
||||||
|
|
||||||
validates :title, presence: true
|
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
|
def microposts
|
||||||
microposts = Micropost.none
|
microposts = Micropost.none
|
||||||
tags.each { |tag| microposts = microposts.or(tag.microposts) }
|
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"), new_learning_goal_path if logged_in? %>
|
||||||
<%= link_to t(".new_todo"), new_todo_path if logged_in? %>
|
<%= link_to t(".new_todo"), new_todo_path if logged_in? %>
|
||||||
|
|
||||||
<% if @learning_goals.empty? %>
|
<h3><%= t(".current") %></h3>
|
||||||
<p><%= t(".empty") %></p>
|
<% if LearningGoal.current.any? %>
|
||||||
|
<%= render LearningGoal.current %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<ul id="learning_goals">
|
<p><%= t(".no_current_goals") %></p>
|
||||||
<% @learning_goals.each do |learning_goal| %>
|
|
||||||
<li><%= link_to learning_goal.title, learning_goal %></li>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
|
||||||
<%= paginate @learning_goals %>
|
<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 %>
|
<% end %>
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<h3><%= t(".todos") %></h3>
|
<h3><%= t(".todos") %></h3>
|
||||||
<ul>
|
<ul class="todos">
|
||||||
<% @learning_goal.todos.each do |todo| %>
|
<% @learning_goal.todos.each do |todo| %>
|
||||||
<li><%= render todo %></li>
|
<li><%= render todo %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3><%= t(".tags") %></h3>
|
<h3><%= t(".tags") %></h3>
|
||||||
<ul>
|
<ul class="tags">
|
||||||
<% @learning_goal.tags.each do |tag| %>
|
<% @learning_goal.tags.each do |tag| %>
|
||||||
<li><%= link_to tag.name, tag %></li>
|
<li><%= link_to tag.name, tag %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
checked
|
checked
|
||||||
<% end %>>
|
<% end %>>
|
||||||
<%= todo.title %>
|
<%= todo.title %>
|
||||||
<%= todo.description %>
|
|
||||||
<% if todo.user == current_user %>
|
<% if todo.user == current_user %>
|
||||||
<%= link_to t(".edit"), edit_todo_path(todo) %>
|
<%= link_to t(".edit"), edit_todo_path(todo) %>
|
||||||
<%= link_to t(".delete"), todo, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>
|
<%= link_to t(".delete"), todo, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%= todo.description %>
|
||||||
|
|
|
@ -2,9 +2,14 @@ en:
|
||||||
learning_goals:
|
learning_goals:
|
||||||
index:
|
index:
|
||||||
learning_goals: Learning Goals
|
learning_goals: Learning Goals
|
||||||
empty: You have no learning goals yet.
|
|
||||||
new: New learning goal
|
new: New learning goal
|
||||||
new_todo: New todo
|
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:
|
new:
|
||||||
create: Create learning goal
|
create: Create learning goal
|
||||||
edit:
|
edit:
|
||||||
|
|
|
@ -9,6 +9,6 @@ en:
|
||||||
form:
|
form:
|
||||||
title: Title
|
title: Title
|
||||||
todo:
|
todo:
|
||||||
edit: Edit todo
|
edit: Edit
|
||||||
delete: Delete todo
|
delete: Delete
|
||||||
confirm: Are you sure you want to delete this todo?
|
confirm: Are you sure you want to delete this todo?
|
||||||
|
|
Loading…
Reference in New Issue