Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wotamann committed May 18, 2019
1 parent d0bbc0d commit b161bcf
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 94 deletions.
32 changes: 16 additions & 16 deletions example/src/components/array.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,34 @@ export default {
]
},
mySchema: {
tasksA: {
type: 'array',
flex: 5,
tasksA: {
type: 'array',
flex: 5,
// Template Object
schema: { done: { type: 'checkbox', label: 'Ok', flex: 3 }, title: { type: 'text' }, flex: 8 }
schema: { done: { type: 'checkbox', label: 'Ok', flex: 3 }, title: { type: 'text' }, flex: 8 }
},
tasksB: {
type: 'array',
tasksB: {
type: 'array',
flex: 5,
offset:1,
// Array with Schema-Objects
offset: 1,
// Array with Schema-Objects
schema: [
{ done: { type: 'checkbox', label: 'Ok 1', color:'brown', flex: 3 }, title: { type: 'text' }, flex: 8 },
{ done: { type: 'checkbox', label: 'Ok 2', color:'green', flex: 3 }, title: { type: 'text' }, flex: 8 },
{ done: { type: 'checkbox', label: 'Ok 3', color:'blue',flex: 3 }, title: { type: 'text' }, flex: 8 },
{ done: { type: 'checkbox', label: 'Ok 1', color: 'brown', flex: 3 }, title: { type: 'text' }, flex: 8 },
{ done: { type: 'checkbox', label: 'Ok 2', color: 'green', flex: 3 }, title: { type: 'text' }, flex: 8 },
{ done: { type: 'checkbox', label: 'Ok 3', color: 'blue', flex: 3 }, title: { type: 'text' }, flex: 8 }
]
}
}
}
},
methods: {
update ({ on, parentId, id, index, key, value, obj, event, params, data, schema }) {
console.log( 'UPDATED: On', on, ' ID:', id, ' Obj:', obj, ' Key|Value|Params|Index:', key, value, params, index, ' Data|Schema:', data, schema, ' Parent:', parent)
if (key === 'done') {
data.title = Math.random()
console.log('UPDATED: On', on, ' ID:', id, ' Obj:', obj, ' Key|Value|Params|Index:', key, value, params, index, ' Data|Schema:', data, schema, ' Parent:', parent)
if (key === 'done') {
data.title = Math.random()
schema.title.disabled = !value
schema.done.label = index + ' Done'
schema.done.label = index + ' Done'
schema.done.color = value ? 'green' : 'red'
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/src/components/complex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {
console.log('this.mySchema.checkbox[2].checkbox1[0].hidden', this.mySchema.checkbox[2].checkbox1[0].hidden)
},
update ({ on, id, index, key, value, obj, event, params, data, schema, parent }) {
console.log( 'UPDATED: On', on, ' ID:', id, ' Obj:', obj, ' Key|Value|Params|Index:', key, value, params, index, ' Data|Schema:', data, schema, ' Parent:', parent)
console.log('UPDATED: On', on, ' ID:', id, ' Obj:', obj, ' Key|Value|Params|Index:', key, value, params, index, ' Data|Schema:', data, schema, ' Parent:', parent)
// print content
if (on === 'click' && key === 'subgroups.content' && (params && params.text) === 'print') {
Expand Down
30 changes: 15 additions & 15 deletions example/src/components/conditional.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ export default {
tasks: {
type: 'array',
hidden: this.hidden,
flex: { xs: 12, sm: 6 },
flex: { xs: 12, sm: 6 },
// OPTION A: Schema as Object: Is Template for all Items in Array (Schema-Objects are NOT independent )
// schema: {
// OPTION A: Schema as Object: Is Template for all Items in Array (Schema-Objects are NOT independent )
// schema: {
// done: { type: 'checkbox', label: 'Ok', disabled: false, color:'green', flex: 3 },
// title: { type: 'text', placeholder: 'to do...', disabled: false, flex: 8 }
// },
// OPTION B: Schema as Array: define independent Schema for each Item
template: {
done: { type: 'checkbox', label: 'Ok', disabled: false, color:'brown', flex: 3 },
template: {
done: { type: 'checkbox', label: 'Ok', disabled: false, color: 'brown', flex: 3 },
title: { type: 'text', placeholder: 'to do...', disabled: false, flex: 8 }
},
schema: [
{
done: { type: 'checkbox', label: 'Ok', disabled: false, color:'green', flex: 3 },
{
done: { type: 'checkbox', label: 'Ok', disabled: false, color: 'green', flex: 3 },
title: { type: 'text', placeholder: 'to do...', disabled: false, flex: 8 }
},{
done: { type: 'checkbox', label: 'No', disabled: false, color:'red', flex: 3 },
}, {
done: { type: 'checkbox', label: 'No', disabled: false, color: 'red', flex: 3 },
title: { type: 'text', placeholder: 'to do...', disabled: false, flex: 8 }
},{
done: { type: 'checkbox', label: 'Ok', disabled: false, color:'blue', flex: 3 },
}, {
done: { type: 'checkbox', label: 'Ok', disabled: false, color: 'blue', flex: 3 },
title: { type: 'text', placeholder: 'to do...', disabled: false, flex: 8 }
}
]
Expand All @@ -86,7 +86,7 @@ export default {
methods: {
update (updated) {
let { on, id, index, parentId, key, value, obj, event, params, data, schema, parent } = updated
this.log(updated)
if (key === 'button') this.toggle()
Expand All @@ -95,12 +95,12 @@ export default {
if (key === 'add') {
// MODIFY Value & Schema Array
this.myValue.tasks.unshift({...task})
this.myValue.tasks.unshift({ ...task })
let insert = cloneDeep(this.mySchema.tasks.template)
this.mySchema.tasks.schema.unshift(insert)
}
if (key === 'done' && value === true) {
if (key === 'done' && value === true) {
// MODIFY Value & Schema Array
this.myValue.tasks.splice(index, 1)
this.mySchema.tasks.schema.splice(index, 1)
Expand All @@ -112,7 +112,7 @@ export default {
},
log ({ on, id, index, parentId, key, value, obj, event, params, data, schema, parent } = {}) {
console.log( 'UPDATED: On', on, ' ID:', id, ' Obj:', obj, ' Key|Value|Params|Index:', key, value, params, index, ' Data|Schema:', data, schema, ' Parent:', parent)
console.log('UPDATED: On', on, ' ID:', id, ' Obj:', obj, ' Key|Value|Params|Index:', key, value, params, index, ' Data|Schema:', data, schema, ' Parent:', parent)
}
}
}
Expand Down
118 changes: 56 additions & 62 deletions example/src/components/vFormBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
:schema= "sanitizeSchema(obj, idx)"
/>
<!-- v-bind = "clonedSchema(obj)" -->

</slot>
</div>
</template>
Expand Down Expand Up @@ -151,47 +151,47 @@

<script>
// import & declarations
import { get, isPlainObject, isFunction, isArray, orderBy, cloneDeep } from 'lodash'
const typeToComponent = {
// implemented in Vuetify
text: 'v-text-field',
password: 'v-text-field',
email: 'v-text-field',
// native Input Types - https://www.wufoo.com/html5/
tel: 'v-text-field',
url: 'v-text-field',
color: 'v-text-field',
search: 'v-text-field',
number: 'v-text-field',
file: 'v-text-field',
list: 'v-list',
range: 'v-slider'
}
import { get, isPlainObject, isFunction, isArray, orderBy, cloneDeep } from 'lodash'
const typeToComponent = {
// implemented in Vuetify
text: 'v-text-field',
password: 'v-text-field',
email: 'v-text-field',
// native Input Types - https://www.wufoo.com/html5/
tel: 'v-text-field',
url: 'v-text-field',
color: 'v-text-field',
search: 'v-text-field',
number: 'v-text-field',
file: 'v-text-field',
list: 'v-list',
range: 'v-slider'
}
const orderDirection = 'ASC'
const pathDelimiter = '.'
const classKeyDelimiter = '-'
const defaultID = 'form-base'
const orderDirection = 'ASC'
const pathDelimiter = '.'
const classKeyDelimiter = '-'
const defaultID = 'form-base'
const itemClassAppendix = 'item'
const typeClassAppendix = 'type'
const keyClassAppendix = 'key'
const itemClassAppendix = 'item'
const typeClassAppendix = 'type'
const keyClassAppendix = 'key'
const arraySlotAppendix = 'slot-array'
const topSlotAppendix = 'slot-top'
const itemSlotAppendix = 'slot-item'
const bottomSlotAppendix = 'slot-bottom'
const arraySlotAppendix = 'slot-array'
const topSlotAppendix = 'slot-top'
const itemSlotAppendix = 'slot-item'
const bottomSlotAppendix = 'slot-bottom'
const clear = 'clear'
const button = 'button'
const append = 'append'
const appendOuter = 'append-outer'
const prepend = 'prepend'
const prependInner = 'prepend-inner'
const clear = 'clear'
const button = 'button'
const append = 'append'
const appendOuter = 'append-outer'
const prepend = 'prepend'
const prependInner = 'prepend-inner'
let defaultSchemaSchema = null
let defaultSchemaSchema = null
//
export default {
Expand Down Expand Up @@ -241,28 +241,21 @@ export default {
},
methods: {
sanitizeSchema(obj, idx) {
sanitizeSchema (obj, idx) {
let clonedObj = cloneDeep(obj)
let clonedSchema = isArray( clonedObj.schema.schema ) ? clonedObj.schema.schema[idx] : clonedObj.schema.schema
if ( isArray(obj.schema.schema) ){
obj.schema.schema[idx] = obj.schema.schema[idx] ? obj.schema.schema[idx] : cloneDeep(defaultSchemaSchema)
let clonedSchema = isArray(clonedObj.schema.schema) ? clonedObj.schema.schema[idx] : clonedObj.schema.schema
if (isArray(obj.schema.schema)) {
obj.schema.schema[idx] = obj.schema.schema[idx] ? obj.schema.schema[idx] : cloneDeep(defaultSchemaSchema)
} else {
obj.schema.schema = []
defaultSchemaSchema = clonedObj.schema.schema
obj.schema.schema[idx] = obj.schema.schema[idx] ? obj.schema.schema[idx] : cloneDeep(defaultSchemaSchema)
obj.schema.schema[idx] = obj.schema.schema[idx] ? obj.schema.schema[idx] : cloneDeep(defaultSchemaSchema)
}
// console.warn('defaultSchemaSchema', defaultSchemaSchema);
// console.warn('{...defaultSchemaSchema}', {...defaultSchemaSchema});
return obj.schema.schema[idx]
// console.warn('defaultSchemaSchema', defaultSchemaSchema);
// console.warn('{...defaultSchemaSchema}', {...defaultSchemaSchema});
return obj.schema.schema[idx]
},
mapTypeToComponent (type) {
Expand Down Expand Up @@ -398,16 +391,17 @@ export default {
})
},
onFocus (event, obj) {
this.emitValue('focus', {
on: 'focus', id: this.ref,
this.emitValue('focus', {
on: 'focus',
id: this.ref,
index: this.ref.replace(/\D/g, ''),
parentId: this.$parent.id,
key: obj.key,
value: obj.value,
obj,
event,
data: this.storeStateData,
schema: this.storeStateSchema
parentId: this.$parent.id,
key: obj.key,
value: obj.value,
obj,
event,
data: this.storeStateData,
schema: this.storeStateSchema
})
},
onSwipe (pos, obj) {
Expand Down

0 comments on commit b161bcf

Please sign in to comment.