1
0
Fork 0
Dieser Commit ist enthalten in:
Angus McLeod 2020-03-22 17:47:56 +11:00
Ursprung 2e6ab27ea0
Commit ffde10c217
10 geänderte Dateien mit 79 neuen und 52 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,6 @@ import { gt } from "@ember/object/computed";
export default Ember.Component.extend({ export default Ember.Component.extend({
classNames: 'pair', classNames: 'pair',
connectorNone: 'admin.wizard.connector.none', connectorNone: 'admin.wizard.connector.none',
connectors: connectors.map(c => ({ id: c, name: I18n.t(`admin.wizard.connector.${c}`) })), connectors: connectors,
showRemove: gt('pair.index', 0) showRemove: gt('pair.index', 0)
}) })

Datei anzeigen

@ -1,11 +1,16 @@
import { observes, default as computed } from 'discourse-common/utils/decorators'; import {
observes,
on,
default as computed
} from 'discourse-common/utils/decorators';
export default Ember.Component.extend({ export default Ember.Component.extend({
classNames: 'wizard-custom-step', classNames: 'wizard-custom-step',
currentField: null, currentField: null,
currentAction: null, currentAction: null,
disableId: Ember.computed.not('step.isNew'), disableId: Ember.computed.not('step.isNew'),
@on('didInsertElement')
@observes('step') @observes('step')
resetCurrentObjects() { resetCurrentObjects() {
const fields = this.get('step.fields'); const fields = this.get('step.fields');

Datei anzeigen

@ -13,7 +13,6 @@ export default {
}); });
this.route('adminWizardsTransfer', { path: '/transfer', resetNamespace: true }); this.route('adminWizardsTransfer', { path: '/transfer', resetNamespace: true });
}); });
} }
}; };

Datei anzeigen

@ -23,7 +23,22 @@ const profileFields = [
]; ];
const connectors = [ const connectors = [
'equal' {
id: 'eq',
name: '='
},{
id: 'gt',
name: '>'
},{
id: 'lt',
name: '<'
},{
id: 'gte',
name: '>='
},{
id: 'lte',
name: '<='
}
] ]
const actionTypes = [ const actionTypes = [
@ -58,7 +73,7 @@ function newPair(options = {}, index) {
key_type: 'text', key_type: 'text',
value: '', value: '',
value_type: 'text', value_type: 'text',
connector: 'equal' connector: 'eq'
} }
return Ember.Object.create(params); return Ember.Object.create(params);

Datei anzeigen

@ -78,7 +78,7 @@
<div class="setting-value"> <div class="setting-value">
{{input type='checkbox' checked=model.after_time}} {{input type='checkbox' checked=model.after_time}}
<span>{{i18n 'admin.wizard.after_time_label'}}</span> <span>{{i18n 'admin.wizard.after_time_label'}}</span>
{{d-button action='setNextSessionScheduled' translatedLabel=nextSessionScheduledLabel icon='calendar-o'}} {{d-button action='setNextSessionScheduled' translatedLabel=nextSessionScheduledLabel icon='far-calendar'}}
</div> </div>
</div> </div>
@ -111,7 +111,9 @@
content=model.themes content=model.themes
valueProperty='id' valueProperty='id'
value=model.theme_id value=model.theme_id
none='admin.wizard.no_theme'}} options=(hash
none='admin.wizard.no_theme'
)}}
</div> </div>
</div> </div>

Datei anzeigen

