Add pro restriction
Dieser Commit ist enthalten in:
Ursprung
a7904a28af
Commit
f49f516403
11 geänderte Dateien mit 84 neuen und 30 gelöschten Zeilen
|
@ -39,6 +39,7 @@ export default DiscourseRoute.extend({
|
|||
currentStep: wizard.steps[0],
|
||||
currentAction: wizard.actions[0],
|
||||
creating: model.create,
|
||||
proSubscribed: parentModel.pro_subscribed
|
||||
};
|
||||
|
||||
controller.setProperties(props);
|
||||
|
|
|
@ -166,7 +166,8 @@
|
|||
wizard=wizard
|
||||
currentField=currentField
|
||||
wizardFields=wizardFields
|
||||
fieldTypes=fieldTypes}}
|
||||
fieldTypes=fieldTypes
|
||||
proSubscribed=proSubscribed}}
|
||||
{{/if}}
|
||||
|
||||
{{wizard-links
|
||||
|
|
|
@ -213,17 +213,20 @@
|
|||
{{#if field.showAdvanced}}
|
||||
<div class="advanced-settings">
|
||||
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
<label>{{i18n "admin.wizard.condition"}}</label>
|
||||
</div>
|
||||
{{#if proSubscribed}}
|
||||
<div class="setting full field-mapper-setting pro">
|
||||
<div class="setting-label">
|
||||
<label>{{i18n "admin.wizard.condition"}}</label>
|
||||
<span class="pro-label">{{i18n "admin.wizard.pro.label"}}</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-value">
|
||||
{{wizard-mapper
|
||||
inputs=field.condition
|
||||
options=fieldConditionOptions}}
|
||||
<div class="setting-value">
|
||||
{{wizard-mapper
|
||||
inputs=field.condition
|
||||
options=fieldConditionOptions}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
|
|
|
@ -38,26 +38,29 @@
|
|||
{{#if step.showAdvanced}}
|
||||
<div class="advanced-settings">
|
||||
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
<label>{{i18n "admin.wizard.condition"}}</label>
|
||||
{{#if proSubscribed}}
|
||||
<div class="setting full field-mapper-setting pro">
|
||||
<div class="setting-label">
|
||||
<label>{{i18n "admin.wizard.condition"}}</label>
|
||||
<span class="pro-label">{{i18n "admin.wizard.pro.label"}}</span>
|
||||
</div>
|
||||
|
||||
<div class="setting-value">
|
||||
{{wizard-mapper
|
||||
inputs=step.condition
|
||||
options=stepConditionOptions}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-value">
|
||||
{{wizard-mapper
|
||||
inputs=step.condition
|
||||
options=stepConditionOptions}}
|
||||
<div class="setting full">
|
||||
<div class="setting-label"></div>
|
||||
<div class="setting-value force-final">
|
||||
<h4>{{i18n "admin.wizard.step.force_final.label"}}</h4>
|
||||
{{input type="checkbox" checked=step.force_final}}
|
||||
<span>{{i18n "admin.wizard.step.force_final.description"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting full">
|
||||
<div class="setting-label"></div>
|
||||
<div class="setting-value force-final">
|
||||
<h4>{{i18n "admin.wizard.step.force_final.label"}}</h4>
|
||||
{{input type="checkbox" checked=step.force_final}}
|
||||
<span>{{i18n "admin.wizard.step.force_final.description"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
|
@ -129,5 +132,6 @@
|
|||
currentFieldId=currentField.id
|
||||
fieldTypes=fieldTypes
|
||||
removeField="removeField"
|
||||
wizardFields=wizardFields}}
|
||||
wizardFields=wizardFields
|
||||
proSubscribed=proSubscribed}}
|
||||
{{/each}}
|
||||
|
|
|
@ -372,6 +372,22 @@
|
|||
.setting-gutter {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
&.pro {
|
||||
.setting-label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
label {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pro-label {
|
||||
color: $tertiary;
|
||||
font-size: .75em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.advanced-settings {
|
||||
|
|
|
@ -436,6 +436,7 @@ en:
|
|||
|
||||
pro:
|
||||
nav_label: PRO
|
||||
label: PRO
|
||||
title: Custom Wizard PRO
|
||||
authorize: Authorize
|
||||
authorized: Authorized
|
||||
|
|
|
@ -49,6 +49,7 @@ en:
|
|||
required: "%{property} is required"
|
||||
conflict: "Wizard with id '%{wizard_id}' already exists"
|
||||
after_time: "After time setting is invalid"
|
||||
pro: "%{property} is PRO only"
|
||||
|
||||
site_settings:
|
||||
custom_wizard_enabled: "Enable custom wizards."
|
||||
|
|
|
@ -10,7 +10,8 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
|||
),
|
||||
field_types: CustomWizard::Field.types,
|
||||
realtime_validations: CustomWizard::RealtimeValidation.types,
|
||||
custom_fields: custom_field_list
|
||||
custom_fields: custom_field_list,
|
||||
pro_subscribed: CustomWizard::Pro.subscribed?
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ class CustomWizard::Builder
|
|||
@template = CustomWizard::Template.create(wizard_id)
|
||||
return nil if @template.nil?
|
||||
@wizard = CustomWizard::Wizard.new(template.data, user)
|
||||
@pro = CustomWizard::Pro.new
|
||||
end
|
||||
|
||||
def self.sorted_handlers
|
||||
|
@ -222,6 +223,8 @@ class CustomWizard::Builder
|
|||
end
|
||||
|
||||
def check_condition(template)
|
||||
return false unless @pro.subscribed?
|
||||
|
||||
if template['condition'].present?
|
||||
result = CustomWizard::Mapper.new(
|
||||
inputs: template['condition'],
|
||||
|
|
|
@ -18,4 +18,8 @@ class CustomWizard::Pro
|
|||
def subscribed?
|
||||
@subscription.active?
|
||||
end
|
||||
|
||||
def self.subscribed?
|
||||
self.new.subscribed?
|
||||
end
|
||||
end
|
|
@ -6,6 +6,7 @@ class CustomWizard::TemplateValidator
|
|||
def initialize(data, opts = {})
|
||||
@data = data
|
||||
@opts = opts
|
||||
@pro = CustomWizard::Pro.new
|
||||
end
|
||||
|
||||
def perform
|
||||
|
@ -14,12 +15,15 @@ class CustomWizard::TemplateValidator
|
|||
check_id(data, :wizard)
|
||||
check_required(data, :wizard)
|
||||
validate_after_time
|
||||
validate_pro(data, :wizard)
|
||||
|
||||
data[:steps].each do |step|
|
||||
check_required(step, :step)
|
||||
validate_pro(step, :step)
|
||||
|
||||
if data[:fields].present?
|
||||
data[:fields].each do |field|
|
||||
validate_pro(field, :field)
|
||||
check_required(field, :field)
|
||||
end
|
||||
end
|
||||
|
@ -47,6 +51,13 @@ class CustomWizard::TemplateValidator
|
|||
}
|
||||
end
|
||||
|
||||
def self.pro
|
||||
{
|
||||
step: ['condition'],
|
||||
field: ['conition']
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_required(object, type)
|
||||
|
@ -57,6 +68,14 @@ class CustomWizard::TemplateValidator
|
|||
end
|
||||
end
|
||||
|
||||
def validate_pro(object, type)
|
||||
CustomWizard::TemplateValidator.required[type].each do |property|
|
||||
if object[property].present? && !@pro.subscribed?
|
||||
errors.add :base, I18n.t("wizard.validation.pro", property: property)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_id(object, type)
|
||||
if type === :wizard && @opts[:create] && CustomWizard::Template.exists?(object[:id])
|
||||
errors.add :base, I18n.t("wizard.validation.conflict", wizard_id: object[:id])
|
||||
|
|
Laden …
In neuem Issue referenzieren