Compare commits
No commits in common. "658bc90ed75392e71619602428b342014f823c32" and "c2b2017d6ca2e04325609abf30338c4ee17118c4" have entirely different histories.
658bc90ed7
...
c2b2017d6c
|
@ -1,4 +1,4 @@
|
||||||
form#blog_post_form, form#learning_goal_form {
|
form#blog_post_form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
max-width: 55em;
|
max-width: 55em;
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
.learning_goal {
|
|
||||||
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#learning_goals {
|
|
||||||
list-style-type: none;
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
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 new
|
|
||||||
@learning_goal = LearningGoal.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
@learning_goal = LearningGoal.new(learning_goal_params)
|
|
||||||
@learning_goal.user = helpers.current_user
|
|
||||||
|
|
||||||
if @learning_goal.save
|
|
||||||
redirect_to @learning_goal, notice: t(".created")
|
|
||||||
else
|
|
||||||
render :new, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show ; end
|
|
||||||
|
|
||||||
def edit; end
|
|
||||||
|
|
||||||
def update
|
|
||||||
if @learning_goal.update(learning_goal_params)
|
|
||||||
redirect_to @learning_goal, notice: t(".updated")
|
|
||||||
else
|
|
||||||
render :edit, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
if @learning_goal.destroy
|
|
||||||
redirect_to learning_goals_path, notice: t(".deleted")
|
|
||||||
else
|
|
||||||
render :edit, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def learning_goal_params
|
|
||||||
params.require(:learning_goal).permit(
|
|
||||||
:title,
|
|
||||||
:starts_on,
|
|
||||||
:ends_on,
|
|
||||||
:description,
|
|
||||||
:retrospective,
|
|
||||||
:completed,
|
|
||||||
:user,
|
|
||||||
tag_ids: [],
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_learning_goal
|
|
||||||
@learning_goal = LearningGoal.find(params[:id])
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
module LearningGoalsHelper
|
|
||||||
def learning_goal_completed_text(learning_goal)
|
|
||||||
learning_goal.completed ? t(".completed") : t(".not_completed")
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,17 +0,0 @@
|
||||||
class LearningGoal < ApplicationRecord
|
|
||||||
belongs_to :user
|
|
||||||
|
|
||||||
has_rich_text :description
|
|
||||||
has_rich_text :retrospective
|
|
||||||
|
|
||||||
validates :title, presence: true
|
|
||||||
|
|
||||||
has_and_belongs_to_many :tags
|
|
||||||
accepts_nested_attributes_for :tags
|
|
||||||
|
|
||||||
def microposts
|
|
||||||
microposts = Micropost.none
|
|
||||||
tags.each { |tag| microposts = microposts.or(tag.microposts) }
|
|
||||||
microposts
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -4,7 +4,6 @@ class Tag < ApplicationRecord
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
has_many :microposts_tags
|
has_many :microposts_tags
|
||||||
has_many :microposts, through: :microposts_tags
|
has_many :microposts, through: :microposts_tags
|
||||||
has_and_belongs_to_many :learning_goals
|
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
name
|
name
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div id="blog_post_<%= @blog_post.id %>" class="blog_post">
|
<div id="@blog_post_<%= @blog_post.id %>" class="blog_post">
|
||||||
<h2><%= @blog_post.title %></h2>
|
<h2><%= @blog_post.title %></h2>
|
||||||
<p><%= @blog_post.content %></p>
|
<p><%= @blog_post.content %></p>
|
||||||
<div class="created_at">
|
<div class="created_at">
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
<%= form_with model: @learning_goal, id: "learning_goal_form" do |f| %>
|
|
||||||
<h2><%= title %></h2>
|
|
||||||
|
|
||||||
<%= f.text_field :title, placeholder: t(".title") %>
|
|
||||||
|
|
||||||
<%= f.rich_text_area :description %>
|
|
||||||
|
|
||||||
<%= f.label :starts_on %>
|
|
||||||
<%= f.date_field :starts_on %>
|
|
||||||
|
|
||||||
<%= f.label :ends_on %>
|
|
||||||
<%= f.date_field :ends_on %>
|
|
||||||
|
|
||||||
<%= f.rich_text_area :retrospective %>
|
|
||||||
|
|
||||||
<%= f.label :completed %>
|
|
||||||
<%= f.check_box :completed %>
|
|
||||||
|
|
||||||
<%= f.label :microposts_tag %>
|
|
||||||
<%= f.collection_check_boxes :tag_ids, Tag.all, :id, :name %>
|
|
||||||
|
|
||||||
<%= f.submit button_text %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
<% @title = t(".edit") %>
|
|
||||||
|
|
||||||
<%= render partial: "form",
|
|
||||||
locals: {
|
|
||||||
user: @user,
|
|
||||||
button_text: t(".edit"),
|
|
||||||
title: t(".edit"),
|
|
||||||
} %>
|
|
||||||
|
|
||||||
<%= link_to t(".delete"), @learning_goal, data: { turbo_method: :delete, turbo_confirm: t(".confirm") } %>
|
|
|
@ -1,14 +0,0 @@
|
||||||
<h2><%= t(".learning_goals") %></h2>
|
|
||||||
|
|
||||||
<%= link_to t(".new"), new_learning_goal_path if logged_in? %>
|
|
||||||
|
|
||||||
<% if @learning_goals.empty? %>
|
|
||||||
<p><%= t(".empty") %></p>
|
|
||||||
<% 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 %>
|
|
||||||
<% end %>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<% @title = t(".create") %>
|
|
||||||
|
|
||||||
<%= render partial: "form",
|
|
||||||
locals: {
|
|
||||||
user: @user,
|
|
||||||
button_text: t(".create"),
|
|
||||||
title: t(".create"),
|
|
||||||
} %>
|
|
|
@ -1,21 +0,0 @@
|
||||||
<div id="learning_goal_<%= @learning_goal.id %>" class="learning_goal">
|
|
||||||
<%= link_to t(".edit"), edit_learning_goal_path(@learning_goal) if @learning_goal.user == current_user %>
|
|
||||||
<h2><%= @learning_goal.title %></h2>
|
|
||||||
<p><%= @learning_goal.starts_on %>-<%= @learning_goal.ends_on %></p>
|
|
||||||
<h3><%= t(".description") %></h3>
|
|
||||||
<p><%= @learning_goal.description %></p>
|
|
||||||
<% if @learning_goal.completed? %>
|
|
||||||
<h3><%= t(".retrospective") %></h3>
|
|
||||||
<p><%= @learning_goal.retrospective %></p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<h3><%= t(".tags") %></h3>
|
|
||||||
<ul>
|
|
||||||
<% @learning_goal.tags.each do |tag| %>
|
|
||||||
<li><%= link_to tag.name, tag %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3><%= t(".related_microposts") %></h3>
|
|
||||||
<p><%= render @learning_goal.microposts %></p>
|
|
||||||
</div>
|
|
|
@ -1,5 +0,0 @@
|
||||||
en:
|
|
||||||
learning_goals:
|
|
||||||
created: Successfully created learning goal
|
|
||||||
updated: Successfully updated learning goal
|
|
||||||
deleted: Successfully deleted learning goal
|
|
|
@ -1,22 +0,0 @@
|
||||||
en:
|
|
||||||
learning_goals:
|
|
||||||
index:
|
|
||||||
learning_goals: Learning Goals
|
|
||||||
empty: You have no learning goals yet.
|
|
||||||
new: New learning goal
|
|
||||||
new:
|
|
||||||
create: Create learning goal
|
|
||||||
edit:
|
|
||||||
edit: Edit learning goal
|
|
||||||
delete: Delete learning goal
|
|
||||||
confirm: Are you sure you want to delete this learning goal?
|
|
||||||
form:
|
|
||||||
title: Title
|
|
||||||
show:
|
|
||||||
completed: Learning goal is complete
|
|
||||||
not_completed: Learning goal is incomplete
|
|
||||||
edit: Edit
|
|
||||||
description: Description
|
|
||||||
retrospective: Retrospective
|
|
||||||
tags: Tags
|
|
||||||
related_microposts: Related μposts
|
|
|
@ -13,7 +13,6 @@ Rails.application.routes.draw do
|
||||||
get "confirm_email", to: "email_confirmations#confirm"
|
get "confirm_email", to: "email_confirmations#confirm"
|
||||||
|
|
||||||
resources :blog_posts
|
resources :blog_posts
|
||||||
resources :learning_goals
|
|
||||||
resources :microposts
|
resources :microposts
|
||||||
resources :tags, only: [:index, :show]
|
resources :tags, only: [:index, :show]
|
||||||
resources :diary_entries, except: [:destroy]
|
resources :diary_entries, except: [:destroy]
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
class CreateLearningGoals < ActiveRecord::Migration[7.1]
|
|
||||||
def change
|
|
||||||
create_table :learning_goals do |t|
|
|
||||||
t.string :title, null: false
|
|
||||||
t.date :starts_on
|
|
||||||
t.date :ends_on
|
|
||||||
t.boolean :completed, null: false, default: false
|
|
||||||
t.references :user, null: false, foreign_key: true
|
|
||||||
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
class LearningGoalTagAssociation < ActiveRecord::Migration[7.1]
|
|
||||||
def change
|
|
||||||
create_join_table :learning_goals, :tags
|
|
||||||
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_06_103226) do
|
ActiveRecord::Schema[7.1].define(version: 2023_12_31_112357) 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"
|
||||||
|
|
||||||
|
@ -97,22 +97,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_06_103226) do
|
||||||
t.index ["exercise_type_id"], name: "index_exercises_on_exercise_type_id"
|
t.index ["exercise_type_id"], name: "index_exercises_on_exercise_type_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "learning_goals", force: :cascade do |t|
|
|
||||||
t.string "title", null: false
|
|
||||||
t.date "starts_on"
|
|
||||||
t.date "ends_on"
|
|
||||||
t.boolean "completed", default: false, null: false
|
|
||||||
t.bigint "user_id", null: false
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
t.index ["user_id"], name: "index_learning_goals_on_user_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "learning_goals_tags", id: false, force: :cascade do |t|
|
|
||||||
t.bigint "learning_goal_id", null: false
|
|
||||||
t.bigint "tag_id", null: false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "microposts", force: :cascade do |t|
|
create_table "microposts", force: :cascade do |t|
|
||||||
t.bigint "user_id", null: false
|
t.bigint "user_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
|
@ -159,6 +143,5 @@ ActiveRecord::Schema[7.1].define(version: 2024_01_06_103226) do
|
||||||
add_foreign_key "diary_entries", "users"
|
add_foreign_key "diary_entries", "users"
|
||||||
add_foreign_key "exercises", "diary_entries"
|
add_foreign_key "exercises", "diary_entries"
|
||||||
add_foreign_key "exercises", "exercise_types"
|
add_foreign_key "exercises", "exercise_types"
|
||||||
add_foreign_key "learning_goals", "users"
|
|
||||||
add_foreign_key "microposts", "users"
|
add_foreign_key "microposts", "users"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class LearningGoalsControllerTest < ActionDispatch::IntegrationTest
|
|
||||||
# test "the truth" do
|
|
||||||
# assert true
|
|
||||||
# end
|
|
||||||
end
|
|
|
@ -10,7 +10,3 @@ draft_blog_post:
|
||||||
record: draft (BlogPost)
|
record: draft (BlogPost)
|
||||||
name: content
|
name: content
|
||||||
body: <p>Just some text</p>
|
body: <p>Just some text</p>
|
||||||
learning_goal_one:
|
|
||||||
record: linux (LearningGoal)
|
|
||||||
name: content
|
|
||||||
body: <p>Learning about Linux</p>
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
sql:
|
|
||||||
title: SQL
|
|
||||||
starts_on: 2024-01-06
|
|
||||||
ends_on: 2024-06-06
|
|
||||||
completed: false
|
|
||||||
user: trevor
|
|
||||||
|
|
||||||
linux:
|
|
||||||
title: Linux
|
|
||||||
starts_on: 2023-03-06
|
|
||||||
ends_on: 2023-06-06
|
|
||||||
completed: true
|
|
||||||
user: trevor
|
|
|
@ -1,4 +0,0 @@
|
||||||
require "test_helper"
|
|
||||||
|
|
||||||
class LearningGoalTest < ActiveSupport::TestCase
|
|
||||||
end
|
|
Loading…
Reference in New Issue