Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
some changes
Dieser Commit ist enthalten in:
Ursprung
3cc45fa714
Commit
5d749fe426
11 geänderte Dateien mit 69 neuen und 2 gelöschten Zeilen
|
@ -0,0 +1,5 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
Component.extend({
|
||||||
|
|
||||||
|
});
|
|
@ -4,6 +4,7 @@ import { computed } from "@ember/object";
|
||||||
import { selectKitContent } from '../lib/wizard';
|
import { selectKitContent } from '../lib/wizard';
|
||||||
import UndoChanges from '../mixins/undo-changes';
|
import UndoChanges from '../mixins/undo-changes';
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import wizardSchema from '../lib/wizard-schema';
|
||||||
|
|
||||||
export default Component.extend(UndoChanges, {
|
export default Component.extend(UndoChanges, {
|
||||||
componentType: 'field',
|
componentType: 'field',
|
||||||
|
@ -26,6 +27,18 @@ export default Component.extend(UndoChanges, {
|
||||||
showAdvanced: alias('field.type'),
|
showAdvanced: alias('field.type'),
|
||||||
messageUrl: 'https://thepavilion.io/t/2809',
|
messageUrl: 'https://thepavilion.io/t/2809',
|
||||||
|
|
||||||
|
@discourseComputed('field.type')
|
||||||
|
validations(type) {
|
||||||
|
const applicableToField = [];
|
||||||
|
for(let validation in wizardSchema.field.validations) {
|
||||||
|
if (wizardSchema.field.validations[validation].includes(type)) {
|
||||||
|
applicableToField.push(validation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return applicableToField;
|
||||||
|
},
|
||||||
|
|
||||||
@discourseComputed('field.type')
|
@discourseComputed('field.type')
|
||||||
isDateTime(type) {
|
isDateTime(type) {
|
||||||
return ['date_time', 'date', 'time'].indexOf(type) > -1;
|
return ['date_time', 'date', 'time'].indexOf(type) > -1;
|
||||||
|
|
|
@ -244,6 +244,10 @@ export function buildFieldTypes(types) {
|
||||||
wizardSchema.field.types = types;
|
wizardSchema.field.types = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildFieldValidations(validations) {
|
||||||
|
wizardSchema.field.validations = validations;
|
||||||
|
}
|
||||||
|
|
||||||
if (Discourse.SiteSettings.wizard_apis_enabled) {
|
if (Discourse.SiteSettings.wizard_apis_enabled) {
|
||||||
wizardSchema.action.types.send_to_api = {
|
wizardSchema.action.types.send_to_api = {
|
||||||
api: null,
|
api: null,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import { buildFieldTypes } from '../lib/wizard-schema';
|
import { buildFieldTypes, buildFieldValidations } from '../lib/wizard-schema';
|
||||||
import EmberObject, { set } from "@ember/object";
|
import EmberObject, { set } from "@ember/object";
|
||||||
import { A } from "@ember/array";
|
import { A } from "@ember/array";
|
||||||
import { all } from "rsvp";
|
import { all } from "rsvp";
|
||||||
|
@ -12,6 +12,7 @@ export default DiscourseRoute.extend({
|
||||||
|
|
||||||
afterModel(model) {
|
afterModel(model) {
|
||||||
buildFieldTypes(model.field_types);
|
buildFieldTypes(model.field_types);
|
||||||
|
buildFieldValidations(model.realtime_validations);
|
||||||
|
|
||||||
return all([
|
return all([
|
||||||
this._getThemes(model),
|
this._getThemes(model),
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<div>
|
||||||
|
<label>{{i18n 'admin.wizard.field.validations.header'}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{#each validations as |validation|}}
|
||||||
|
<span class="setting-title">
|
||||||
|
{{i18n (concat 'admin.wizard.field.validations.' validation)}} {{input type="checkbox" }}
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
{{input type="radio"}} :before
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{input type="radio"}} :after
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
|
@ -221,4 +221,8 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if validations}}
|
||||||
|
{{realtime-validation-settings field=field validations=validations}}
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
13
assets/javascripts/wizard/components/alpha-validator.js.es6
Normale Datei
13
assets/javascripts/wizard/components/alpha-validator.js.es6
Normale Datei
|
@ -0,0 +1,13 @@
|
||||||
|
import WizardFieldValidator from "../../wizard/components/validator";
|
||||||
|
|
||||||
|
export default WizardFieldValidator.extend({
|
||||||
|
validMessageKey: 'hello',
|
||||||
|
invalidMessageKey: 'world',
|
||||||
|
validate() {
|
||||||
|
if(this.field.value) {
|
||||||
|
this.field.value.length > 0 ? this.set('isValid', true) : this.set('isValid', false);
|
||||||
|
} else {
|
||||||
|
this.set('isValid', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -176,6 +176,9 @@ en:
|
||||||
date_time_format:
|
date_time_format:
|
||||||
label: "Format"
|
label: "Format"
|
||||||
instructions: "<a href='https://momentjs.com/docs/#/displaying/format/' target='_blank'>Moment.js format</a>"
|
instructions: "<a href='https://momentjs.com/docs/#/displaying/format/' target='_blank'>Moment.js format</a>"
|
||||||
|
validations:
|
||||||
|
header: "Realtime Validation Settings"
|
||||||
|
suggested_topics: "Suggested Topics"
|
||||||
|
|
||||||
type:
|
type:
|
||||||
text: "Text"
|
text: "Text"
|
||||||
|
|
|
@ -8,6 +8,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
||||||
each_serializer: CustomWizard::BasicWizardSerializer
|
each_serializer: CustomWizard::BasicWizardSerializer
|
||||||
),
|
),
|
||||||
field_types: CustomWizard::Field.types,
|
field_types: CustomWizard::Field.types,
|
||||||
|
realtime_validations: CustomWizard::RealtimeValidation.types,
|
||||||
custom_fields: custom_field_list
|
custom_fields: custom_field_list
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
7
lib/custom_wizard/realtime_validation.rb
Normale Datei
7
lib/custom_wizard/realtime_validation.rb
Normale Datei
|
@ -0,0 +1,7 @@
|
||||||
|
class CustomWizard::RealtimeValidation
|
||||||
|
cattr_accessor :types
|
||||||
|
@@types ||= {
|
||||||
|
suggested_topics: [:text]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
|
@ -58,6 +58,7 @@ after_initialize do
|
||||||
../lib/custom_wizard/cache.rb
|
../lib/custom_wizard/cache.rb
|
||||||
../lib/custom_wizard/custom_field.rb
|
../lib/custom_wizard/custom_field.rb
|
||||||
../lib/custom_wizard/field.rb
|
../lib/custom_wizard/field.rb
|
||||||
|
../lib/custom_wizard/realtime_validation.rb
|
||||||
../lib/custom_wizard/mapper.rb
|
../lib/custom_wizard/mapper.rb
|
||||||
../lib/custom_wizard/log.rb
|
../lib/custom_wizard/log.rb
|
||||||
../lib/custom_wizard/step_updater.rb
|
../lib/custom_wizard/step_updater.rb
|
||||||
|
|
Laden …
In neuem Issue referenzieren