Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-15 14:22:53 +01:00
various fixes
Dieser Commit ist enthalten in:
Ursprung
3d4c24d362
Commit
3e950036d0
2 geänderte Dateien mit 11 neuen und 4 gelöschten Zeilen
|
@ -161,7 +161,7 @@ const CustomWizard = EmberObject.extend({
|
|||
input.pairs = [];
|
||||
|
||||
inpt.pairs.forEach((pr) => {
|
||||
if (present(pr.key) && present(pr.value)) {
|
||||
if ((present(pr.key) && present(pr.value)) || pr.key_type == "wizardUser") {
|
||||
let pairParams = {
|
||||
index: pr.index,
|
||||
key: pr.key,
|
||||
|
|
|
@ -106,7 +106,12 @@ class CustomWizard::Mapper
|
|||
pairs.all? do |pair|
|
||||
connector = pair['connector']
|
||||
operator = map_operator(connector)
|
||||
key = map_field(pair['key'], pair['key_type'])
|
||||
if pair['key_type'] == 'wizard_user'
|
||||
key = @user.username
|
||||
else
|
||||
key = map_field(pair['key'], pair['key_type'])
|
||||
end
|
||||
|
||||
value = cast_value(map_field(pair['value'], pair['value_type']), key, connector)
|
||||
begin
|
||||
validation_result(key, value, operator)
|
||||
|
@ -119,6 +124,8 @@ class CustomWizard::Mapper
|
|||
def cast_value(value, key, connector)
|
||||
if connector == 'regex'
|
||||
Regexp.new(value)
|
||||
elsif connector == 'in'
|
||||
value.to_a
|
||||
else
|
||||
if key.is_a?(String)
|
||||
value.to_s
|
||||
|
@ -140,7 +147,7 @@ class CustomWizard::Mapper
|
|||
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value))
|
||||
end
|
||||
elsif operator === 'in'
|
||||
result = value.includes?(key)
|
||||
result = value.include?(key)
|
||||
elsif [key, value, operator].all? { |i| !i.nil? }
|
||||
result = key.public_send(operator, value)
|
||||
else
|
||||
|
@ -216,7 +223,7 @@ class CustomWizard::Mapper
|
|||
end
|
||||
end
|
||||
|
||||
def map_current_user(value)
|
||||
def map_wizard_user(value)
|
||||
@user.username
|
||||
end
|
||||
|
||||
|
|
Laden …
In neuem Issue referenzieren