0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

Fix dropdown choices && wizard start

Dieser Commit ist enthalten in:
Angus McLeod 2017-11-08 16:52:50 +08:00
Ursprung a784d4a33e
Commit 8c173a7b17
5 geänderte Dateien mit 26 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -5,9 +5,9 @@ export default Ember.Component.extend({
isDropdown: Ember.computed.equal('field.type', 'dropdown'), isDropdown: Ember.computed.equal('field.type', 'dropdown'),
disableId: Ember.computed.not('field.isNew'), disableId: Ember.computed.not('field.isNew'),
choicesTypes: ['translation', 'preset', 'custom'], choicesTypes: ['translation', 'preset', 'custom'],
choicesTranslation: Ember.computed.equal('choicesType', 'translation'), choicesTranslation: Ember.computed.equal('field.choices_type', 'translation'),
choicesPreset: Ember.computed.equal('choicesType', 'preset'), choicesPreset: Ember.computed.equal('field.choices_type', 'preset'),
choicesCustom: Ember.computed.equal('choicesType', 'custom'), choicesCustom: Ember.computed.equal('field.choices_type', 'custom'),
@computed('field.type') @computed('field.type')
isInput: (type) => type === 'text' || type === 'textarea', isInput: (type) => type === 'text' || type === 'textarea',

Datei anzeigen

@ -70,7 +70,7 @@
{{i18n 'admin.wizard.field.choices_label'}} {{i18n 'admin.wizard.field.choices_label'}}
</div> </div>
{{combo-box value=choicesType content=choicesTypes none="admin.wizard.field.choices_type"}} {{combo-box value=field.choices_type content=choicesTypes none="admin.wizard.field.choices_type"}}
{{#if choicesTranslation}} {{#if choicesTranslation}}
<div class="wizard-header small"> <div class="wizard-header small">

Datei anzeigen

@ -64,6 +64,10 @@
height: 20px; height: 20px;
vertical-align: middle; vertical-align: middle;
} }
.combo-box ul {
padding: 0;
}
} }
.step-message { .step-message {

Datei anzeigen

@ -100,7 +100,14 @@ class CustomWizard::Builder
if f['choices_filters'] && f['choices_filters'].length > 0 if f['choices_filters'] && f['choices_filters'].length > 0
f['choices_filters'].each do |f| f['choices_filters'].each do |f|
objects.reject! { |o| o[f['key']] != f['value'] } objects.reject! do |o|
prop = f['key']
if prop.include? 'custom_fields'
o.custom_fields[prop.split('.')[1]].to_s != f['value'].to_s
else
o[prop].to_s != f['value'].to_s
end
end
end end
end end

Datei anzeigen

@ -51,19 +51,18 @@ class CustomWizard::Wizard
end end
def start def start
completed = ::UserHistory.where( if unfinished?
step_id = ::UserHistory.where(
acting_user_id: @user.id, acting_user_id: @user.id,
action: ::UserHistory.actions[:custom_wizard_step], action: ::UserHistory.actions[:custom_wizard_step],
context: @id, context: @id,
subject: @steps.map(&:id) subject: @steps.map(&:id)
).uniq.pluck(:subject) ).order("created_at").last.subject
@steps.find { |s| s.id == step_id }
@steps.each do |s| else
return s unless completed.include?(s.id)
end
@first_step @first_step
end end
end
def create_updater(step_id, fields) def create_updater(step_id, fields)
step = @steps.find { |s| s.id == step_id } step = @steps.find { |s| s.id == step_id }