Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #623 from FlowzPlatform/issue-594-n8
Browse files Browse the repository at this point in the history
sidebar-socket-fixes
  • Loading branch information
faizansaiyed authored Oct 12, 2018
2 parents a9d2f25 + 99ab14e commit 9ee8065
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 173 deletions.
148 changes: 74 additions & 74 deletions client/src/components/SchemaView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ export default {
checkValidation (data, ent, permission) {
let self = this
for (let v of ent) {
if (permission[v.name] !== undefined) {
if (permission !== undefined && permission[v.name] !== undefined) {
if (permission[v.name].write || permission[v.name].read) {
if (v.customtype) {
for (let d of data[v.name]) {
Expand Down Expand Up @@ -1063,91 +1063,91 @@ export default {
}
} else {
if (v.customtype) {
for (let d of data[v.name]) {
self.validFlag = self.checkValidation(d, v.entity[0].entity, permission)
}
} else {
if (!v.property.optional) {
if (data[v.name] === '') {
self.validErr.push({name: v.name, errmsg: 'Field is required.'})
for (let d of data[v.name]) {
self.validFlag = self.checkValidation(d, v.entity[0].entity, permission)
}
} else {
if (!v.property.optional) {
if (data[v.name] === '') {
self.validErr.push({name: v.name, errmsg: 'Field is required.'})
self.validFlag = false
} else if (Array.isArray(data[v.name]) && data[v.name].length === 0) {
self.validErr.push({name: v.name, errmsg: 'File is required.'})
self.validFlag = false
} else if (v.type === 'text') {
if (v.property.regEx !== '') {
let patt0 = v.property.regEx
let res0 = patt0.test(data[v.name])
if (!res0) {
self.validErr.push({name: v.name, errmsg: 'Invalid Email.'})
self.validFlag = false
}
} else if (v.property.max !== 0) {
if (data[v.name].length > v.property.max) {
self.validErr.push({name: v.name, errmsg: 'max ' + v.property.max + ' characters allowed.'})
self.validFlag = false
}
} else if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Email, Please select allow one.'})
self.validFlag = false
}
}
} else if (v.type === 'email' && data[v.name] !== '') {
let patt1 = (v.property.regEx === '') ? new RegExp('[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,3}$') : new RegExp(v.property.regEx)
let res1 = patt1.test(data[v.name])
if (!res1) {
self.validErr.push({name: v.name, errmsg: 'Invalid Email.'})
self.validFlag = false
} else if (Array.isArray(data[v.name]) && data[v.name].length === 0) {
self.validErr.push({name: v.name, errmsg: 'File is required.'})
} else if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Email, Please select allow one.'})
self.validFlag = false
}
}
} else if (v.type === 'phone') {
let patt2 = (v.property.regEx === '') ? new RegExp('^\\(?([0-9]{3})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$') : new RegExp(v.property.regEx)
let res2 = patt2.test(data[v.name])
if (!res2) {
self.validErr.push({name: v.name, errmsg: 'Invalid Phone.'})
self.validFlag = false
} else if (v.type === 'text') {
if (v.property.regEx !== '') {
let patt0 = v.property.regEx
let res0 = patt0.test(data[v.name])
if (!res0) {
self.validErr.push({name: v.name, errmsg: 'Invalid Email.'})
self.validFlag = false
}
} else if (v.property.max !== 0) {
if (data[v.name].length > v.property.max) {
self.validErr.push({name: v.name, errmsg: 'max ' + v.property.max + ' characters allowed.'})
self.validFlag = false
}
} else if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Email, Please select allow one.'})
self.validFlag = false
}
} else if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Phone, Please select allow one.'})
self.validFlag = false
}
} else if (v.type === 'email' && data[v.name] !== '') {
let patt1 = (v.property.regEx === '') ? new RegExp('[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,3}$') : new RegExp(v.property.regEx)
let res1 = patt1.test(data[v.name])
if (!res1) {
self.validErr.push({name: v.name, errmsg: 'Invalid Email.'})
}
} else if (v.type === 'number') {
if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Number, Please select allow one.'})
self.validFlag = false
} else if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Email, Please select allow one.'})
self.validFlag = false
}
}
} else if (v.type === 'phone') {
let patt2 = (v.property.regEx === '') ? new RegExp('^\\(?([0-9]{3})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$') : new RegExp(v.property.regEx)
let res2 = patt2.test(data[v.name])
if (!res2) {
self.validErr.push({name: v.name, errmsg: 'Invalid Phone.'})
}
} else if (v.type === 'date') {
if (v.property.mindate !== '' && v.property.maxdate !== '') {
if (data[v.name] < v.property.mindate && data[v.name] > v.property.maxdate) {
self.validErr.push({name: v.name, errmsg: 'Date must in between ' + v.property.mindate + ' and ' + v.property.maxdate})
self.validFlag = false
} else if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Phone, Please select allow one.'})
self.validFlag = false
}
}
} else if (v.type === 'number') {
if (v.property.allowedValue.length > 0) {
let exist = _.indexOf(v.property.allowedValue, data[v.name])
if (exist === -1) {
self.validErr.push({name: v.name, errmsg: 'Not Allowed Number, Please select allow one.'})
self.validFlag = false
}
} else if (v.property.mindate !== '') {
if (data[v.name] < v.property.mindate) {
self.validErr.push({name: v.name, errmsg: 'Date must be greater than or equal ' + v.property.mindate + '.'})
self.validFlag = false
}
} else if (v.type === 'date') {
if (v.property.mindate !== '' && v.property.maxdate !== '') {
if (data[v.name] < v.property.mindate && data[v.name] > v.property.maxdate) {
self.validErr.push({name: v.name, errmsg: 'Date must in between ' + v.property.mindate + ' and ' + v.property.maxdate})
self.validFlag = false
}
} else if (v.property.mindate !== '') {
if (data[v.name] < v.property.mindate) {
self.validErr.push({name: v.name, errmsg: 'Date must be greater than or equal ' + v.property.mindate + '.'})
self.validFlag = false
}
} else if (v.property.maxdate !== '') {
if (data[v.name] > v.property.maxdate) {
self.validErr.push({name: v.name, errmsg: 'Date must be less than or equal ' + v.property.mindate + '.'})
self.validFlag = false
}
} else if (v.property.maxdate !== '') {
if (data[v.name] > v.property.maxdate) {
self.validErr.push({name: v.name, errmsg: 'Date must be less than or equal ' + v.property.mindate + '.'})
self.validFlag = false
}
}
}
}
}
}
}
return self.validFlag
Expand Down
110 changes: 11 additions & 99 deletions client/src/masterLayout/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</template>
<template
v-for="(subItem, key) in getByOrder(item.processList)"
v-if="subItem && subItem.type !== 'startevent' && subItem.type !== 'endevent' && subItem.type !== 'intermediatethrowevent'"
v-if="subItem && subItem.type !== 'startevent' && subItem.type !== 'endevent' && subItem.type !== 'intermediatethrowevent' && subItem.type !== 'exclusivegateway'"
>
<Menu-item
:name="item.id + '/' + subItem.id"
Expand Down Expand Up @@ -176,48 +176,9 @@ export default {
p.count = 0
return p
})
// if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_created'] === undefined) {
// socket.on(m.id.replace(/-/g, '_') + '_created', (data) => {
// // console.log('===created==', data)
// if (data._currentStatus) {
// let finx = _.findIndex(this.flowzList, {id: m.id})
// if (finx !== -1) {
// this.flowzList[finx].processList[data._state].count++
// this.flowzList[finx].count++
// }
// }
// })
// }
// if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_patched'] === undefined) {
// socket.on(m.id.replace(/-/g, '_') + '_patched', (data) => {
// // console.log('===patched==', data)
// let finx = _.findIndex(this.flowzList, {id: m.id})
// if (finx !== -1 && !data._currentStatus && data._next === null) {
// if (this.flowzList[finx].processList[data._state].count > 0) {
// this.flowzList[finx].processList[data._state].count--
// }
// if (this.flowzList[finx].count > 0) {
// this.flowzList[finx].count--
// }
// }
// })
// }
// if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_removed'] === undefined) {
// socket.on(m.id.replace(/-/g, '_') + '_removed', (data) => {
// // console.log('===removed==', data)
// if (data._currentStatus) {
// let finx = _.findIndex(this.flowzList, {id: m.id})
// if (finx !== -1) {
// this.flowzList[finx].processList[data._state].count--
// this.flowzList[finx].count--
// }
// }
// })
// }
return m
})
this.loading = false
// console.log('this.flowzList', this.flowzList)
this.setCounters()
})
.catch(error => {
Expand Down Expand Up @@ -300,62 +261,8 @@ export default {
}
},
setCounters (sitem) {
// if (sitem) {
// if (this.$store.state.role === 1) {
// dflowzdataModal.get(null, {
// $paginate: false,
// $select: ['_state'],
// _currentStatus: true
// }, {
// ftablename: sitem.id.replace(/-/g, '_')
// }).then(res => {
// console.log('res count', res.data)
// sitem.count = 0
// _.map(sitem.processList, (pitem) => {
// pitem.count = _.filter(res.data, {_state: pitem.id}).length
// sitem.count += pitem.count
// })
// // for (let pitem in sitem.processList) {
// // pitem.count = _.filter(res.data, {currentStatus: pitem.id}).length
// // sitem.count += pitem.count
// // }
// }).catch(err => {
// console.log('error', err)
// })
// } else {
// let once = false
// let mdata = []
// sitem.count = 0
// for (let pitem in sitem.processList) {
// if (!once) {
// dflowzdataModal.get(null, {
// $paginate: false,
// $select: ['_state'],
// _currentStatus: true
// }, {
// workflowid: 'workflow_' + sitem.id,
// stateid: sitem.processList[pitem].id,
// ftablename: sitem.id.replace(/-/g, '_')
// }).then(res => {
// if (res.data.length > 0) {
// once = true
// mdata = res.data
// sitem.processList[pitem].count = _.filter(res.data, {_state: sitem.processList[pitem].id}).length
// sitem.count += sitem.processList[pitem].count
// }
// }).catch(err => {
// console.log('error', err)
// })
// } else {
// sitem.processList[pitem].count = _.filter(mdata, {_state: sitem.processList[pitem].id}).length
// sitem.count += sitem.processList[pitem].count
// }
// }
// }
// } else {
for (let item of this.flowzList) {
if (this.$store.state.role === 1) {
// item.count = 9
dflowzdataModal.get(null, {
$paginate: false,
$select: ['_state'],
Expand All @@ -366,7 +273,6 @@ export default {
if (res.data.length > 0) {
item.count = 0
_.map(item.processList, (pitem) => {
// console.log('_.filter(res.data, {_state: pitem.id}).length', _.filter(res.data, {_state: pitem.id}).length)
pitem.count = _.filter(res.data, {_state: pitem.id}).length
item.count += pitem.count
})
Expand All @@ -378,7 +284,6 @@ export default {
let isonce = false
let pdata = []
for (let key in item.processList) {
// console.log('item', item)
if (!isonce) {
dflowzdataModal.get(null, {
$paginate: false,
Expand All @@ -405,7 +310,6 @@ export default {
}
}
}
// }
}
},
computed: {
Expand All @@ -427,6 +331,12 @@ export default {
},
mounted () {
this.init()
// console.log(this.$feathers)
},
beforeDestroy () {
this.$feathers.services.dflowzdata.removeAllListeners('_created')
this.$feathers.services.dflowzdata.removeAllListeners('_removed')
this.$feathers.services.dflowzdata.removeAllListeners('_patched')
},
feathers: {
'flowz': {
Expand All @@ -450,7 +360,8 @@ export default {
},
'dflowzdata': {
_created (data) {
// console.log('================created==============', data)
// console.log('================created==============')
// alert('Created' + Object.keys(data))
let keys = Object.keys(data)
for (let tName of keys) {
if (data[tName]._currentStatus) {
Expand All @@ -465,7 +376,8 @@ export default {
_updated (data) {
},
_patched (data) {
// console.log('==============patched============', data)
// console.log('==============patched============')
// alert('Patched' + Object.keys(data))
let keys = Object.keys(data)
for (let tName of keys) {
let finx = _.findIndex(this.flowzList, {id: tName.replace(/_/g, '-')})
Expand Down

0 comments on commit 9ee8065

Please sign in to comment.