@ -92,7 +92,9 @@
{{combo-box {{combo-box
value=api.authType value=api.authType
content=authorizationTypes content=authorizationTypes
none='admin.wizard.api.auth.type_none'}} options=(hash
none='admin.wizard.api.auth.type_none'
)}}
</div> </div>
</div> </div>
@ -246,15 +248,21 @@
{{combo-box {{combo-box
content=endpointMethods content=endpointMethods
value=endpoint.method value=endpoint.method
none="admin.wizard.api.endpoint.method"}} options=(hash
none="admin.wizard.api.endpoint.method"
)}}
{{combo-box {{combo-box
content=contentTypes content=contentTypes
value=endpoint.content_type value=endpoint.content_type
none="admin.wizard.api.endpoint.content_type"}} options=(hash
none="admin.wizard.api.endpoint.content_type"
)}}
{{multi-select {{multi-select
content=successCodes content=successCodes
values=endpoint.success_codes values=endpoint.success_codes
none="admin.wizard.api.endpoint.success_codes"}} options=(hash
none="admin.wizard.api.endpoint.success_codes"
)}}
</div> </div>
</div> </div>
</div> </div>

Datei anzeigen

@ -15,7 +15,9 @@
{{combo-box {{combo-box
value=action.type value=action.type
content=types content=types
none="admin.wizard.field.type"}} options=(hash
none="admin.wizard.field.type"
)}}
</div> </div>
</div> </div>
@ -30,7 +32,9 @@
content=wizardFields content=wizardFields
nameProperty="label" nameProperty="label"
isDisabled=action.custom_title_enabled isDisabled=action.custom_title_enabled
none='admin.wizard.select_field'}} options=(hash
none='admin.wizard.select_field'
)}}
<div class="setting-gutter"> <div class="setting-gutter">
{{input type='checkbox' checked=action.custom_title_enabled}} {{input type='checkbox' checked=action.custom_title_enabled}}
<span>{{i18n 'admin.wizard.action.custom_title'}}</span> <span>{{i18n 'admin.wizard.action.custom_title'}}</span>
@ -51,7 +55,9 @@
content=wizardFields content=wizardFields
nameProperty='label' nameProperty='label'
isDisabled=action.post_builder isDisabled=action.post_builder
none='admin.wizard.select_field'}} options=(hash
none='admin.wizard.select_field'
)}}
<div class="setting-gutter"> <div class="setting-gutter">
{{input type='checkbox' checked=action.post_builder}} {{input type='checkbox' checked=action.post_builder}}
<span>{{i18n 'admin.wizard.action.post_builder.checkbox'}}</span> <span>{{i18n 'admin.wizard.action.post_builder.checkbox'}}</span>
@ -100,7 +106,9 @@
value=action.category_id value=action.category_id
content=categoryFields content=categoryFields
nameProperty="label" nameProperty="label"
none='admin.wizard.select_field'}} options=(hash
none='admin.wizard.select_field'
)}}
{{/if}} {{/if}}
</div> </div>
<div> <div>
@ -137,7 +145,9 @@
value=action.custom_tag_field value=action.custom_tag_field
content=tagFields content=tagFields
nameProperty="label" nameProperty="label"
none='admin.wizard.select_field'}} options=(hash
none='admin.wizard.select_field'
)}}
</div> </div>
{{/if}} {{/if}}
</div> </div>
@ -181,7 +191,9 @@
value=action.required value=action.required
content=wizardFields content=wizardFields
nameProperty='label' nameProperty='label'
none='admin.wizard.select_field'}} options=(hash
none='admin.wizard.select_field'
)}}
</div> </div>
</div> </div>
@ -231,7 +243,9 @@
value=action.api value=action.api
content=availableApis content=availableApis
isDisabled=action.custom_title_enabled isDisabled=action.custom_title_enabled
none='admin.wizard.action.send_to_api.select_an_api'}} options=(hash
none='admin.wizard.action.send_to_api.select_an_api'
)}}
</div> </div>
</div> </div>
@ -244,7 +258,9 @@
value=action.api_endpoint value=action.api_endpoint
content=availableEndpoints content=availableEndpoints
isDisabled=apiEmpty isDisabled=apiEmpty
none='admin.wizard.action.send_to_api.select_an_endpoint'}} options=(hash
none='admin.wizard.action.send_to_api.select_an_endpoint'
)}}
</div> </div>
</div> </div>
@ -273,7 +289,9 @@
content=wizardFields content=wizardFields
isDisabled=action.custom isDisabled=action.custom
nameProperty="label" nameProperty="label"
none='admin.wizard.select_field'}} options=(hash
none='admin.wizard.select_field'
)}}
<div class="setting-gutter"> <div class="setting-gutter">
{{input type='checkbox' checked=action.custom_group_enabled}} {{input type='checkbox' checked=action.custom_group_enabled}}

