0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-19 23:31:11 +02:00
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({
classNames: 'pair',
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)
})

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({
classNames: 'wizard-custom-step',
currentField: null,
currentAction: null,
disableId: Ember.computed.not('step.isNew'),
@on('didInsertElement')
@observes('step')
resetCurrentObjects() {
const fields = this.get('step.fields');

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -78,7 +78,7 @@
<div class="setting-value">
{{input type='checkbox' checked=model.after_time}}
<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>
@ -111,7 +111,9 @@
content=model.themes
valueProperty='id'
value=model.theme_id
none='admin.wizard.no_theme'}}
options=(hash
none='admin.wizard.no_theme'
)}}
</div>
</div>

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -69,7 +69,6 @@ en:
connector:
none: "op"
prefill: "prefill"
equal: "="
error:
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']
PROFILE_FIELDS = ['location', 'website', 'bio_raw', 'profile_background', 'card_background']
OPERATORS = {
'equal': '=='
'eq': '==',
'gt': '>',
'lt': '<',
'gte': '>=',
'lte': '<='
}
def self.fill_placeholders(string, user, data)
@ -272,35 +276,20 @@ class CustomWizard::Builder
output = nil
prefill.each do |item|
puts "PREFIL: #{item.inspect}"
if validate_pairs(item['pairs'])
puts "OUTPUT: #{get_field(item['output'], item['output_type'])}"
output = get_field(item['output'], item['output_type'])
end
end
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
def validate_pairs(pairs)
failed = false
pairs.each do |pair|
puts "PAIR: #{pair.inspect}"
key = get_field(pair['key'], pair['key_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)
end
!failed
@ -516,18 +505,6 @@ class CustomWizard::Builder
action['profile_updates'].each do |pu|
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']
return if data[key].blank?