0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00

Add required data message

Dieser Commit ist enthalten in:
Angus McLeod 2019-07-27 17:01:29 +10:00
Ursprung c058340c84
Commit 802f7d1fd5
10 geänderte Dateien mit 60 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -78,6 +78,7 @@ const CustomWizard = Discourse.Model.extend({
if (s.banner) step['banner'] = s.banner; if (s.banner) step['banner'] = s.banner;
if (s.raw_description) step['raw_description'] = s.raw_description; if (s.raw_description) step['raw_description'] = s.raw_description;
if (s.required_data) step['required_data'] = s.required_data; if (s.required_data) step['required_data'] = s.required_data;
if (s.required_data_message) step['required_data_message'] = s.required_data_message;
if (s.permitted_params) step['permitted_params'] = s.permitted_params; if (s.permitted_params) step['permitted_params'] = s.permitted_params;
const fields = s.get('fields'); const fields = s.get('fields');
@ -245,6 +246,7 @@ CustomWizard.reopenClass({
raw_description: s.raw_description, raw_description: s.raw_description,
banner: s.banner, banner: s.banner,
required_data: s.required_data, required_data: s.required_data,
required_data_message: s.required_data_message,
permitted_params: s.permitted_params, permitted_params: s.permitted_params,
fields, fields,
actions, actions,

Datei anzeigen

@ -43,7 +43,7 @@
</div> </div>
</div> </div>
<div class="setting full"> <div class="setting required-data full">
<div class="setting-label"> <div class="setting-label">
<h3>{{i18n 'admin.wizard.step.required_data.label'}}</h3> <h3>{{i18n 'admin.wizard.step.required_data.label'}}</h3>
</div> </div>
@ -52,6 +52,12 @@
inputKey='admin.wizard.step.required_data.key' inputKey='admin.wizard.step.required_data.key'
valueContent=requiredContent valueContent=requiredContent
connectorContent=requiredConnectorContent}} connectorContent=requiredConnectorContent}}
{{#if step.required_data}}
<div class="required-data-message">
<label>{{i18n 'admin.wizard.step.required_data.not_permitted_message'}}</label>
{{input value=step.required_data_message}}
</div>
{{/if}}
</div> </div>
</div> </div>

Datei anzeigen

@ -21,6 +21,12 @@ export default StepController.extend({
showMessage(message) { showMessage(message) {
this.set('stepMessage', message); this.set('stepMessage', message);
},
resetWizard() {
const id = this.get('wizard.id');
const stepId = this.get('step.id');
window.location.href = getUrl(`/w/${id}/steps/${stepId}?reset=true`);
} }
} }
}); });

Datei anzeigen

@ -24,8 +24,11 @@ export default Ember.Route.extend({
if (!model.permitted) { if (!model.permitted) {
props['stepMessage'] = { props['stepMessage'] = {
state: 'not-permitted', state: 'not-permitted',
text: "You're not allowed to view this step." text: model.permitted_message || I18n.t('wizard.step_not_permitted')
}; };
if (model.index > 0) {
props['showReset'] = true;
}
} }
controller.setProperties(props); controller.setProperties(props);

Datei anzeigen

@ -1,5 +1,12 @@
<div class="step-message {{stepMessage.state}}"> <div class="step-message {{stepMessage.state}}">
<div class="text">
{{stepMessage.text}} {{stepMessage.text}}
</div>
{{#if showReset}}
<a class="reset-wizard" {{action "resetWizard"}}>
{{i18n 'wizard.reset'}}
</a>
{{/if}}
</div> </div>
{{#if step.permitted}} {{#if step.permitted}}
{{wizard-step step=step {{wizard-step step=step

Datei anzeigen

@ -270,36 +270,35 @@
} }
.step-message { .step-message {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 0;
line-height: 0;
text-align: center; text-align: center;
transition: all .2s; transition: all .2s;
z-index: 2; z-index: 2;
padding: 20px;
&.success { &.success {
height: 60px;
line-height: 60px;
background-color: #009900; background-color: #009900;
color: #ffffff; color: #ffffff;
} }
&.error { &.error {
height: 60px;
line-height: 60px;
background-color: #e45735; background-color: #e45735;
color: #ffffff; color: #ffffff;
} }
&.not-permitted { &.not-permitted {
height: 60px;
line-height: 60px;
background-color: #e45735; background-color: #e45735;
color: #ffffff; color: #ffffff;
} }
.text {
display: inline-block;
}
.reset-wizard {
margin-top: 20px;
text-decoration: underline;
cursor: pointer;
}
} }
.p-list-box { .p-list-box {

Datei anzeigen

@ -222,6 +222,14 @@
} }
} }
.required-data .setting-value {
flex-flow: wrap;
.custom-inputs {
margin-bottom: 20px;
}
}
.setting .add-custom-input { .setting .add-custom-input {
margin-top: 5px; margin-top: 5px;
} }

Datei anzeigen

@ -77,6 +77,7 @@ en:
key: 'Submission key' key: 'Submission key'
connector: connector:
equals: "Equals" equals: "Equals"
not_permitted_message: "Message shown when required data not present"
permitted_params: permitted_params:
label: "Permitted Params" label: "Permitted Params"
key: 'Param' key: 'Param'
@ -279,6 +280,8 @@ en:
none: "There is no wizard here." none: "There is no wizard here."
return_to_site: "Return to {{siteName}}" return_to_site: "Return to {{siteName}}"
requires_login: "You need to be logged in to access the {{name}} wizard." requires_login: "You need to be logged in to access the {{name}} wizard."
reset: "Reset this wizard."
step_not_permitted: "You're not allowed to view this step."
wizard_composer: wizard_composer:
show_preview: "Preview Post" show_preview: "Preview Post"

Datei anzeigen

@ -95,7 +95,10 @@ class CustomWizard::Builder
end end
end end
next if !step.permitted if !step.permitted
step.permitted_message = step_template['required_data_message'] if step_template['required_data_message']
next
end
end end
if step_template['fields'] && step_template['fields'].length if step_template['fields'] && step_template['fields'].length

Datei anzeigen

@ -63,7 +63,7 @@ end
end end
class ::Wizard::Step class ::Wizard::Step
attr_accessor :title, :description, :key, :permitted attr_accessor :title, :description, :key, :permitted, :permitted_message
end end
::WizardSerializer.class_eval do ::WizardSerializer.class_eval do
@ -159,7 +159,7 @@ end
end end
::WizardStepSerializer.class_eval do ::WizardStepSerializer.class_eval do
attributes :permitted attributes :permitted, :permitted_message
def title def title
return PrettyText.cook(object.title) if object.title return PrettyText.cook(object.title) if object.title
@ -174,6 +174,10 @@ end
def permitted def permitted
object.permitted object.permitted
end end
def permitted_message
object.permitted_message
end
end end
::WizardFieldSerializer.class_eval do ::WizardFieldSerializer.class_eval do