Datei anzeigen

@ -51,7 +51,9 @@
{{combo-box {{combo-box
value=field.type value=field.type
content=types content=types
none="admin.wizard.field.type"}} options=(hash
none="admin.wizard.field.type"
)}}
</div> </div>
</div> </div>
@ -85,7 +87,9 @@
{{combo-box {{combo-box
value=field.choices_type value=field.choices_type
content=choicesTypes content=choicesTypes
none="admin.wizard.field.choices_type"}} options=(hash
none="admin.wizard.field.choices_type"
)}}
{{#if choicesTranslation}} {{#if choicesTranslation}}
<div class="wizard-header small"> <div class="wizard-header small">

Datei anzeigen

@ -69,7 +69,6 @@ en:
connector: connector:
none: "op" none: "op"
prefill: "prefill" prefill: "prefill"
equal: "="
error: error:
name_required: "Wizards must have a name." name_required: "Wizards must have a name."

Datei anzeigen

@ -45,7 +45,11 @@ class CustomWizard::Builder
USER_FIELDS = ['name', 'username', 'email', 'date_of_birth', 'title', 'locale'] USER_FIELDS = ['name', 'username', 'email', 'date_of_birth', 'title', 'locale']
PROFILE_FIELDS = ['location', 'website', 'bio_raw', 'profile_background', 'card_background'] PROFILE_FIELDS = ['location', 'website', 'bio_raw', 'profile_background', 'card_background']
OPERATORS = { OPERATORS = {
'equal': '==' 'eq': '==',
'gt': '>',
'lt': '<',
'gte': '>=',
'lte': '<='
} }
def self.fill_placeholders(string, user, data) def self.fill_placeholders(string, user, data)
@ -272,35 +276,20 @@ class CustomWizard::Builder
output = nil output = nil
prefill.each do |item| prefill.each do |item|
puts "PREFIL: #{item.inspect}"
if validate_pairs(item['pairs']) if validate_pairs(item['pairs'])
puts "OUTPUT: #{get_field(item['output'], item['output_type'])}"
output = get_field(item['output'], item['output_type']) output = get_field(item['output'], item['output_type'])
end end
end end
output output
else
actions = step_template['actions']
if actions && actions.any?
profile_actions = actions.select { |a| a['type'] === 'update_profile' } || []
profile_actions.each do |action|
update = action['profile_updates'].select { |u| u['key'] === field_template['id'] }.first
get_user_field(update['value']) if update
end
end
end end
end end
def validate_pairs(pairs) def validate_pairs(pairs)
failed = false failed = false
pairs.each do |pair| pairs.each do |pair|
puts "PAIR: #{pair.inspect}"
key = get_field(pair['key'], pair['key_type']) key = get_field(pair['key'], pair['key_type'])
value = get_field(pair['value'], pair['value_type']) value = get_field(pair['value'], pair['value_type'])
puts "KEY VALUE: #{key.inspect}; #{value.inspect}"
failed = true unless key.public_send(get_operator(pair['connector']), value) failed = true unless key.public_send(get_operator(pair['connector']), value)
end end
!failed !failed
@ -516,18 +505,6 @@ class CustomWizard::Builder
action['profile_updates'].each do |pu| action['profile_updates'].each do |pu|
value = pu['value'] value = pu['value']
custom_field = nil
if pu['value_custom'].present?
custom_parts = pu['value_custom'].split('.')
if custom_parts.length == 2 && custom_parts[0] == 'custom_field'
custom_field = custom_parts[1]
else
value = custom_parts[0]
end
end
user_field = pu['user_field']
key = pu['key'] key = pu['key']
return if data[key].blank? return if data[key].blank?