@cybertale/form 0.1.2 → 0.1.4
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/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<input class="form-control" :list="object.Stats[statTypeEnum.BelongsTo].Data"
|
|
3
3
|
:class="returnIfExists(statTypeEnum.Design) + ' ' + validate()"
|
|
4
4
|
:required="attributeCheck(statTypeEnum.Required)"
|
|
5
|
-
:disabled="
|
|
5
|
+
:disabled="disabledCheck(statTypeEnum.Disabled)"
|
|
6
6
|
:type="returnIfExists(statTypeEnum.ElementType)"
|
|
7
7
|
:value="`${object?.Stats[statTypeEnum.Value].Data !== null ? object.Stats[statTypeEnum.Value].Data.name === undefined ? valueName : object.Stats[statTypeEnum.Value].Data.name : ''}`"
|
|
8
8
|
:placeholder="returnIfExists(statTypeEnum.Placeholder)"
|
|
@@ -43,23 +43,29 @@ export default class DataListComponent extends Vue {
|
|
|
43
43
|
object!: ObjectTemplate
|
|
44
44
|
displayOptions = false
|
|
45
45
|
options: Option[] = []
|
|
46
|
+
loading = true
|
|
46
47
|
|
|
47
48
|
returnIfExists (tag: number): string {
|
|
48
|
-
|
|
49
|
+
if (this.object.Stats[tag]) {
|
|
50
|
+
return this.object.Stats[tag].Data
|
|
51
|
+
}
|
|
52
|
+
return ''
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
async created() {
|
|
52
56
|
await this.fetchOptions();
|
|
57
|
+
this.loading = false
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
// Extract the logic for fetching options data into a separate method
|
|
56
61
|
async fetchOptions() {
|
|
62
|
+
console.log(this.object.Stats)
|
|
57
63
|
try {
|
|
58
64
|
const parsedObject: { link?: string } = JSON.parse(this.object.Stats[this.statTypeEnum.ItemList].Data)[0];
|
|
59
65
|
if (parsedObject.link) {
|
|
60
|
-
const response = await http.get(parsedObject.link + '/' + this.object.Stats[this.statTypeEnum.Name].Data)
|
|
61
|
-
this.options = response.data
|
|
62
|
-
this.
|
|
66
|
+
const response = await http.get(parsedObject.link + '/' + this.object.Stats[this.statTypeEnum.Name].Data)
|
|
67
|
+
this.options = response.data
|
|
68
|
+
this.object.Stats[this.statTypeEnum.ItemList].Data = JSON.stringify(response.data)
|
|
63
69
|
} else {
|
|
64
70
|
this.options = JSON.parse(this.object.Stats[this.statTypeEnum.ItemList].Data);
|
|
65
71
|
}
|
|
@@ -70,7 +76,7 @@ export default class DataListComponent extends Vue {
|
|
|
70
76
|
|
|
71
77
|
getValue (statEnum: number, indexStatTypeEnum = StatTypeEnum.Option) : string {
|
|
72
78
|
if (this.object.Stats[statEnum]) {
|
|
73
|
-
if (this.object.Stats[indexStatTypeEnum] && this.object.Stats[statEnum] &&
|
|
79
|
+
if (this.object.Stats[indexStatTypeEnum] && this.object.Stats[statEnum] && this.isJSON(this.object.Stats[statEnum].Data)) {
|
|
74
80
|
const data = JSON.parse(this.object.Stats[statEnum].Data)
|
|
75
81
|
return data[Number(this.object.Stats[indexStatTypeEnum].Data)]
|
|
76
82
|
} else {
|
|
@@ -82,11 +88,20 @@ export default class DataListComponent extends Vue {
|
|
|
82
88
|
|
|
83
89
|
get valueName (): string {
|
|
84
90
|
const temp = this.options.find((option: any) => option.id === this.getValue(StatTypeEnum.Value, StatTypeEnum.ValueIndices))
|
|
85
|
-
|
|
91
|
+
if (!temp) { return this.getValue(StatTypeEnum.Value, StatTypeEnum.ValueIndices) }
|
|
92
|
+
return temp?.name
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
attributeCheck (statType : number) : boolean | string {
|
|
89
|
-
|
|
96
|
+
if (this.object.Stats[statType] === undefined) { return false }
|
|
97
|
+
if (this.object.Stats[statType].Data === '') { return false }
|
|
98
|
+
return this.object.Stats[statType].Data
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
disabledCheck (statType : number) : boolean | string {
|
|
102
|
+
if (this.object.Stats[statType] === undefined) { return (false || this.loading) }
|
|
103
|
+
if (this.object.Stats[statType].Data === '') { return (false || this.loading) }
|
|
104
|
+
return this.object.Stats[statType].Data
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
validate () : string {
|
|
@@ -103,21 +118,23 @@ export default class DataListComponent extends Vue {
|
|
|
103
118
|
this.regionType.RegionTypes[object.Region].ObjectTypes[object.ObjectEnum].ChooseSubType(object, value)
|
|
104
119
|
}
|
|
105
120
|
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
check (id : string) : boolean {
|
|
122
|
+
if (this.object.Stats[this.statTypeEnum.Value] === undefined || id === undefined) { return false }
|
|
123
|
+
return this.object.Stats[this.statTypeEnum.Value].Data === id.toString()
|
|
108
124
|
}
|
|
109
125
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return false;
|
|
126
|
+
isJSON (str: string): boolean {
|
|
127
|
+
let temp = null
|
|
128
|
+
try {
|
|
129
|
+
temp = JSON.parse(str)
|
|
130
|
+
} catch (e) {
|
|
131
|
+
return false
|
|
132
|
+
}
|
|
133
|
+
return Array.isArray(temp)
|
|
119
134
|
}
|
|
135
|
+
|
|
120
136
|
}
|
|
137
|
+
|
|
121
138
|
</script>
|
|
122
139
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
123
140
|
<style scoped>
|