1
0
Fork 0

built step attributes dynamically

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-07-20 19:37:46 +05:30
Ursprung a904d14e70
Commit 098c16cd47
2 geänderte Dateien mit 58 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -82,17 +82,10 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
:theme_id,
permitted: mapped_params,
steps: [
:id,
:index,
:title,
:key,
:banner,
:raw_description,
:required_data_message,
:force_final,
required_data: mapped_params,
permitted_params: mapped_params,
condition: mapped_params,
*CustomWizard::Step.type_attributes(:permitted),
CustomWizard::Step.type_attributes(:mapped).map do |attribute|
[attribute, mapped_params]
end.to_h ,
fields: [
*CustomWizard::Field.type_attributes(:permitted),
CustomWizard::Field.type_attributes(:mapped).map do |attribute|

Datei anzeigen

@ -3,25 +3,61 @@
class CustomWizard::Step
include ActiveModel::SerializerSupport
attr_reader :id,
:updater
def self.attribute_map
{
id: [:serializable, :permitted],
updater: [],
index: [:accessible, :serializable, :permitted],
title: [:accessible, :serializable, :permitted],
description: [:accessible, :serializable],
key: [:accessible, :permitted],
permitted: [:accessible, :serializable],
permitted_message: [:accessible, :serializable],
fields: [:accessible],
next: [:accessible, :serializable],
previous: [:accessible, :serializable],
banner: [:accessible, :serializable, :permitted],
disabled: [:accessible],
description_vars: [:accessible],
last_step: [:accessible],
force_final: [:accessible],
conditional_final_step: [:accessible],
wizard: [:accessible],
raw_description: [:permitted],
required_data_message: [:permitted],
required_data: [:permitted, :mapped],
permitted_params: [:permitted, :mapped],
condition: [:permitted, :mapped],
final: [:serializable]
}
end
attr_accessor :index,
:title,
:description,
:key,
:permitted,
:permitted_message,
:fields,
:next,
:previous,
:banner,
:disabled,
:description_vars,
:last_step,
:force_final,
:conditional_final_step,
:wizard
def self.type_attributes(type)
attribute_map.map { |attribute, props| props.include?(type.to_sym) ? attribute : nil }.compact
end
def self.all_attributes
attribute_map.keys
end
def self.accessible_attributes
type_attributes(:accessible)
end
def self.included_attributes
all_attributes - excluded_attributes
end
def self.readonly_attributes
included_attributes - accessible_attributes
end
def self.excluded_attributes
type_attributes(:excluded)
end
attr_reader *readonly_attributes
attr_accessor *accessible_attributes
def initialize(id)
@id = id