-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add test for autonomic forms, Hot fix for dispatching events to…
… parent form from autonomic form.
- Loading branch information
Showing
9 changed files
with
156 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,28 @@ | ||
<template> | ||
<div class="container-examples"> | ||
<div :key = "values">Values: {{values}}</div> | ||
|
||
<div :key = "changes">Changes: {{changes}}</div> | ||
<div :key = "pureValue">Pure values: {{pureValue}}</div> | ||
<div :key = "pureAvailabilities">Pure av: {{pureAvailabilities}}</div> | ||
<script setup lang="ts"> | ||
<input-field name = "birthday" type = "date" label = "Placeholder" /> | ||
import {useFormValues, Form, FormField} from "../../../src/index"; | ||
import ParentForm from "./parent-form.vue"; | ||
<input-field name = "birthday" type = "date" label = "Other mask" mask = "MM/DD/YYYY" :handlers = "[testFrom, testTo]"/> | ||
const form = new Form({ | ||
name: "grand" | ||
}) | ||
const values = useFormValues(form); | ||
// @ts-ignore | ||
window.theForm = form; | ||
</script> | ||
|
||
<template> | ||
<div class="container"> | ||
<form-field name="username" label="username"/> | ||
{{ values }} | ||
<parent-form/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang='ts'> | ||
import Form from "../../../src/classes/Form"; | ||
import {ref} from "vue"; | ||
import copyObject from "./../../../src/utils/copy-object"; | ||
import {InputField} from "../../../src/index"; | ||
import DateController from "../../../src/controllers/date-controller"; | ||
// @ts-ignore | ||
const form = window.form = new Form({ | ||
name: "main", | ||
parent:false | ||
}); | ||
const show = ref(false); | ||
setInterval(() => { | ||
if (!form) return; | ||
values.value = copyObject(form?.values); | ||
changes.value = copyObject(form.changes); | ||
pureValue.value = copyObject(form.TEST_PURE_VALUE); | ||
pureAvailabilities.value = copyObject(form.TEST_PURE_AVAILABILITIES) | ||
}, 50); | ||
const values = ref(0); | ||
const changes = ref({}); | ||
const pureValue= ref({}); | ||
const pureAvailabilities = ref({}) | ||
const name = ref('username'); | ||
function change() { | ||
name.value = name.value === 'username' ? 'age' : 'username'; | ||
<style scoped> | ||
.container { | ||
padding: 20px; | ||
border: 2px solid black; | ||
} | ||
function clean() { | ||
form.cleanValues(); | ||
} | ||
function testFrom(date: unknown) { | ||
if (typeof date !== 'string') return null; | ||
return new Date(date) | ||
} | ||
function testTo(str?: string) { | ||
if (typeof str !== 'string') return null; | ||
const p = DateController.ConvertToDate(str, "MM/DD/YYYY"); | ||
if (!p) return null; | ||
return DateController.GetPrettyDate(p, 'YYYY-MM-DD') | ||
} | ||
</script> | ||
|
||
<style> | ||
</style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup lang="ts"> | ||
import {useFormValues, Form, FormField} from "../../../src/index"; | ||
const form = new Form({ | ||
name: "child" | ||
}) | ||
const values = useFormValues(form); | ||
</script> | ||
|
||
<template> | ||
<div class="container"> | ||
<form-field name="username" label="username"/> | ||
{{ values }} | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.container { | ||
padding: 20px; | ||
border: 2px solid black; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script setup lang="ts"> | ||
import {useFormValues, Form, FormField} from "../../../src/index"; | ||
import ChildForm from "./child-form.vue"; | ||
const form = new Form({ | ||
name: "parent" | ||
}) | ||
const values = useFormValues(form); | ||
</script> | ||
|
||
<template> | ||
|
||
<div class="container"> | ||
<form-field name="username" label="username"/> | ||
{{ values }} | ||
|
||
<child-form/> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.container { | ||
padding: 20px; | ||
border: 2px solid black; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters