1
0
Fork 0

FIX: make invite topic redirects work and allow them to be used in conditional route_tos

Dieser Commit ist enthalten in:
Angus McLeod 2020-05-01 18:16:58 +10:00
Ursprung e257d60c86
Commit 379e839b71
5 geänderte Dateien mit 26 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -72,6 +72,8 @@ export default Component.extend({
return type ? I18n.t(`admin.wizard.selector.label.${snakeCase(type)}`) : null;
},
comboBoxAllowAny: alias('showWizardField'),
@discourseComputed('activeType')
comboBoxContent(activeType) {
const controller = getOwner(this).lookup('controller:admin-wizards-wizard-show');

Datei anzeigen

@ -35,6 +35,7 @@
onChange=(action "changeValue")
options=(hash
none=placeholderKey
allowAny=comboBoxAllowAny
)}}
{{/if}}

Datei anzeigen

@ -1,7 +1,7 @@
module InvitesControllerCustomWizard
def path(url)
if ::Wizard.user_requires_completion?(@user)
wizard_id = @user.custom_fields['custom_wizard_redirect']
wizard_id = @user.custom_fields['redirect_to_wizard']
if wizard_id && url != '/'
CustomWizard::Wizard.set_submission_redirect(@user, wizard_id, url)

Datei anzeigen

@ -187,7 +187,8 @@ class CustomWizard::Builder
if updater.errors.empty?
if final_step
updater.result[:redirect_on_complete] = route_to || data['redirect_on_complete']
redirect_url = route_to || data['redirect_on_complete'] || data["redirect_to"]
updater.result[:redirect_on_complete] = redirect_url
elsif route_to
updater.result[:redirect_on_next] = route_to
end

Datei anzeigen

@ -15,7 +15,11 @@ class CustomWizard::Mapper
greater_or_equal: '>=',
less_or_equal: '<=',
regex: '=~',
boolean: '=='
boolean: {
present: "present?",
true: "==",
false: "=="
}
}
def initialize(params)
@ -90,9 +94,8 @@ class CustomWizard::Mapper
operator = map_operator(connector)
key = map_field(pair['key'], pair['key_type'])
value = cast_value(map_field(pair['value'], pair['value_type']), key, connector)
begin
cast_result(key.public_send(operator, value), connector)
validation_result(key, value, operator)
rescue NoMethodError
#
end
@ -102,8 +105,6 @@ class CustomWizard::Mapper
def cast_value(value, key, connector)
if connector == 'regex'
Regexp.new(value)
elsif connector == 'boolean'
ActiveRecord::Type::Boolean.new.cast(value)
else
if key.is_a?(String)
value.to_s
@ -115,8 +116,20 @@ class CustomWizard::Mapper
end
end
def cast_result(result, connector)
if connector == 'regex'
def validation_result(key, value, operator)
result = nil
if operator.is_a?(Hash) && (operator = operator[value.to_sym]).present?
if value == "present"
result = key.public_send(operator)
elsif ["true", "false"].include?(value)
result = key.public_send(operator, ActiveRecord::Type::Boolean.new.cast(value))
end
else
result = key.public_send(operator, value)
end
if operator == '=~'
result == 0 ? true : false
else
result