Add min trust setting
Dieser Commit ist enthalten in:
Ursprung
40465a3fb7
Commit
f7c1170e07
10 geänderte Dateien mit 75 neuen und 23 gelöschten Zeilen
|
@ -9,7 +9,8 @@ const wizardProperties = [
|
|||
'after_time',
|
||||
'after_time_scheduled',
|
||||
'required',
|
||||
'prompt_completion'
|
||||
'prompt_completion',
|
||||
'min_trust'
|
||||
];
|
||||
|
||||
const CustomWizard = Discourse.Model.extend({
|
||||
|
@ -245,6 +246,7 @@ CustomWizard.reopenClass({
|
|||
props['after_time'] = false;
|
||||
props['required'] = false;
|
||||
props['prompt_completion'] = false;
|
||||
props['min_trust'] = 0;
|
||||
props['steps'] = Ember.A();
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</div>
|
||||
<div class="setting-value">
|
||||
{{input type='checkbox' checked=model.save_submissions}}
|
||||
<span for="save">{{i18n 'admin.wizard.save_submissions_label'}}</span>
|
||||
<span>{{i18n 'admin.wizard.save_submissions_label'}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
</div>
|
||||
<div class="setting-value">
|
||||
{{input type='checkbox' checked=model.multiple_submissions}}
|
||||
<span for="save">{{i18n 'admin.wizard.multiple_submissions_label'}}</span>
|
||||
<span>{{i18n 'admin.wizard.multiple_submissions_label'}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
|||
</div>
|
||||
<div class="setting-value">
|
||||
{{input type='checkbox' checked=model.required}}
|
||||
<span for="save">{{i18n 'admin.wizard.required_label'}}</span>
|
||||
<span>{{i18n 'admin.wizard.required_label'}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
|||
</div>
|
||||
<div class="setting-value">
|
||||
{{input type='checkbox' checked=model.after_signup}}
|
||||
<span for="save">{{i18n 'admin.wizard.after_signup_label'}}</span>
|
||||
<span>{{i18n 'admin.wizard.after_signup_label'}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -77,7 +77,7 @@
|
|||
</div>
|
||||
<div class="setting-value">
|
||||
{{input type='checkbox' checked=model.after_time}}
|
||||
<span for="save">{{i18n 'admin.wizard.after_time_label'}}</span>
|
||||
<span>{{i18n 'admin.wizard.after_time_label'}}</span>
|
||||
{{d-button action='setNextSessionScheduled' translatedLabel=nextSessionScheduledLabel icon='calendar-o'}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -88,7 +88,17 @@
|
|||
</div>
|
||||
<div class="setting-value">
|
||||
{{input type='checkbox' checked=model.prompt_completion}}
|
||||
<span for="save">{{i18n 'admin.wizard.prompt_completion_label'}}</span>
|
||||
<span>{{i18n 'admin.wizard.prompt_completion_label'}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting">
|
||||
<div class="setting-label">
|
||||
<h3>{{i18n 'admin.wizard.min_trust'}}</h3>
|
||||
</div>
|
||||
<div class="setting-value">
|
||||
<span>{{i18n 'admin.wizard.min_trust_label'}}</span>
|
||||
{{input type='number' value=model.min_trust class='input-small'}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
export default Ember.Route.extend({
|
||||
beforeModel() {
|
||||
const appModel = this.modelFor('custom');
|
||||
|
||||
if (appModel) {
|
||||
if (appModel.completed) {
|
||||
this.set('completed', true);
|
||||
} else if (appModel.start) {
|
||||
this.replaceWith('custom.step', appModel.start);
|
||||
}
|
||||
if (appModel.permitted && !appModel.completed && appModel.start) {
|
||||
this.replaceWith('custom.step', appModel.start);
|
||||
}
|
||||
},
|
||||
|
||||
setupController(controller) {
|
||||
const completed = this.get('completed');
|
||||
controller.set('completed', completed);
|
||||
model() {
|
||||
return this.modelFor('custom');
|
||||
},
|
||||
|
||||
setupController(controller, model) {
|
||||
const completed = model.get('completed');
|
||||
const permitted = model.get('permitted');
|
||||
const minTrust = model.get('min_trust');
|
||||
controller.setProperties({
|
||||
completed,
|
||||
notPermitted: !permitted,
|
||||
minTrust
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
{{#if completed}}
|
||||
{{i18n 'wizard.completed'}}
|
||||
{{else}}
|
||||
{{#if notPermitted}}
|
||||
{{i18n 'wizard.not_permitted' level=minTrust}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
.wizard-step-contents {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wizard-step-description {
|
||||
|
@ -19,7 +21,8 @@
|
|||
}
|
||||
|
||||
.image-container {
|
||||
padding: 0 40px;
|
||||
padding: 0 20px;
|
||||
margin: 60px 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
|
@ -39,7 +42,7 @@
|
|||
|
||||
img.small {
|
||||
width: 120;
|
||||
padding: 10px;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
img.x-small {
|
||||
|
@ -57,6 +60,7 @@
|
|||
position: absolute;
|
||||
bottom: 0;
|
||||
font-style: italic;
|
||||
margin-bottom: 20px;
|
||||
|
||||
img {
|
||||
width: 30px;
|
||||
|
@ -94,7 +98,7 @@
|
|||
|
||||
.wizard-step-form .wizard-btn {
|
||||
display: block;
|
||||
margin: 10px 0;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.wizard-column .wizard-field .input-area {
|
||||
|
|
|
@ -32,6 +32,8 @@ en:
|
|||
required_label: "Users cannot skip the wizard."
|
||||
prompt_completion: "Prompt"
|
||||
prompt_completion_label: "Prompt user to complete wizard."
|
||||
min_trust: "Trust"
|
||||
min_trust_label: "Trust level required to access wizard."
|
||||
save: "Save Changes"
|
||||
remove: "Delete Wizard"
|
||||
header: "Wizard"
|
||||
|
@ -145,3 +147,4 @@ en:
|
|||
|
||||
wizard:
|
||||
completed: "You have completed this wizard."
|
||||
not_permitted: "You need to be trust level {{level}} or higher to access this wizard."
|
||||
|
|
|
@ -16,7 +16,8 @@ class CustomWizard::Builder
|
|||
name: data["name"],
|
||||
after_time: data["after_time"],
|
||||
after_signup: data["after_signup"],
|
||||
required: data["required"]
|
||||
required: data["required"],
|
||||
min_trust: data["min_trust"]
|
||||
)
|
||||
@submissions = Array.wrap(PluginStore.get("#{wizard_id}_submissions", user.id))
|
||||
end
|
||||
|
@ -48,7 +49,7 @@ class CustomWizard::Builder
|
|||
end
|
||||
|
||||
def build
|
||||
unless (@wizard.completed? && !@wizard.multiple_submissions) || !@steps
|
||||
unless (@wizard.completed? && !@wizard.multiple_submissions) || !@steps || !@wizard.permitted?
|
||||
@steps.each do |s|
|
||||
@wizard.append_step(s['id']) do |step|
|
||||
step.title = s['title'] if s['title']
|
||||
|
|
|
@ -7,6 +7,7 @@ class CustomWizard::Template
|
|||
:save_submissions,
|
||||
:multiple_submissions,
|
||||
:prompt_completion,
|
||||
:min_trust,
|
||||
:after_signup,
|
||||
:after_time,
|
||||
:after_time_scheduled,
|
||||
|
@ -21,6 +22,7 @@ class CustomWizard::Template
|
|||
@save_submissions = data['save_submissions'] || false
|
||||
@multiple_submissions = data['multiple_submissions'] || false
|
||||
@prompt_completion = data['prompt_completion'] || false
|
||||
@min_trust = data['min_trust'] || 0
|
||||
@after_signup = data['after_signup']
|
||||
@after_time = data['after_time']
|
||||
@after_time_scheduled = data['after_time_scheduled']
|
||||
|
|
|
@ -11,6 +11,7 @@ class CustomWizard::Wizard
|
|||
:background,
|
||||
:save_submissions,
|
||||
:multiple_submissions,
|
||||
:min_trust,
|
||||
:after_time,
|
||||
:after_signup,
|
||||
:required,
|
||||
|
@ -107,6 +108,10 @@ class CustomWizard::Wizard
|
|||
(steps - completed).empty?
|
||||
end
|
||||
|
||||
def permitted?
|
||||
user.staff? || user.trust_level.to_i >= min_trust.to_i
|
||||
end
|
||||
|
||||
def self.after_signup
|
||||
rows = PluginStoreRow.where(plugin_name: 'custom_wizard')
|
||||
wizards = [*rows].select { |r| r.value['after_signup'] }
|
||||
|
|
|
@ -48,7 +48,7 @@ class ::Wizard::Step
|
|||
end
|
||||
|
||||
::WizardSerializer.class_eval do
|
||||
attributes :id, :background, :completed, :required
|
||||
attributes :id, :background, :completed, :required, :min_trust, :permitted
|
||||
|
||||
def id
|
||||
object.id
|
||||
|
@ -74,6 +74,22 @@ end
|
|||
object.completed? && (!object.respond_to?(:multiple_submissions) || !object.multiple_submissions)
|
||||
end
|
||||
|
||||
def min_trust
|
||||
object.min_trust
|
||||
end
|
||||
|
||||
def include_min_trust?
|
||||
object.respond_to?(:min_trust)
|
||||
end
|
||||
|
||||
def permitted
|
||||
object.permitted?
|
||||
end
|
||||
|
||||
def inlcude_permitted?
|
||||
object.respond_to?(:permitted)
|
||||
end
|
||||
|
||||
def include_start?
|
||||
object.start && include_steps?
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren