DB restructure, print page
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
module IdCard
|
||||
class NetworkLogosController < ApplicationController
|
||||
|
||||
# View Methods
|
||||
def index
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
file = logo_params["logo_file"]
|
||||
if file.present? && file.is_a?(ActionDispatch::Http::UploadedFile)
|
||||
filename = file.original_filename
|
||||
# binary_data = file.read
|
||||
binary_data = File.binread(file)
|
||||
meme_type = Marcel::MimeType.for(file)
|
||||
|
||||
networklogo = IdCard::NetworkLogo.create(
|
||||
filename: filename,
|
||||
image_data: binary_data,
|
||||
content_type: meme_type
|
||||
)
|
||||
|
||||
render json: networklogo, only: [:id], status: :ok
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
# API Methods
|
||||
|
||||
def image
|
||||
logo_file = IdCard::NetworkLogo.find(params[:id])
|
||||
puts params[:id]
|
||||
logo_binary = logo_file.image_data
|
||||
logo_filename = logo_file.filename
|
||||
|
||||
send_data logo_binary,
|
||||
filename: logo_filename,
|
||||
disposition: 'inline'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def logo_params
|
||||
params.require(:id_card_network_logo).permit(:logo_file)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,35 @@
|
||||
module IdCard
|
||||
class PlansController < ApplicationController
|
||||
|
||||
# View Methods
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
end
|
||||
|
||||
# API Methods
|
||||
|
||||
def get_plan_benefits
|
||||
@plan_benefits = IdCard::Plan.find(params[:id]).plan_benefits
|
||||
render json: @plan_benefits.as_json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
module IdCard
|
||||
class PrinterController < ApplicationController
|
||||
|
||||
# View Methods
|
||||
def index
|
||||
@employer_configurations = IdCard::Configuration.active.to_a.sort_by { |config| config.pl_plan_key.to_i }
|
||||
add_queued_count_to_card_configuration
|
||||
render :index
|
||||
end
|
||||
|
||||
# API Methods
|
||||
|
||||
private
|
||||
|
||||
|
||||
def add_queued_count_to_card_configuration
|
||||
@queue_counts = EmployerCards::QueueCounter.new().call
|
||||
@queue_counts.each do |qc|
|
||||
match = @employer_configurations.find { |configuration| configuration.pl_plan_key == qc["PLPlanKey"] }
|
||||
if match.present?
|
||||
match.queued_card_count = qc["QueuedCardsCount"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,40 @@
|
||||
module IdCard
|
||||
class ProviderSectionsController < ApplicationController
|
||||
|
||||
# View Methods
|
||||
def index
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
# API Methods
|
||||
|
||||
def get_section_data
|
||||
@provider_section = IdCard::ProviderSection.find(params[:id])
|
||||
render json: @provider_section.as_json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def logo_params
|
||||
params.require(:id_card_network_logo).permit(:logo_file)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,41 +1,25 @@
|
||||
module IdCard
|
||||
class SetupController < ApplicationController
|
||||
class ConfigurationController < ApplicationController
|
||||
before_action :set_employer_and_setup
|
||||
|
||||
# View Methods
|
||||
def new
|
||||
@employer = Employer.find_by(slug: params[:employer])
|
||||
@setup = @employer.create_id_card_setup
|
||||
render :new
|
||||
end
|
||||
|
||||
def create
|
||||
xyz
|
||||
employer_params = Employer.permitted_params(params)
|
||||
puts "---Params---"
|
||||
puts employer_params
|
||||
# post_image_processing_params = process_logos(employer_setup_process_params)
|
||||
@employer = Employer.new(employer_params)
|
||||
if @employer.save
|
||||
# update_logos_with_employer_setup_information()
|
||||
redirect_to employer_path(@employer.slug), notice: 'Employer Saved'
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@employer = Employer.find_by(slug: params[:id])
|
||||
@employer = Employer.find_by(slug: params[:employer_id])
|
||||
if @employer.id_card_enabled?
|
||||
@setup = @employer.id_card_setup
|
||||
else
|
||||
@setup = @employer.create_id_card_setup
|
||||
end
|
||||
render :edit
|
||||
end
|
||||
|
||||
def update
|
||||
puts "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||
employer_params = Employer.permitted_params(params)
|
||||
@employer = Employer.find(params[:id])
|
||||
setup_params = IdCard::Configuration.permitted_params(params)
|
||||
@setup = IdCard::Configuration.find(params[:id])
|
||||
|
||||
if @employer.update(employer_params)
|
||||
if @setup.update(setup_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@employer.slug), notice: 'Employer was successfully updated.'
|
||||
redirect_to employer_path(@setup.employer.slug), notice: 'ID Card Configuration was successfully updated.'
|
||||
else
|
||||
puts "fail"
|
||||
render :edit, status: :unprocessable_entity
|
||||
@@ -43,6 +27,66 @@ module IdCard
|
||||
|
||||
end
|
||||
|
||||
def general
|
||||
provider_defaults = IdCard::ProviderSection.defaults
|
||||
@provider_options = provider_defaults.map { |p| ["Default #{p.title}", p.id] }.concat(provider_defaults.map { |p| ["New #{p.title}", "new|#{p.id}"] })
|
||||
if @setup.provider_section_id.present? && provider_defaults.map(&:id).exclude?(@setup.provider_section_id)
|
||||
@provider_options.insert(0, ["#{@employer.name} Custom", @setup.provider_section_id])
|
||||
end
|
||||
@rx_options = IdCard::RxSection.all
|
||||
@fairos_rx_id = IdCard::RxSection.find_by(title: "FairosRx").id
|
||||
render :general
|
||||
end
|
||||
|
||||
def update_general
|
||||
if params[:id_card_setup]["provider_section_id"].include?("new|")
|
||||
new_provider_section_params = IdCard::ProviderSection.permitted_params(params)
|
||||
new_provider_section = IdCard::ProviderSection.create(new_provider_section_params)
|
||||
params[:id_card_setup]["provider_section_id"] = new_provider_section.id
|
||||
end
|
||||
general_params = IdCard::Configuration.permitted_params(params)
|
||||
if @setup.update(general_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@employer.slug), notice: 'ID Card Configuration was successfully updated.'
|
||||
else
|
||||
puts "fail"
|
||||
render :general, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def plans
|
||||
@plan_templates = IdCard::Plan.templates
|
||||
render :plans
|
||||
end
|
||||
|
||||
def update_plans
|
||||
plans_params = IdCard::Plan.permitted_params(params)
|
||||
if @setup.update(plans_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@setup.employer.slug), notice: 'ID Card Plans successfully updated.'
|
||||
else
|
||||
puts "fail"
|
||||
render :plans, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def field_exceptions
|
||||
render :field_exceptions
|
||||
end
|
||||
|
||||
def update_field_exceptions
|
||||
field_exceptions_params = IdCard::FieldException.permitted_params(params)
|
||||
if @setup.update(field_exceptions_params)
|
||||
puts "sucess"
|
||||
redirect_to employer_path(@setup.employer.slug), notice: 'ID Card Exceptions successfully updated.'
|
||||
else
|
||||
puts "fail"
|
||||
render :field_exceptions, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
# @resource = Resource.find(params[:id])
|
||||
# @resource.destroy
|
||||
@@ -53,6 +97,15 @@ module IdCard
|
||||
|
||||
private
|
||||
|
||||
def set_employer_and_setup
|
||||
@employer = Employer.find_by(slug: params[:employer_id])
|
||||
if @employer.id_card_setup.present?
|
||||
@setup = @employer.id_card_setup
|
||||
else
|
||||
@setup = @employer.create_id_card_setup
|
||||
end
|
||||
end
|
||||
|
||||
# def process_logos(employer_setup_process_params)
|
||||
# @uploaded_logos = []
|
||||
# employer_logo = employer_setup_process_params["employer_logo"]
|
||||
@@ -129,15 +182,15 @@ module IdCard
|
||||
# )
|
||||
# end
|
||||
|
||||
# def network_exceptions_params
|
||||
# params.require(:employer_setup_network_exceptions_form).permit(
|
||||
# network_exceptions: [:network_logo, exceptions: [:type, :value]],
|
||||
# def network_field_exceptions_params
|
||||
# params.require(:employer_setup_network_field_exceptions_form).permit(
|
||||
# network_field_exceptions: [:network_logo, field_exceptions: [:type, :value]],
|
||||
# )
|
||||
# end
|
||||
|
||||
# def form_for_step
|
||||
# step_name = @top_form.current_step
|
||||
# form_method = "EmployerSetup#{step_name.camelize}Form".constantize
|
||||
# form_method = "EmployerConfiguration#{step_name.camelize}Form".constantize
|
||||
# # puts "/////\\\\\\||||||"
|
||||
# # puts session[:employer_setup_data]
|
||||
# # puts session[:employer_setup_data]['employer_setup_process_id']
|
||||
@@ -146,7 +199,7 @@ module IdCard
|
||||
# end
|
||||
|
||||
# def process_step(step_name)
|
||||
# @form_method = "EmployerSetup#{step_name.camelize}Form".constantize
|
||||
# @form_method = "EmployerConfiguration#{step_name.camelize}Form".constantize
|
||||
# session_data_name = "#{step_name}_data"
|
||||
# # puts "1--------------params----"
|
||||
# # puts params
|
||||
@@ -180,13 +233,13 @@ module IdCard
|
||||
|
||||
# def global_params(step_name)
|
||||
# form_name_sym = "employer_setup_#{step_name}_form".to_sym
|
||||
# params.require(form_name_sym).permit(EmployerSetupForm.permitted_params)
|
||||
# params.require(form_name_sym).permit(EmployerConfigurationForm.permitted_params)
|
||||
# end
|
||||
|
||||
# def process_step(step_name)
|
||||
# form_name = "employer_setup_#{step_name}_form".camelize.constantize
|
||||
# form_params_name = "#{step_name}_params".to_sym
|
||||
# allowed_params = [:general_information_params, :plans_params, :network_exceptions_params]
|
||||
# allowed_params = [:general_information_params, :plans_params, :network_field_exceptions_params]
|
||||
# if allowed_params.include?(form_params_name)
|
||||
# form_params = send(form_params_name)
|
||||
# @form = form_name.new(form_params)
|
||||
@@ -211,7 +264,7 @@ module IdCard
|
||||
# :number_of_plans,
|
||||
# :network,
|
||||
# :number_of_additional_network_logos,
|
||||
# network_exceptions: [:network_logo, exceptions: [:type, :value]],
|
||||
# network_field_exceptions: [:network_logo, field_exceptions: [:type, :value]],
|
||||
# plans: permited_plans_keys,
|
||||
# benefit_descs: benefit_sequence_keys
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user