-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5172 from rubyforgood/5108-add-training-topics-se…
…ction-to-learning-hours adds learning hour topics to learning hours
- Loading branch information
Showing
28 changed files
with
368 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
class LearningHourTopicsController < ApplicationController | ||
before_action :set_learning_hour_topic, only: %i[edit update] | ||
after_action :verify_authorized | ||
|
||
def new | ||
authorize LearningHourTopic | ||
@learning_hour_topic = LearningHourTopic.new | ||
end | ||
|
||
def edit | ||
authorize @learning_hour_topic | ||
end | ||
|
||
def create | ||
authorize LearningHourTopic | ||
@learning_hour_topic = LearningHourTopic.new(learning_hour_topic_params) | ||
|
||
if @learning_hour_topic.save | ||
redirect_to edit_casa_org_path(current_organization), notice: "Learning Topic was successfully created." | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def update | ||
authorize @learning_hour_topic | ||
|
||
if @learning_hour_topic.update(learning_hour_topic_params) | ||
redirect_to edit_casa_org_path(current_organization), notice: "Learning Topic was successfully updated." | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def set_learning_hour_topic | ||
@learning_hour_topic = LearningHourTopic.find(params[:id]) | ||
end | ||
|
||
def learning_hour_topic_params | ||
params.require(:learning_hour_topic).permit(:name, :active).merge( | ||
casa_org: current_organization | ||
) | ||
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
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,12 @@ | ||
class LearningHourTopicDecorator < ApplicationDecorator | ||
delegate_all | ||
|
||
# Define presentation-specific methods here. Helpers are accessed through | ||
# `helpers` (aka `h`). You can override attributes, for example: | ||
# | ||
# def created_at | ||
# helpers.content_tag :span, class: 'time' do | ||
# object.created_at.strftime("%a %m/%d/%y") | ||
# end | ||
# 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class LearningHourTopic < ApplicationRecord | ||
belongs_to :casa_org | ||
validates :name, presence: true, uniqueness: {scope: %i[casa_org], case_sensitive: false} | ||
before_validation :strip_name | ||
scope :for_organization, ->(org) { where(casa_org: org).order(:name) } | ||
|
||
private | ||
|
||
def strip_name | ||
self.name = name.strip if name | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: learning_hour_topics | ||
# | ||
# id :bigint not null, primary key | ||
# name :string not null | ||
# position :integer default(1) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# casa_org_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_learning_hour_topics_on_casa_org_id (casa_org_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (casa_org_id => casa_orgs.id) | ||
# |
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 @@ | ||
class LearningHourTopicPolicy < ApplicationPolicy | ||
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,50 @@ | ||
<div class="row"> | ||
<div class="col-lg-12"> | ||
<div class="card-style mb-30"> | ||
<div class="row align-items-center"> | ||
<div class="col-md-6"> | ||
<h3>Learning Topic</h3> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="breadcrumb-wrapper"> | ||
<span class="ml-5"> | ||
<%= link_to new_learning_hour_topic_path, class: "btn-sm main-btn primary-btn btn-hover" do %> | ||
<i class="lni lni-plus mr-10"></i> | ||
New Learning Topic | ||
<% end %> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="table-wrapper table-responsive"> | ||
<table class="table striped-table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @learning_hour_topics.each do |learning_hour_topic| %> | ||
<tr id="learning_hour_topic-<%= learning_hour_topic.id %>"> | ||
<td scope="row" class="min-width"> | ||
<%= learning_hour_topic.name %> | ||
</td> | ||
|
||
<td> | ||
<%= link_to edit_learning_hour_topic_path(learning_hour_topic) do %> | ||
<div class="action"> | ||
<button class="text-danger"> | ||
<i class="lni lni-pencil-alt"></i> Edit | ||
</button> | ||
</div> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<div class="title-wrapper pt-30"> | ||
<div class="row align-items-center"> | ||
<div class="col-md-6"> | ||
<div class="title mb-30"> | ||
<h1> | ||
<%= title %> | ||
</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</div><!-- ==== end title ==== --> | ||
|
||
<!-- ========== card start ========== --> | ||
<div class="card-style mb-30"> | ||
<%= form_with(model: learning_hour_topic, local: true) do |form| %> | ||
<div class="alert-box danger-alert"> | ||
<%= render "/shared/error_messages", resource: learning_hour_topic %> | ||
</div> | ||
<div class="input-style-1"> | ||
<%= form.label :name, "Name" %> | ||
<%= form.text_field :name, class: "form-control", required: true %> | ||
</div> | ||
|
||
<div class="actions mb-10"> | ||
<%= button_tag(type: "submit", class: "btn-sm main-btn primary-btn btn-hover") do %> | ||
<i class="lni lni-checkmark-circle mr-5"></i> Submit | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<!-- card 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 @@ | ||
<%= render partial: "form", locals: {title: "Learning Topic", learning_hour_topic: @learning_hour_topic} %> |
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 @@ | ||
<%= render partial: "form", locals: {title: "New Learning Topic", learning_hour_topic: @learning_hour_topic} %> |
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
Oops, something went wrong.