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 = [];
|
input.pairs = [];
|
||||||
|
|
||||||
inpt.pairs.forEach((pr) => {
|
inpt.pairs.forEach((pr) => {
|
||||||
if (present(pr.key) && present(pr.value)) {
|
if ((present(pr.key) && present(pr.value)) || pr.key_type == "wizardUser") {
|
||||||
let pairParams = {
|
let pairParams = {
|
||||||
index: pr.index,
|
index: pr.index,
|
||||||
key: pr.key,
|
key: pr.key,
|
||||||
|
|
|
@ -106,7 +106,12 @@ class CustomWizard::Mapper
|
||||||
pairs.all? do |pair|
|
pairs.all? do |pair|
|
||||||
connector = pair['connector']
|
connector = pair['connector']
|
||||||
operator = map_operator(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)
|
value = cast_value(map_field(pair['value'], pair['value_type']), key, connector)
|
||||||
begin
|
begin
|
||||||
validation_result(key, value, operator)
|
validation_result(key, value, operator)
|
||||||
|
@ -119,6 +124,8 @@ class CustomWizard::Mapper
|
||||||
def cast_value(value, key, connector)
|
def cast_value(value, key, connector)
|
||||||
if connector == 'regex'
|
if connector == 'regex'
|
||||||
Regexp.new(value)
|
Regexp.new(value)
|
||||||
|
elsif connector == 'in'
|
||||||
|
value.to_a
|
||||||
else
|
else
|
||||||
if key.is_a?(String)
|
if key.is_a?(String)
|
||||||
value.to_s
|
value.to_s
|
||||||
|
@ -140,7 +147,7 @@ class CustomWizard::Mapper
|
||||||
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value))
|
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value))
|
||||||
end
|
end
|
||||||
elsif operator === 'in'
|
elsif operator === 'in'
|
||||||
result = value.includes?(key)
|
result = value.include?(key)
|
||||||
elsif [key, value, operator].all? { |i| !i.nil? }
|
elsif [key, value, operator].all? { |i| !i.nil? }
|
||||||
result = key.public_send(operator, value)
|
result = key.public_send(operator, value)
|
||||||
else
|
else
|
||||||
|
@ -216,7 +223,7 @@ class CustomWizard::Mapper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def map_current_user(value)
|
def map_wizard_user(value)
|
||||||
@user.username
|
@user.username
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Laden …
In neuem Issue referenzieren