Compare commits
No commits in common. "01e08c2656d2db5bd614dcffed7587666ea32da0" and "658bc90ed75392e71619602428b342014f823c32" have entirely different histories.
01e08c2656
...
658bc90ed7
|
@ -13,14 +13,3 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
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,7 +4,11 @@ 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 ; end
|
def index
|
||||||
|
@learning_goals = LearningGoal.all
|
||||||
|
.order(created_at: :desc)
|
||||||
|
.page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@learning_goal = LearningGoal.new
|
@learning_goal = LearningGoal.new
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
class TodosController < ApplicationController
|
|
||||||
before_action :set_todo, only: [:edit, :update, :destroy]
|
|
||||||
|
|
||||||
def new
|
|
||||||
@todo = Todo.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
@todo = Todo.new(todo_params)
|
|
||||||
if @todo.save
|
|
||||||
redirect_to @todo.learning_goal, notice: t(".created")
|
|
||||||
else
|
|
||||||
render :new, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit ; end
|
|
||||||
|
|
||||||
def update
|
|
||||||
if @todo.update(todo_params)
|
|
||||||
redirect_to @todo.learning_goal, notice: t(".updated")
|
|
||||||
else
|
|
||||||
render :edit, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
learning_goal = @todo.learning_goal
|
|
||||||
if @todo.destroy
|
|
||||||
redirect_to learning_goal, notice: t(".deleted")
|
|
||||||
else
|
|
||||||
render :edit, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def set_todo
|
|
||||||
@todo = Todo.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def todo_params
|
|
||||||
params.require(:todo).permit(
|
|
||||||
:learning_goal_id,
|
|
||||||
:description,
|
|
||||||
:done,
|
|
||||||
:title,
|
|
||||||
:due,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,2 +0,0 @@
|
||||||
module TodosHelper
|
|
||||||
end
|
|
|
@ -1,21 +1,17 @@
|
||||||
class LearningGoal < ApplicationRecord
|
class LearningGoal < ApplicationRecord
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_many :todos
|
|
||||||
has_and_belongs_to_many :tags
|
|
||||||
accepts_nested_attributes_for :tags
|
|
||||||
|
|
||||||
has_rich_text :description
|
has_rich_text :description
|
||||||
has_rich_text :retrospective
|
has_rich_text :retrospective
|
||||||
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..) }
|
has_and_belongs_to_many :tags
|
||||||
scope :past, -> { where(ends_on: ..Date.today) }
|
accepts_nested_attributes_for :tags
|
||||||
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) }
|
||||||
microposts.uniq
|
microposts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
class Todo < ApplicationRecord
|
|
||||||
belongs_to :learning_goal
|
|
||||||
validates :done, inclusion: { in: [true, false] }
|
|
||||||
has_rich_text :description
|
|
||||||
has_one :user, through: :learning_goal
|
|
||||||
end
|
|
|
@ -22,7 +22,6 @@
|
||||||
<li><%= link_to t(".microposts"), microposts_path %></li>
|
<li><%= link_to t(".microposts"), microposts_path %></li>
|
||||||
<% if logged_in? %>
|
<% if logged_in? %>
|
||||||
<li><%= link_to t(".diary_entries"), diary_entries_path %></li>
|
<li><%= link_to t(".diary_entries"), diary_entries_path %></li>
|
||||||
<li><%= link_to t(".learning_goals"), learning_goals_path %></li>
|
|
||||||
<li><%= link_to t(".profile"), user_path(current_user) %></li>
|
<li><%= link_to t(".profile"), user_path(current_user) %></li>
|
||||||
<li><%= link_to t(".log_out"), log_out_path, data: { turbo_method: :delete } %></li>
|
<li><%= link_to t(".log_out"), log_out_path, data: { turbo_method: :delete } %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
<div id="learning_goal_<%= learning_goal.id %>" class="learning_goal">
|
|
||||||
<h2><%= link_to learning_goal.title, learning_goal %></h2>
|
|
||||||
<%= learning_goal.description %>
|
|
||||||
</div>
|
|
|
@ -1,25 +1,14 @@
|
||||||
<h2><%= t(".learning_goals") %></h2>
|
<h2><%= t(".learning_goals") %></h2>
|
||||||
|
|
||||||
<%= 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? %>
|
|
||||||
|
|
||||||
<h3><%= t(".current") %></h3>
|
<% if @learning_goals.empty? %>
|
||||||
<% if LearningGoal.current.any? %>
|
<p><%= t(".empty") %></p>
|
||||||
<%= render LearningGoal.current %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<p><%= t(".no_current_goals") %></p>
|
<ul id="learning_goals">
|
||||||
<% end %>
|
<% @learning_goals.each do |learning_goal| %>
|
||||||
|
<li><%= link_to learning_goal.title, learning_goal %></li>
|
||||||
<h3><%= t(".future") %></h3>
|
<% end %>
|
||||||
<% if LearningGoal.future.any? %>
|
</ul>
|
||||||
<%= render LearningGoal.future %>
|
<%= paginate @learning_goals %>
|
||||||
<% 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 %>
|
||||||
|
|
|
@ -9,15 +9,8 @@
|
||||||
<p><%= @learning_goal.retrospective %></p>
|
<p><%= @learning_goal.retrospective %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<h3><%= t(".todos") %></h3>
|
|
||||||
<ul class="todos">
|
|
||||||
<% @learning_goal.todos.each do |todo| %>
|
|
||||||
<li><%= render todo %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3><%= t(".tags") %></h3>
|
<h3><%= t(".tags") %></h3>
|
||||||
<ul class="tags">
|
<ul>
|
||||||
<% @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 %>
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<%= form_with model: @todo, id: "todo_form" do |f| %>
|
|
||||||
<h2><%= title %></h2>
|
|
||||||
|
|
||||||
<%= f.text_field :title, placeholder: t(".title") %>
|
|
||||||
|
|
||||||
<%= f.label :learning_goal %>
|
|
||||||
<%= f.collection_select :learning_goal_id, LearningGoal.all, :id, :title %>
|
|
||||||
|
|
||||||
<%= f.rich_text_area :description %>
|
|
||||||
|
|
||||||
<%= f.label :due %>
|
|
||||||
<%= f.date_field :due %>
|
|
||||||
|
|
||||||
<%= f.label :done %>
|
|
||||||
<%= f.check_box :done %>
|
|
||||||
|
|
||||||
<%= f.submit button_text %>
|
|
||||||
<% end %>
|
|
|
@ -1,10 +0,0 @@
|
||||||
<input type="checkbox" class="todo" disabled
|
|
||||||
<% if todo.done? %>
|
|
||||||
checked
|
|
||||||
<% end %>>
|
|
||||||
<%= todo.title %>
|
|
||||||
<% 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 %>
|
|
|
@ -1,10 +0,0 @@
|
||||||
<% @title = t(".edit") %>
|
|
||||||
|
|
||||||
<%= render partial: "form",
|
|
||||||
locals: {
|
|
||||||
user: @user,
|
|
||||||
button_text: t(".edit"),
|
|
||||||
title: t(".edit"),
|
|
||||||
} %>
|
|
||||||
|
|
||||||
<%= link_to t(".delete"), @todo, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<% @title = t(".create") %>
|
|
||||||
|
|
||||||
<%= render partial: "form",
|
|
||||||
locals: {
|
|
||||||
user: @user,
|
|
||||||
button_text: t(".create"),
|
|
||||||
title: t(".create"),
|
|
||||||
} %>
|
|
|
@ -1,5 +0,0 @@
|
||||||
en:
|
|
||||||
todos:
|
|
||||||
created: Successfully created todo
|
|
||||||
updated: Successfully updated todo
|
|
||||||
deleted: Successfully deleted todo
|
|
|
@ -10,4 +10,3 @@ en:
|
||||||
blog_posts: Blog
|
blog_posts: Blog
|
||||||
microposts: μposts
|
microposts: μposts
|
||||||
diary_entries: Diary
|
diary_entries: Diary
|
||||||
learning_goals: Learning Goals
|
|
||||||
|
|
|
@ -2,14 +2,8 @@ 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
|
|
||||||
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:
|
||||||
|
@ -25,5 +19,4 @@ en:
|
||||||
description: Description
|
description: Description
|
||||||
retrospective: Retrospective
|
retrospective: Retrospective
|
||||||
tags: Tags
|
tags: Tags
|
||||||
todos: Todos
|
|
||||||
related_microposts: Related μposts
|
related_microposts: Related μposts
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
en:
|
|
||||||
todos:
|
|
||||||
new:
|
|
||||||
create: Create todo
|
|
||||||
edit:
|
|
||||||
edit: Edit todo
|
|
||||||
delete: Delete todo
|
|
||||||
confirm: Are you sure you want to delete this todo?
|
|
||||||
form:
|
|
||||||
title: Title
|
|
||||||
todo:
|
|
||||||
edit: Edit
|
|
||||||
delete: Delete
|
|
||||||
confirm: Are you sure you want to delete this todo?
|
|
|
@ -16,7 +16,6 @@ Rails.application.routes.draw do
|
||||||
resources :learning_goals
|
resources :learning_goals
|
||||||
resources :microposts
|
resources :microposts
|
||||||
resources :tags, only: [:index, :show]
|
resources :tags, only: [:index, :show]
|
||||||
resources :todos, only: [:new, :create, :edit, :update, :destroy]
|
|
||||||
resources :diary_entries, except: [:destroy]
|
resources :diary_entries, except: [:destroy]
|
||||||
|
|
||||||
get "up" => "rails/health#show", as: :rails_health_check
|
get "up" => "rails/health#show", as: :rails_health_check
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
class CreateTodos < ActiveRecord::Migration[7.1]
|
|
||||||
def change
|
|
||||||
create_table :todos do |t|
|
|
||||||
t.belongs_to :learning_goal, null: false, foreign_key: true
|
|
||||||
t.boolean :done, null: false, default: false
|
|
||||||
t.string :title, null: false, default: ''
|
|
||||||
t.date :due
|
|
||||||
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.1].define(version: 2024_01_07_131738) do
|
ActiveRecord::Schema[7.1].define(version: 2024_01_06_103226) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -140,16 +140,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_07_131738) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "todos", force: :cascade do |t|
|
|
||||||
t.bigint "learning_goal_id", null: false
|
|
||||||
t.boolean "done", default: false, null: false
|
|
||||||
t.string "title", default: "", null: false
|
|
||||||
t.date "due"
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
t.index ["learning_goal_id"], name: "index_todos_on_learning_goal_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "users", force: :cascade do |t|
|
create_table "users", force: :cascade do |t|
|
||||||
t.string "username", null: false
|
t.string "username", null: false
|
||||||
t.string "password_digest", null: false
|
t.string "password_digest", null: false
|
||||||
|
@ -171,5 +161,4 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_07_131738) do
|
||||||
add_foreign_key "exercises", "exercise_types"
|
add_foreign_key "exercises", "exercise_types"
|
||||||
add_foreign_key "learning_goals", "users"
|
add_foreign_key "learning_goals", "users"
|
||||||
add_foreign_key "microposts", "users"
|
add_foreign_key "microposts", "users"
|
||||||
add_foreign_key "todos", "learning_goals"
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class TodosControllerTest < ActionDispatch::IntegrationTest
|
|
||||||
# test "the truth" do
|
|
||||||
# assert true
|
|
||||||
# end
|
|
||||||
end
|
|
|
@ -1,10 +0,0 @@
|
||||||
one:
|
|
||||||
learning_goal: sql
|
|
||||||
done: false
|
|
||||||
title: Read ‘SQL for Mere Mortals’
|
|
||||||
due: <%= 3.years.from_now %>
|
|
||||||
|
|
||||||
two:
|
|
||||||
learning_goal: linux
|
|
||||||
done: true
|
|
||||||
title: Install Debian
|
|
|
@ -1,7 +0,0 @@
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class TodoTest < ActiveSupport::TestCase
|
|
||||||
# test "the truth" do
|
|
||||||
# assert true
|
|
||||||
# end
|
|
||||||
end
|
|
Loading…
Reference in New Issue