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

frontend validator apis

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-01-26 13:35:10 +05:30
Ursprung 505043922e
Commit 3cc45fa714
5 geänderte Dateien mit 50 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,9 @@
import Component from "@ember/component";
import { observes } from "discourse-common/utils/decorators";
export default Component.extend({
actions:{
perform() {
this.toggleProperty('performValidation');
}
}
});

Datei anzeigen

@ -0,0 +1,16 @@
import Component from "@ember/component";
import { not } from "@ember/object/computed";
import { observes } from "discourse-common/utils/decorators";
export default Component.extend({
classNameBindings: ['isValid', 'isInvalid'],
validMessageKey: null,
invalidMessageKey: null,
isValid: null,
isInvalid: not('isValid'),
layoutName: 'components/validator', // useful for sharing the template with extending components
@observes('perform')
performValidation() {
this.validate();
},
});

Datei anzeigen

@ -0,0 +1,13 @@
{{#if field.validations}}
{{#each field.validations.top as |validation|}}
{{validation.component field=field perform=perform}}
{{/each}}
{{yield (hash perform=(action 'perform')) }}
{{#each field.validations.bottom as |validation|}}
{{validation.component field=field perform=perform}}
{{/each}}
{{else}}
{{yield}}
{{/if}}

Datei anzeigen

@ -0,0 +1,5 @@
{{#if isValid}}
{{i18n validMessageKey}}
{{else}}
{{i18n invalidMessageKey}}
{{/if}}

Datei anzeigen

@ -10,11 +10,13 @@
<div class='field-description'>{{cookedDescription}}</div> <div class='field-description'>{{cookedDescription}}</div>
{{/if}} {{/if}}
{{#field-validators field=field as |validators|}}
{{#if inputComponentName}} {{#if inputComponentName}}
<div class='input-area'> <div class='input-area'>
{{component inputComponentName field=field step=step fieldClass=fieldClass wizard=wizard}} {{component inputComponentName field=field step=step fieldClass=fieldClass wizard=wizard focusOut=validators.perform}}
</div> </div>
{{/if}} {{/if}}
{{/field-validators}}
{{#if field.char_counter}} {{#if field.char_counter}}
{{#if textType}} {{#if textType}}