-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add an aria-label to the modal close link * translate required text * add cx_action_plans
- Loading branch information
1 parent
ec20259
commit 03ee41b
Showing
22 changed files
with
642 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
class Admin::CxActionPlansController < AdminController | ||
before_action :set_cx_action_plan, only: %i[ show edit update destroy ] | ||
|
||
def index | ||
@cx_action_plans = CxActionPlan.all | ||
end | ||
|
||
def show | ||
end | ||
|
||
def new | ||
@service_providers = ServiceProvider.all.includes(:organization).order('organizations.name', 'service_providers.name') | ||
@cx_action_plan = CxActionPlan.new | ||
end | ||
|
||
def edit | ||
@service_providers = ServiceProvider.all.includes(:organization).order('organizations.name', 'service_providers.name') | ||
end | ||
|
||
def create | ||
@cx_action_plan = CxActionPlan.new(cx_action_plan_params) | ||
|
||
respond_to do |format| | ||
if @cx_action_plan.save | ||
format.html { redirect_to admin_cx_action_plan_url(@cx_action_plan), notice: "Cx action plan was successfully created." } | ||
format.json { render :show, status: :created, location: @cx_action_plan } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @cx_action_plan.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def update | ||
respond_to do |format| | ||
if @cx_action_plan.update(cx_action_plan_params) | ||
format.html { redirect_to admin_cx_action_plan_url(@cx_action_plan), notice: "Cx action plan was successfully updated." } | ||
format.json { render :show, status: :ok, location: @cx_action_plan } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @cx_action_plan.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
@cx_action_plan.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to cx_action_plans_url, notice: "Cx action plan was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
def set_cx_action_plan | ||
@cx_action_plan = CxActionPlan.find(params[:id]) | ||
end | ||
|
||
def cx_action_plan_params | ||
params.require(:cx_action_plan).permit(:service_provider_id, :year, :delivered_current_year, :to_deliver_next_year) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
module V1 | ||
class CxActionPlansController < ::ApiController | ||
def index | ||
respond_to do |format| | ||
format.json do | ||
render json: CxActionPlan.order(:id), each_serializer: CxActionPlanSerializer | ||
end | ||
end | ||
end | ||
|
||
def show | ||
respond_to do |format| | ||
format.json do | ||
render json: CxActionPlan.find(params[:id]), serializer: CxActionPlanSerializer | ||
end | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class CxActionPlan < ApplicationRecord | ||
belongs_to :service_provider | ||
|
||
|
||
def organization_id | ||
self.service_provider.organization_id | ||
end | ||
|
||
def organization_name | ||
self.service_provider.organization.name | ||
end | ||
|
||
def service_provider_name | ||
self.service_provider.name | ||
end | ||
|
||
def services | ||
self.service_provider.services | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CxActionPlanSerializer < ActiveModel::Serializer | ||
attributes :id, | ||
:organization_id, | ||
:organization_name, | ||
:service_provider_id, | ||
:service_provider_name, | ||
:year, | ||
:delivered_current_year, | ||
:to_deliver_next_year, | ||
:services | ||
|
||
|
||
def services | ||
ActiveModel::Serializer::CollectionSerializer.new(object.services, serializer: ServiceSerializer) | ||
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,22 @@ | ||
<div id="<%= dom_id cx_action_plan %>"> | ||
<p> | ||
<strong>Service provider:</strong> | ||
<%= cx_action_plan.service_provider_id %> | ||
</p> | ||
|
||
<p> | ||
<strong>Year:</strong> | ||
<%= cx_action_plan.year %> | ||
</p> | ||
|
||
<p> | ||
<strong>Delivered current year:</strong> | ||
<%= cx_action_plan.delivered_current_year %> | ||
</p> | ||
|
||
<p> | ||
<strong>To deliver next year:</strong> | ||
<%= cx_action_plan.to_deliver_next_year %> | ||
</p> | ||
|
||
</div> |
Oops, something went wrong.