built step attributes dynamically
Dieser Commit ist enthalten in:
Ursprung
a904d14e70
Commit
098c16cd47
2 geänderte Dateien mit 58 neuen und 29 gelöschten Zeilen
|
@ -82,17 +82,10 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
||||||
:theme_id,
|
:theme_id,
|
||||||
permitted: mapped_params,
|
permitted: mapped_params,
|
||||||
steps: [
|
steps: [
|
||||||
:id,
|
*CustomWizard::Step.type_attributes(:permitted),
|
||||||
:index,
|
CustomWizard::Step.type_attributes(:mapped).map do |attribute|
|
||||||
:title,
|
[attribute, mapped_params]
|
||||||
:key,
|
end.to_h ,
|
||||||
:banner,
|
|
||||||
:raw_description,
|
|
||||||
:required_data_message,
|
|
||||||
:force_final,
|
|
||||||
required_data: mapped_params,
|
|
||||||
permitted_params: mapped_params,
|
|
||||||
condition: mapped_params,
|
|
||||||
fields: [
|
fields: [
|
||||||
*CustomWizard::Field.type_attributes(:permitted),
|
*CustomWizard::Field.type_attributes(:permitted),
|
||||||
CustomWizard::Field.type_attributes(:mapped).map do |attribute|
|
CustomWizard::Field.type_attributes(:mapped).map do |attribute|
|
||||||
|
|
|
@ -3,25 +3,61 @@
|
||||||
class CustomWizard::Step
|
class CustomWizard::Step
|
||||||
include ActiveModel::SerializerSupport
|
include ActiveModel::SerializerSupport
|
||||||
|
|
||||||
attr_reader :id,
|
def self.attribute_map
|
||||||
:updater
|
{
|
||||||
|
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,
|
def self.type_attributes(type)
|
||||||
:title,
|
attribute_map.map { |attribute, props| props.include?(type.to_sym) ? attribute : nil }.compact
|
||||||
:description,
|
end
|
||||||
:key,
|
|
||||||
:permitted,
|
def self.all_attributes
|
||||||
:permitted_message,
|
attribute_map.keys
|
||||||
:fields,
|
end
|
||||||
:next,
|
|
||||||
:previous,
|
def self.accessible_attributes
|
||||||
:banner,
|
type_attributes(:accessible)
|
||||||
:disabled,
|
end
|
||||||
:description_vars,
|
|
||||||
:last_step,
|
def self.included_attributes
|
||||||
:force_final,
|
all_attributes - excluded_attributes
|
||||||
:conditional_final_step,
|
end
|
||||||
:wizard
|
|
||||||
|
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)
|
def initialize(id)
|
||||||
@id = id
|
@id = id
|
||||||
|
|
Laden …
In neuem Issue referenzieren