@cybertale/form 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.editorconfig ADDED
@@ -0,0 +1,5 @@
1
+ [*.{js,jsx,ts,tsx,vue}]
2
+ indent_style = space
3
+ indent_size = 2
4
+ trim_trailing_whitespace = true
5
+ insert_final_newline = true
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # geocms-interface
2
+ # Description
3
+ ##### UI collections for inserting and editing devices along with administration management and creation of custom device forms/groups.
4
+ ## Compatible version
5
+ ```
6
+ node: v14.21
7
+ npm: 6.14
8
+ ```
9
+ ## Project setup
10
+ ```
11
+ npm install
12
+ ```
13
+ ### Import folder to Vue CLI!
14
+
15
+ ### Customize configuration (.env.development example)
16
+
17
+ ```
18
+ VUE_APP_BASE_URL=http://blog.test/api/
19
+ VUE_APP_URL=http://blog.test/
20
+ VUE_APP_CLIENT_ID=99062c75-d480-4659-82b7-7e0037d7fc52
21
+
22
+ PS:get VUE_APP_CLIENT_ID from oauth database, table oauth_clients.
23
+ Be sure that you choose the row with front_redirect to localhost:8080
24
+ ```
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@cybertale/form",
3
+ "version": "0.1.0",
4
+ "description": "ECS interface for Web Development, CyberTale edition.",
5
+ "author": "Joso Marich <jspmari@proton.me>",
6
+ "license": "GPL-3.0-only",
7
+ "keywords": [
8
+ "ecs",
9
+ "cyber",
10
+ "cybertale",
11
+ "web",
12
+ "form"
13
+ ],
14
+ "main": "src/index.ts",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/Joso997/cybertale-form.git"
18
+ },
19
+ "directories": {
20
+ "lib": "src"
21
+ },
22
+ "types": "src/index.ts",
23
+ "module": "src/index.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": "./src/index.ts",
27
+ "require": "./src/index.ts"
28
+ }
29
+ },
30
+ "dependencies": {
31
+ "@cybertale/interface": "^2.0.6",
32
+ "vue": "^3.0.0",
33
+ "vue-class-component": "^8.0.0-0"
34
+ },
35
+ "devDependencies": {
36
+ "@typescript-eslint/eslint-plugin": "^5.54.0",
37
+ "@typescript-eslint/parser": "^5.54.0",
38
+ "eslint": "^8.35.0",
39
+ "typescript": "^4.9.5"
40
+ },
41
+ "eslintConfig": {
42
+ "env": {
43
+ "node": true
44
+ },
45
+ "extends": [
46
+ "plugin:vue/vue3-essential",
47
+ "@vue/standard",
48
+ "@vue/typescript/recommended"
49
+ ],
50
+ "parserOptions": {
51
+ "ecmaVersion": 2020,
52
+ "sourceType": "module"
53
+ },
54
+ "rules": {
55
+ "@typescript-eslint/no-namespace": "off"
56
+ }
57
+ },
58
+ "browserslist": [
59
+ "> 1%",
60
+ "last 2 versions",
61
+ "not dead"
62
+ ]
63
+ }
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <div class="alert" :class="object?.Stats[statTypeEnum.Design].Data">
3
+ {{object.Stats[statTypeEnum.Label].Data}}
4
+ </div>
5
+ </template>
6
+
7
+ <script lang="ts">
8
+ import { Options, Vue } from 'vue-class-component'
9
+ import { ObjectTemplate, ObjectType, StatTypeEnum, ObjectTypeEnum, RegionType, RegionEnum } from '@cybertale/interface'
10
+ @Options({
11
+ props: {
12
+ object: ObjectTemplate
13
+ }
14
+ })
15
+ export default class AlertComponent extends Vue {
16
+ statTypeEnum = StatTypeEnum
17
+ objectTypeEnum = ObjectTypeEnum
18
+ objectType = ObjectType
19
+ regionType = RegionType
20
+ regionEnum = RegionEnum
21
+ object!: ObjectTemplate
22
+ }
23
+ </script>
24
+
25
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
26
+ <style scoped>
27
+
28
+ </style>
@@ -0,0 +1,76 @@
1
+ <template v-if="renderComponent">
2
+ <button data-bs-toggle="tooltip" data-bs-placement="top"
3
+ :data-bs-title="tooltipCase()"
4
+ :hidden="specialCase()"
5
+ :disabled="attributeCheck(statTypeEnum.Disabled)"
6
+ :class="getValue(statTypeEnum.Design)"
7
+ @click.prevent='regionType.RegionTypes[object.Region].ObjectTypes[object.ObjectEnum].ChooseSubType(object)'>
8
+ {{ getValue(statTypeEnum.Label) }}
9
+ </button>
10
+ <slot></slot>
11
+ </template>
12
+
13
+ <script lang="ts">
14
+ import { Options, Vue } from 'vue-class-component'
15
+ import { ObjectTemplate, ObjectType, StatTypeEnum, ObjectTypeEnum, RegionType, RegionEnum } from '@cybertale/interface'
16
+ @Options({
17
+ props: {
18
+ object: ObjectTemplate
19
+ }
20
+ })
21
+ export default class ButtonComponent extends Vue {
22
+ statTypeEnum = StatTypeEnum
23
+ objectTypeEnum = ObjectTypeEnum
24
+ objectType = ObjectType
25
+ regionType = RegionType
26
+ regionEnum = RegionEnum
27
+ object!: ObjectTemplate
28
+ renderComponent= false
29
+
30
+ getValue (statEnum: number) : string {
31
+ if (this.object) {
32
+ if (this.object.Stats[this.statTypeEnum.Option] && this.isJSON(this.object.Stats[statEnum].Data)) {
33
+ const data = JSON.parse(this.object.Stats[statEnum].Data)
34
+ return data[Number(this.object.Stats[this.statTypeEnum.Option].Data)]
35
+ } else {
36
+ return this.object.Stats[statEnum].Data
37
+ }
38
+ }
39
+ return ''
40
+ }
41
+
42
+ isJSON (str: string): boolean {
43
+ let temp = null
44
+ try {
45
+ temp = JSON.parse(str)
46
+ } catch (e) {
47
+ return false
48
+ }
49
+ return Array.isArray(temp)
50
+ }
51
+
52
+ tooltipCase () {
53
+ if (this.object) {
54
+ if (this.object.Stats[this.statTypeEnum.Tooltip]) {
55
+ return this.object.Stats[this.statTypeEnum.Tooltip].Data
56
+ }
57
+ }
58
+ }
59
+
60
+ specialCase () : boolean {
61
+ if (this.object.Stats[this.statTypeEnum.ElementType] === undefined) { return false }
62
+ return this.object.Stats[this.statTypeEnum.ElementType].Data === 'hidden'
63
+ }
64
+
65
+ attributeCheck (statType : number) : boolean | string {
66
+ if (this.object.Stats[statType] === undefined) { return false }
67
+ if (this.object.Stats[statType].Data === '') { return false }
68
+ return this.object.Stats[statType].Data
69
+ }
70
+ }
71
+ </script>
72
+
73
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
74
+ <style scoped>
75
+
76
+ </style>
@@ -0,0 +1,81 @@
1
+ <template>
2
+ <div :class="object?.Stats[statTypeEnum.Design].Data">
3
+ <input class="form-check-input mt-0" type="checkbox"
4
+ :checked="!!object?.Stats[statTypeEnum.Value].Data"
5
+ :id="object?.Stats[statTypeEnum.Tag].Data"
6
+ :required="attributeCheck(statTypeEnum.Required)"
7
+ :disabled="attributeCheck(statTypeEnum.Disabled)"
8
+ :class="validate()"
9
+ @input="regionType.RegionTypes[object?.Region].ObjectTypes[object?.ObjectEnum].ChooseSubType(object as ObjectTemplate, $event.target.checked)">
10
+ <label v-if="returnIfExists(statTypeEnum.Label) !== ''" class="form-check-label" for="flexCheckDefault">
11
+ {{ object.Stats[statTypeEnum.Label].Data }}
12
+ </label>
13
+ </div>
14
+ <div class="invalid-feedback">{{ returnIfExists(statTypeEnum.ErrorMessage) }}</div>
15
+ </template>
16
+
17
+ <script lang="ts">
18
+ import { Options, Vue } from 'vue-class-component'
19
+ import { ObjectTemplate, ObjectType, StatTypeEnum, ObjectTypeEnum, RegionType, RegionEnum } from '@cybertale/interface'
20
+ @Options({
21
+ computed: {
22
+ ObjectTemplate () {
23
+ return ObjectTemplate
24
+ }
25
+ },
26
+ props: {
27
+ object: ObjectTemplate
28
+ }
29
+ })
30
+ export default class CheckBoxComponent extends Vue {
31
+ statTypeEnum = StatTypeEnum
32
+ objectTypeEnum = ObjectTypeEnum
33
+ objectType = ObjectType
34
+ regionType = RegionType
35
+ regionEnum = RegionEnum
36
+ object!: ObjectTemplate
37
+
38
+ returnIfExists (tag: number): string {
39
+ if (this.object.Stats[tag]) {
40
+ return this.object.Stats[tag].Data
41
+ }
42
+ return ''
43
+ }
44
+
45
+ validate () : string {
46
+ if (this.object.Stats[this.statTypeEnum.IsValid] === undefined) { return '' }
47
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data === '') { return '' }
48
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data) { return 'is-valid' }
49
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data === null) { return '' }
50
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data !== '') { return 'is-invalid' }
51
+ return ''
52
+ }
53
+
54
+ specialCase () : boolean {
55
+ if (this.object.Stats[this.statTypeEnum.ElementType] === undefined) { return false }
56
+ return this.object.Stats[this.statTypeEnum.ElementType].Data === 'hidden'
57
+ }
58
+
59
+ attributeCheck (statType : number) : boolean | string {
60
+ if (this.object.Stats[statType] === undefined) { return false }
61
+ if (this.object.Stats[statType].Data === '') { return false }
62
+ return this.object.Stats[statType].Data
63
+ }
64
+
65
+ tooltipCase () : string | undefined {
66
+ if (this.object !== undefined) {
67
+ if (this.object.Stats[this.statTypeEnum.Tooltip] !== undefined) {
68
+ return this.object.Stats[this.statTypeEnum.Tooltip].Data
69
+ }
70
+ }
71
+ }
72
+ }
73
+ </script>
74
+
75
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
76
+ <style scoped>
77
+ .form-check-input:checked {
78
+ background-color: #606467;
79
+ border-color: #606467;
80
+ }
81
+ </style>
@@ -0,0 +1,109 @@
1
+ <template>
2
+ <input class="form-control" :list="object.Stats[statTypeEnum.BelongsTo].Data"
3
+ :class="returnIfExists(statTypeEnum.Design) + ' ' + validate()"
4
+ :required="attributeCheck(statTypeEnum.Required)"
5
+ :disabled="attributeCheck(statTypeEnum.Disabled)"
6
+ :type="returnIfExists(statTypeEnum.ElementType)"
7
+ :value="`${object?.Stats[statTypeEnum.Value].Data !== null?object.Stats[statTypeEnum.Value].Data.name === undefined?valueName:object.Stats[statTypeEnum.Value].Data.name:''}`"
8
+ :placeholder="returnIfExists(statTypeEnum.Placeholder)"
9
+ @input="inputEvent(object as ObjectTemplate, $event.target.value)">
10
+ <datalist :id="object.Stats[statTypeEnum.BelongsTo].Data" v-if="dspStyle">
11
+ <option v-for="(item, key, index) in JSON.parse(object.Stats[statTypeEnum.ItemList].Data)" :selected="check(item.name)" :key="`${ key }-${ index }`" :value="item.name">{{item.name}}</option>
12
+ </datalist>
13
+ <div class="invalid-feedback order-1">{{ returnIfExists(statTypeEnum.ErrorMessage) }}</div>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ import { Options, Vue } from 'vue-class-component'
18
+ import { ObjectTemplate, ObjectType, ObjectTypeEnum, RegionEnum, RegionType, StatTypeEnum } from '@cybertale/interface'
19
+
20
+ interface Option {
21
+ id: number;
22
+ name: string;
23
+ }
24
+
25
+ @Options({
26
+ computed: {
27
+ ObjectTemplate () {
28
+ return ObjectTemplate
29
+ }
30
+ },
31
+ props: {
32
+ object: ObjectTemplate
33
+ }
34
+ })
35
+ export default class DataListComponent extends Vue {
36
+ statTypeEnum = StatTypeEnum
37
+ objectTypeEnum = ObjectTypeEnum
38
+ objectType = ObjectType
39
+ regionType = RegionType
40
+ regionEnum = RegionEnum
41
+ object!: ObjectTemplate
42
+ dspStyle = false
43
+ options: Option[] = JSON.parse(this.object.Stats[this.statTypeEnum.ItemList].Data)
44
+
45
+ returnIfExists (tag: number): string {
46
+ if (this.object.Stats[tag]) {
47
+ return this.object.Stats[tag].Data
48
+ }
49
+ return ''
50
+ }
51
+
52
+ getValue (statEnum: number, indexStatTypeEnum = StatTypeEnum.Option) : string {
53
+ if (this.object.Stats[statEnum]) {
54
+ if (this.object.Stats[indexStatTypeEnum] && this.object.Stats[statEnum] && this.isJSON(this.object.Stats[statEnum].Data)) {
55
+ const data = JSON.parse(this.object.Stats[statEnum].Data)
56
+ return data[Number(this.object.Stats[indexStatTypeEnum].Data)]
57
+ } else {
58
+ return this.object.Stats[statEnum].Data
59
+ }
60
+ }
61
+ return ''
62
+ }
63
+
64
+ isJSON (str: string): boolean {
65
+ let temp = null
66
+ try {
67
+ temp = JSON.parse(str)
68
+ } catch (e) {
69
+ return false
70
+ }
71
+ return Array.isArray(temp)
72
+ }
73
+
74
+ get valueName (): string {
75
+ const temp = this.options.find((option: any) => option.id === this.getValue(StatTypeEnum.Value, StatTypeEnum.ValueIndices))
76
+ if (!temp) { return this.getValue(StatTypeEnum.Value, StatTypeEnum.ValueIndices) }
77
+ return temp?.name
78
+ }
79
+
80
+ attributeCheck (statType : number) : boolean | string {
81
+ if (this.object.Stats[statType] === undefined) { return false }
82
+ if (this.object.Stats[statType].Data === '') { return false }
83
+ return this.object.Stats[statType].Data
84
+ }
85
+
86
+ validate () : string {
87
+ if (this.object.Stats[this.statTypeEnum.IsValid] === undefined) { return '' }
88
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data === '') { return '' }
89
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data) { return 'is-valid' }
90
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data === null) { return '' }
91
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data !== '') { return 'is-invalid' }
92
+ return ''
93
+ }
94
+
95
+ inputEvent (object: ObjectTemplate, value: string) : void {
96
+ this.dspStyle = value.length >= 3
97
+ this.regionType.RegionTypes[object.Region].ObjectTypes[object.ObjectEnum].ChooseSubType(object, value)
98
+ }
99
+
100
+ check (id : string) : boolean {
101
+ if (this.object.Stats[this.statTypeEnum.Value] === undefined || id === undefined) { return false }
102
+ return this.object.Stats[this.statTypeEnum.Value].Data === id.toString()
103
+ }
104
+ }
105
+ </script>
106
+
107
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
108
+ <style scoped>
109
+ </style>
@@ -0,0 +1,110 @@
1
+ <template>
2
+ <input class="form-control"
3
+ :id="object?.Stats[statTypeEnum.Tag].Data"
4
+ :required="attributeCheck(statTypeEnum.Required)"
5
+ :disabled="attributeCheck(statTypeEnum.Disabled)"
6
+ :autocomplete="returnIfExists(statTypeEnum.AutoComplete)"
7
+ :class="object?.Stats[statTypeEnum.Design].Data+' '+validate()"
8
+ :type="getValue(statTypeEnum.ElementType)"
9
+ :value="labelToValue()"
10
+ :placeholder="returnIfExists(statTypeEnum.Placeholder)"
11
+ @input="regionType.RegionTypes[object?.Region].ObjectTypes[object?.ObjectEnum].ChooseSubType(object as ObjectTemplate, $event.target.value)">
12
+ <div class="invalid-feedback">{{ returnIfExists(statTypeEnum.ErrorMessage) }}</div>
13
+ </template>
14
+
15
+ <script lang="ts">
16
+ import { Options, Vue } from 'vue-class-component'
17
+ import { ObjectTemplate, ObjectType, ObjectTypeEnum, RegionEnum, RegionType, StatTypeEnum } from '@cybertale/interface'
18
+
19
+ @Options({
20
+ computed: {
21
+ ObjectTemplate () {
22
+ return ObjectTemplate
23
+ }
24
+ },
25
+ props: {
26
+ object: ObjectTemplate
27
+ }
28
+ })
29
+ export default class FieldComponent extends Vue {
30
+ statTypeEnum = StatTypeEnum
31
+ objectTypeEnum = ObjectTypeEnum
32
+ objectType = ObjectType
33
+ regionType = RegionType
34
+ regionEnum = RegionEnum
35
+ object!: ObjectTemplate
36
+
37
+ labelToValue (): string {
38
+ if (this.returnIfExists(this.statTypeEnum.Tag).includes('label') && this.attributeCheck(this.statTypeEnum.Disabled)) {
39
+ return this.returnIfExists(this.statTypeEnum.Label)
40
+ }
41
+ return this.getValue(StatTypeEnum.Value, StatTypeEnum.ValueIndices)
42
+ }
43
+
44
+ getValue (statEnum: number, indexStatTypeEnum = StatTypeEnum.Option) : string {
45
+ if (this.object.Stats[statEnum]) {
46
+ if (this.object.Stats[indexStatTypeEnum] && this.object.Stats[statEnum] && this.isJSON(this.object.Stats[statEnum].Data)) {
47
+ const data = JSON.parse(this.object.Stats[statEnum].Data)
48
+ return data[Number(this.object.Stats[indexStatTypeEnum].Data)]
49
+ } else {
50
+ return this.object.Stats[statEnum].Data
51
+ }
52
+ }
53
+ return ''
54
+ }
55
+
56
+ isJSON (str: string): boolean {
57
+ let temp = null
58
+ try {
59
+ temp = JSON.parse(str)
60
+ } catch (e) {
61
+ return false
62
+ }
63
+ return Array.isArray(temp)
64
+ }
65
+
66
+ returnIfExists (tag: number): string {
67
+ if (this.object.Stats[tag]) {
68
+ return this.object.Stats[tag].Data
69
+ }
70
+ return ''
71
+ }
72
+
73
+ validate () : string {
74
+ if (this.object.Stats[this.statTypeEnum.IsValid] === undefined) { return '' }
75
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data === '') { return '' }
76
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data) { return 'is-valid' }
77
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data === null) { return '' }
78
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data !== '') { return 'is-invalid' }
79
+ return ''
80
+ }
81
+
82
+ attributeCheck (statType : number) : boolean | string {
83
+ if (this.object.Stats[statType] === undefined) { return false }
84
+ if (this.object.Stats[statType].Data === '') { return false }
85
+ return this.object.Stats[statType].Data
86
+ }
87
+
88
+ tooltipCase () : string | undefined {
89
+ if (this.object !== undefined) {
90
+ if (this.object.Stats[this.statTypeEnum.Tooltip] !== undefined) {
91
+ return this.object.Stats[this.statTypeEnum.Tooltip].Data
92
+ }
93
+ }
94
+ }
95
+ }
96
+ </script>
97
+
98
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
99
+ <style scoped>
100
+ .form-check .form-check-input{
101
+ float: none;
102
+ }
103
+ .form-check-input{
104
+ margin-right: 1%;
105
+ }
106
+ .form-check-input:checked {
107
+ background-color: #606467;
108
+ border-color: #606467;
109
+ }
110
+ </style>
@@ -0,0 +1,75 @@
1
+ <template>
2
+ <label :title="tooltipCase()" :class="object.Stats[statTypeEnum.Design].Data" :hidden="specialCase()">{{object.Stats[statTypeEnum.Label].Data }}</label>
3
+ </template>
4
+
5
+ <script lang="ts">
6
+ import { Options, Vue } from 'vue-class-component'
7
+ import { ObjectTemplate, ObjectType, StatTypeEnum, ObjectTypeEnum, RegionType, RegionEnum } from '@cybertale/interface'
8
+ @Options({
9
+ props: {
10
+ object: ObjectTemplate
11
+ }
12
+ })
13
+ export default class LabelComponent extends Vue {
14
+ statTypeEnum = StatTypeEnum
15
+ objectTypeEnum = ObjectTypeEnum
16
+ objectType = ObjectType
17
+ regionType = RegionType
18
+ regionEnum = RegionEnum
19
+ object!: ObjectTemplate
20
+
21
+ validate () : string {
22
+ if (this.object.Stats[this.statTypeEnum.IsValid] === undefined) { return '' }
23
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data === '') { return '' }
24
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data) { return 'is-valid' }
25
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data === null) { return '' }
26
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data !== '') { return 'is-invalid' }
27
+ return ''
28
+ }
29
+
30
+ getValue (statEnum: number) : string {
31
+ if (this.object.Stats[statEnum]) {
32
+ if (this.object.Stats[this.statTypeEnum.Option] && this.object.Stats[statEnum] && this.isJSON(this.object.Stats[statEnum].Data)) {
33
+ const data = JSON.parse(this.object.Stats[statEnum].Data)
34
+ return data[Number(this.object.Stats[this.statTypeEnum.Option].Data)]
35
+ } else {
36
+ return this.object.Stats[statEnum].Data
37
+ }
38
+ }
39
+ return ''
40
+ }
41
+
42
+ specialCase () : boolean {
43
+ return this.getValue(this.statTypeEnum.ElementType) === 'hidden'
44
+ }
45
+
46
+ isJSON (str: string): boolean {
47
+ let temp = null
48
+ try {
49
+ temp = JSON.parse(str)
50
+ } catch (e) {
51
+ return false
52
+ }
53
+ return Array.isArray(temp)
54
+ }
55
+
56
+ attributeCheck (statType : number) : boolean | string {
57
+ if (this.object.Stats[statType] === undefined) { return false }
58
+ if (this.object.Stats[statType].Data === '') { return false }
59
+ return this.object.Stats[statType].Data
60
+ }
61
+
62
+ tooltipCase () : string | undefined {
63
+ if (this.object !== undefined) {
64
+ if (this.object.Stats[this.statTypeEnum.Tooltip] !== undefined) {
65
+ return this.object.Stats[this.statTypeEnum.Tooltip].Data
66
+ }
67
+ }
68
+ }
69
+ }
70
+ </script>
71
+
72
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
73
+ <style scoped>
74
+
75
+ </style>
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <div :class="object?.Stats[statTypeEnum.Design].Data">
3
+ <div v-if="returnIfExists(statTypeEnum.ItemList) && !returnIfExists(statTypeEnum.Name)">
4
+ <div v-for="(item, key, index) in JSON.parse(object.Stats[statTypeEnum.ItemList].Data)" :key="`${ key }-${ index }`">
5
+ <input class="form-check-input mt-0"
6
+ :name="object.Stats[statTypeEnum.Tag].Data"
7
+ :value="item.id" type="radio"
8
+ :checked="object.Stats[statTypeEnum.Value].Data===item.id"
9
+ @input="regionType.RegionTypes[object.Region].ObjectTypes[object.ObjectEnum].ChooseSubType(object as ObjectTemplate, $event.target.value)">
10
+ <label class="form-check-label" for="flexCheckDefault">
11
+ {{ item.name }}
12
+ </label>
13
+ </div>
14
+ </div>
15
+ <div v-else>
16
+ <input class="form-check-input"
17
+ :name="object.Stats[statTypeEnum.Name].Data"
18
+ :value="object.Stats[statTypeEnum.ItemList].Data"
19
+ type="radio"
20
+ :checked="object.Stats[statTypeEnum.ItemList].Data===object.Stats[statTypeEnum.Value].Data"
21
+ @input="regionType.RegionTypes[object.Region].ObjectTypes[object.ObjectEnum].ChooseSubType(object as ObjectTemplate, $event.target.value)">
22
+ </div>
23
+ </div>
24
+ </template>
25
+
26
+ <script lang="ts">
27
+ import { Options, Vue } from 'vue-class-component'
28
+ import { ObjectTemplate, ObjectType, StatTypeEnum, ObjectTypeEnum, RegionType, RegionEnum } from '@cybertale/interface'
29
+ @Options({
30
+ computed: {
31
+ ObjectTemplate () {
32
+ return ObjectTemplate
33
+ }
34
+ },
35
+ props: {
36
+ object: ObjectTemplate
37
+ }
38
+ })
39
+ export default class RadioComponent extends Vue {
40
+ statTypeEnum = StatTypeEnum
41
+ objectTypeEnum = ObjectTypeEnum
42
+ objectType = ObjectType
43
+ regionType = RegionType
44
+ regionEnum = RegionEnum
45
+ object!: ObjectTemplate
46
+
47
+ returnIfExists (tag: number): string {
48
+ if (this.object.Stats[tag]) {
49
+ return this.object.Stats[tag].Data
50
+ }
51
+ return ''
52
+ }
53
+ }
54
+ </script>
55
+
56
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
57
+ <style scoped>
58
+ .form-check .form-check-input{
59
+ float: none;
60
+ }
61
+ .form-check-input{
62
+ margin-right: 1%;
63
+ }
64
+ .form-check-input:checked {
65
+ background-color: #606467;
66
+ border-color: #606467;
67
+ }
68
+ </style>
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <select class="form-select" aria-label="Default select example"
3
+ :class="validate()"
4
+ :required="attributeCheck(statTypeEnum.Required)"
5
+ :disabled="attributeCheck(statTypeEnum.Disabled)"
6
+ :autocomplete="returnIfExists(statTypeEnum.AutoComplete)"
7
+ @input="regionType.RegionTypes[object.Region].ObjectTypes[object.ObjectEnum].ChooseSubType(object as ObjectTemplate, $event.target.value)">
8
+ <option value="" :selected="object.Stats[statTypeEnum.Value] === undefined" hidden>Select a type.</option>
9
+ <option v-for="(item, key, index) in JSON.parse(object.Stats[statTypeEnum.ItemList].Data)" :selected="check(item.id)" :key="`${ key }-${ index }`" :value="item.id">{{item.name}}</option>
10
+ </select>
11
+ <div class="invalid-feedback order-1">{{ returnIfExists(statTypeEnum.ErrorMessage) }}</div>
12
+ </template>
13
+
14
+ <script lang="ts">
15
+ import { Options, Vue } from 'vue-class-component'
16
+ import { ObjectTemplate, ObjectType, StatTypeEnum, ObjectTypeEnum, RegionType, RegionEnum } from '@cybertale/interface'
17
+ @Options({
18
+ computed: {
19
+ ObjectTemplate() {
20
+ return ObjectTemplate
21
+ }
22
+ },
23
+ props: {
24
+ object: ObjectTemplate
25
+ }
26
+ })
27
+ export default class SelectListComponent extends Vue {
28
+ statTypeEnum = StatTypeEnum
29
+ objectTypeEnum = ObjectTypeEnum
30
+ objectType = ObjectType
31
+ regionType = RegionType
32
+ regionEnum = RegionEnum
33
+ object!: ObjectTemplate
34
+ renderComponent= true
35
+
36
+ validate () : string {
37
+ if (this.object.Stats[this.statTypeEnum.IsValid] === undefined) { return '' }
38
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data === '') { return '' }
39
+ if (this.object.Stats[this.statTypeEnum.IsValid].Data) { return 'is-valid' }
40
+ console.log(this.object.Stats[this.statTypeEnum.IsValid].Data)
41
+ console.log(this.object.Stats)
42
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data === null) { return '' }
43
+ if (this.object.Stats[this.statTypeEnum.ErrorMessage].Data !== '') { return 'is-invalid' }
44
+ return ''
45
+ }
46
+
47
+ returnIfExists (tag: number): string {
48
+ if (this.object.Stats[tag]) {
49
+ return this.object.Stats[tag].Data
50
+ }
51
+ return ''
52
+ }
53
+
54
+ attributeCheck (statType : number) : boolean | string {
55
+ if (this.object.Stats[statType] === undefined) { return false }
56
+ if (this.object.Stats[statType].Data === '') { return false }
57
+ return this.object.Stats[statType].Data
58
+ }
59
+
60
+ check (id : string) {
61
+ if (this.object.Stats[this.statTypeEnum.Value] === undefined || id === undefined) { return false }
62
+ return this.object.Stats[this.statTypeEnum.Value].Data === id.toString()
63
+ }
64
+
65
+ specialCase () {
66
+ if (this.object !== undefined) {
67
+ if (this.object.Stats[this.statTypeEnum.Tooltip] !== undefined) {
68
+ return this.object.Stats[this.statTypeEnum.Tooltip].Data
69
+ }
70
+ }
71
+ }
72
+ }
73
+ </script>
74
+
75
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
76
+ <style scoped>
77
+ </style>
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <div class="mb-3">
3
+ <div class="p-3">
4
+ <label :title="`${object.Stats[statTypeEnum.Tooltip].Data}`" class="form-label h3">{{object.Stats[statTypeEnum.Label].Data }}</label>
5
+ <textarea class="form-control" v-model="object.Stats[statTypeEnum.Value].Data" rows="9" placeholder="edit me"></textarea>
6
+ </div>
7
+ <div class="border mb-3">
8
+ <h3 class="text-start p-3">Prikaz</h3>
9
+ <div v-html="object.Stats[statTypeEnum.Value].Data"></div>
10
+ </div>
11
+ </div>
12
+ </template>
13
+
14
+ <script lang="ts">
15
+ import { Options, Vue } from 'vue-class-component'
16
+ import { ObjectTemplate, ObjectType, StatTypeEnum, ObjectTypeEnum } from '@cybertale/interface'
17
+ @Options({
18
+ props: {
19
+ object: ObjectTemplate
20
+ }
21
+ })
22
+ export default class InputComponent extends Vue {
23
+ statTypeEnum = StatTypeEnum
24
+ objectTypeEnum = ObjectTypeEnum
25
+ objectType = ObjectType
26
+ object!: ObjectTemplate
27
+ }
28
+ </script>
29
+
30
+ <!-- Add "scoped" attribute to limit CSS to this component only -->
31
+ <style scoped>
32
+
33
+ </style>
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ import AlertComponent from './formComponents/AlertComponent.vue'
2
+ import ButtonComponent from '@/formComponents/ButtonComponent.vue'
3
+ import CheckBoxComponent from '@/formComponents/CheckBoxComponent.vue'
4
+ import DataListComponent from '@/formComponents/DataListComponent.vue'
5
+ import FieldComponent from '@/formComponents/FieldComponent.vue'
6
+ import LabelComponent from '@/formComponents/LabelComponent.vue'
7
+ import RadioComponent from '@/formComponents/RadioComponent.vue'
8
+ import SelectListComponent from '@/formComponents/SelectListComponent.vue'
9
+
10
+ export { AlertComponent, ButtonComponent, CheckBoxComponent, DataListComponent, FieldComponent, LabelComponent, RadioComponent, SelectListComponent }
package/tsconfig.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "strict": true,
6
+ "jsx": "preserve",
7
+ "importHelpers": true,
8
+ "moduleResolution": "node",
9
+ "experimentalDecorators": true,
10
+ "skipLibCheck": true,
11
+ "esModuleInterop": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "sourceMap": true,
14
+ "baseUrl": ".",
15
+ "types": [
16
+ "webpack-env"
17
+ ],
18
+ "paths": {
19
+ "@/*": [
20
+ "src/*"
21
+ ]
22
+ },
23
+ "lib": [
24
+ "esnext",
25
+ "dom",
26
+ "dom.iterable",
27
+ "scripthost"
28
+ ]
29
+ },
30
+ "include": [
31
+ "src/**/*.ts",
32
+ "src/**/*.tsx",
33
+ "src/**/*.vue",
34
+ "tests/**/*.ts",
35
+ "tests/**/*.tsx",
36
+ "src/**/*",
37
+ "typings/**/*"
38
+ ],
39
+ "exclude": [
40
+ "node_modules"
41
+ ]
42
+ }