fix(core): update
This commit is contained in:
@ -18,7 +18,12 @@ declare global {
|
||||
@customElement('dees-form')
|
||||
export class DeesForm extends DeesElement {
|
||||
public static demo = () => html`
|
||||
<dees-form style="display: block; margin:auto; max-width: 500px; padding: 20px">
|
||||
<dees-form style="display: block; margin:auto; max-width: 500px; padding: 20px" @formData=${async (eventArg) => {
|
||||
const form: DeesForm = eventArg.currentTarget;
|
||||
form.setStatus('freeze', 'authenticating...');
|
||||
await domtools.plugins.smartdelay.delayFor(1000);
|
||||
form.setStatus('success', 'authenticated!');
|
||||
}}>
|
||||
<dees-input-text .required="${true}" key="hello1" label="a text"></dees-input-text>
|
||||
<dees-input-text .required="${true}" key="hello2" label="also a text"></dees-input-text>
|
||||
<dees-input-checkbox .required="${true}" key="hello3" label="another text"></dees-input-checkbox>
|
||||
@ -65,8 +70,7 @@ export class DeesForm extends DeesElement {
|
||||
return formChildren;
|
||||
}
|
||||
|
||||
public async checkRequiredStatus() {
|
||||
console.log('checking the required status.')
|
||||
public getSubmitButton() {
|
||||
const children: Array<DeesElement> = this.children as any;
|
||||
let submitButton: DeesFormSubmit;
|
||||
for (const childArg of children) {
|
||||
@ -74,6 +78,12 @@ export class DeesForm extends DeesElement {
|
||||
submitButton = childArg;
|
||||
}
|
||||
}
|
||||
return submitButton;
|
||||
}
|
||||
|
||||
public async checkRequiredStatus() {
|
||||
console.log('checking the required status.')
|
||||
|
||||
|
||||
let requiredOK = true;
|
||||
for (const childArg of this.getFormChildren()) {
|
||||
@ -81,8 +91,7 @@ export class DeesForm extends DeesElement {
|
||||
requiredOK = false;
|
||||
}
|
||||
}
|
||||
submitButton.disabled = !requiredOK;
|
||||
console.log(submitButton);
|
||||
this.getSubmitButton().disabled = !requiredOK;
|
||||
}
|
||||
|
||||
public async gatherData() {
|
||||
@ -106,4 +115,21 @@ export class DeesForm extends DeesElement {
|
||||
console.log('dispatched data:')
|
||||
console.log(valueObject);
|
||||
}
|
||||
}
|
||||
|
||||
public setStatus (visualStateArg: 'normal' | 'freeze' | 'error' | 'success', textStateArg: string) {
|
||||
const inputChildren = this.getFormChildren();
|
||||
const submitButton = this.getSubmitButton();
|
||||
|
||||
switch(visualStateArg) {
|
||||
case 'freeze':
|
||||
submitButton.disabled = true;
|
||||
for (const inputChild of inputChildren) {
|
||||
inputChild.disabled = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
submitButton.text = textStateArg;
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user