0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-19 15:21:11 +02:00

Fix start step && add dropdown none

Dieser Commit ist enthalten in:
Angus McLeod 2017-11-09 10:50:48 +08:00
Ursprung 8c173a7b17
Commit 75d4fcaab5
8 geänderte Dateien mit 42 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -96,5 +96,10 @@
</div>
{{wizard-custom-input inputs=field.choices}}
{{/if}}
<div class="wizard-header small">
{{i18n 'admin.wizard.field.dropdown_none'}}
</div>
{{input name="dropdown_none" value=field.dropdown_none placeholder=(i18n 'admin.wizard.field.dropdown_none_placeholder')}}
</div>
{{/if}}

Datei anzeigen

@ -0,0 +1,7 @@
{{combo-box elementId=field.id
class=fieldClass
value=field.value
content=field.choices
none=field.dropdown_none
nameProperty="label"
tabindex="9"}}

Datei anzeigen

@ -38,14 +38,22 @@
{{#if showNextButton}}
<button class='wizard-btn next primary' {{action "nextStep"}} disabled={{saving}} tabindex="10">
{{i18n "wizard.next"}}
{{d-icon "chevron-right"}}
{{#if saving}}
{{loading-spinner size='small'}}
{{else}}
{{i18n "wizard.next"}}
{{d-icon "chevron-right"}}
{{/if}}
</button>
{{/if}}
{{#if showDoneButton}}
<button class='wizard-btn done' {{action "done"}} disabled={{saving}} tabindex="10">
{{i18n "wizard.done"}}
{{#if saving}}
{{loading-spinner size='small'}}
{{else}}
{{i18n "wizard.done"}}
{{/if}}
</button>
{{/if}}
</div>

Datei anzeigen

@ -68,6 +68,11 @@
.combo-box ul {
padding: 0;
}
.wizard-buttons > a, .wizard-buttons > button {
display: inline-block;
vertical-align: middle;
}
}
.step-message {

Datei anzeigen

@ -60,6 +60,8 @@ en:
header: "Fields"
label: "Label"
description: "Description"
dropdown_none: "None"
dropdown_none_placeholder: "Translation Key"
choices_label: "Dropdown Choices"
choices_type: "Choose a type"
choices_translation: "Translation"

Datei anzeigen

@ -80,6 +80,8 @@ class CustomWizard::Builder
field = step.add_field(params)
if f['type'] === 'dropdown'
field.dropdown_none = f['dropdown_none'] if f['dropdown_none']
if f['choices'] && f['choices'].length > 0
f['choices'].each do |c|
field.add_choice(c['value'], label: c['label'])

Datei anzeigen

@ -58,7 +58,8 @@ class CustomWizard::Wizard
context: @id,
subject: @steps.map(&:id)
).order("created_at").last.subject
@steps.find { |s| s.id == step_id }
last_index = @steps.index { |s| s.id == step_id }
@steps[last_index + 1]
else
@first_step
end

Datei anzeigen

@ -25,6 +25,7 @@ end
::Wizard::Field.class_eval do
attr_reader :label, :description, :key, :min_length
attr_accessor :dropdown_none
def initialize(attrs)
attrs = attrs || {}
@ -38,6 +39,7 @@ end
@min_length = attrs[:min_length]
@value = attrs[:value]
@choices = []
@dropdown_none = attrs[:dropdown_none]
end
end
@ -102,6 +104,8 @@ end
end
::WizardFieldSerializer.class_eval do
attributes :dropdown_none
def label
return object.label if object.label
I18n.t("#{object.key || i18n_key}.label", default: '')
@ -115,4 +119,8 @@ end
def placeholder
I18n.t("#{object.key || i18n_key}.placeholder", default: '')
end
def dropdown_none
object.dropdown_none
end
end