0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-15 22:32:54 +01:00

dynamically generate permitted params for admin wizard save

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-05-24 07:03:30 +05:30
Ursprung ce705d32da
Commit f9f67c09e8
2 geänderte Dateien mit 22 neuen und 36 gelöschten Zeilen

Datei anzeigen

@ -102,26 +102,10 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
permitted_params: mapped_params, permitted_params: mapped_params,
condition: mapped_params, condition: mapped_params,
fields: [ fields: [
:id, *CustomWizard::Field.type_attributes(:permitted),
:index, CustomWizard::Field.type_attributes(:mapped).map do |attribute|
:label, [attribute, mapped_params]
:image, end.to_h
:description,
:required,
:key,
:type,
:min_length,
:max_length,
:char_counter,
:file_types,
:format,
:limit,
:property,
prefill: mapped_params,
content: mapped_params,
condition: mapped_params,
index: mapped_params,
validations: {},
] ]
], ],
actions: [ actions: [

Datei anzeigen

@ -6,27 +6,29 @@ class CustomWizard::Field
def self.attribute_map def self.attribute_map
{ {
raw: [], raw: [],
id: [:serializable], id: [:serializable, :permitted],
index: [:accessible, :serializable], index: [:accessible, :serializable, :permitted, :mapped],
type: [:serializable], type: [:serializable, :permitted],
step: [:accessible], step: [:accessible],
required: [:serializable], required: [:serializable, :permitted],
value: [:serializable], value: [:serializable],
description: [:serializable], description: [:serializable, :permitted],
image: [:serializable], image: [:serializable, :permitted],
key: [], key: [:permitted],
validations: [:serializable], validations: [:serializable],
min_length: [], min_length: [:permitted],
max_length: [:serializable], max_length: [:serializable, :permitted],
char_counter: [:serializable], char_counter: [:serializable, :permitted],
file_types: [:serializable], file_types: [:serializable, :permitted],
format: [:serializable], format: [:serializable, :permitted],
limit: [:serializable], limit: [:serializable, :permitted],
property: [:serializable], property: [:serializable, :permitted],
content: [:serializable],
# label is excluded so that it isn't initialized and the value # label is excluded so that it isn't initialized and the value
# returned by `label` method is used for serialization # returned by `label` method is used for serialization
label: [:excluded, :serializable] label: [:excluded, :serializable, :permitted],
content: [:serializable, :permitted, :mapped],
prefill: [:permitted, :mapped],
condition: [:permitted, :mapped],
} }
end end