@websy/websy-designs 1.3.0 → 1.3.1
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/dist/server/routes/v1/shop.js +52 -15
- package/dist/websy-designs-es6.debug.js +134 -55
- package/dist/websy-designs-es6.js +146 -54
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +134 -55
- package/dist/websy-designs.js +146 -54
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -52,9 +52,11 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
52
52
|
getBasket(req).then(basket => {
|
|
53
53
|
basket.items[basketItemId] = req.body
|
|
54
54
|
if (req.session && req.session.user) {
|
|
55
|
-
saveBasket(req, basket).then(() => {
|
|
55
|
+
saveBasket(req, basket, 'items').then(() => {
|
|
56
56
|
basket.items = Object.values(basket.items)
|
|
57
57
|
res.json(basket)
|
|
58
|
+
}, err => {
|
|
59
|
+
res.json({err})
|
|
58
60
|
})
|
|
59
61
|
}
|
|
60
62
|
else {
|
|
@@ -71,6 +73,8 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
71
73
|
saveBasket(req, basket).then(() => {
|
|
72
74
|
basket.items = Object.values(basket.items)
|
|
73
75
|
res.json(basket)
|
|
76
|
+
}, err => {
|
|
77
|
+
res.json({err})
|
|
74
78
|
})
|
|
75
79
|
}
|
|
76
80
|
else {
|
|
@@ -84,9 +88,11 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
84
88
|
getBasket(req).then(basket => {
|
|
85
89
|
basket.meta = req.body
|
|
86
90
|
if (req.session && req.session.user) {
|
|
87
|
-
saveBasket(req, basket).then(() => {
|
|
91
|
+
saveBasket(req, basket, 'meta').then(() => {
|
|
88
92
|
basket.items = Object.values(basket.items)
|
|
89
93
|
res.json(basket)
|
|
94
|
+
}, err => {
|
|
95
|
+
res.json({err})
|
|
90
96
|
})
|
|
91
97
|
}
|
|
92
98
|
else {
|
|
@@ -105,9 +111,11 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
105
111
|
basket.items[basketItemId] = req.body
|
|
106
112
|
}
|
|
107
113
|
if (req.session && req.session.user) {
|
|
108
|
-
saveBasket(req, basket).then(() => {
|
|
114
|
+
saveBasket(req, basket, 'items').then(() => {
|
|
109
115
|
basket.items = Object.values(basket.items)
|
|
110
116
|
res.json(basket)
|
|
117
|
+
}, err => {
|
|
118
|
+
res.json({err})
|
|
111
119
|
})
|
|
112
120
|
}
|
|
113
121
|
else {
|
|
@@ -120,9 +128,11 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
120
128
|
getBasket(req).then(basket => {
|
|
121
129
|
basket.meta = req.body
|
|
122
130
|
if (req.session && req.session.user) {
|
|
123
|
-
saveBasket(req, basket).then(() => {
|
|
131
|
+
saveBasket(req, basket, 'meta').then(() => {
|
|
124
132
|
basket.items = Object.values(basket.items)
|
|
125
133
|
res.json(basket)
|
|
134
|
+
}, err => {
|
|
135
|
+
res.json({err})
|
|
126
136
|
})
|
|
127
137
|
}
|
|
128
138
|
else {
|
|
@@ -136,9 +146,11 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
136
146
|
getBasket(req).then(basket => {
|
|
137
147
|
delete basket.items[basketItemId]
|
|
138
148
|
if (req.session && req.session.user) {
|
|
139
|
-
saveBasket(req, basket).then(() => {
|
|
149
|
+
saveBasket(req, basket, 'items').then(() => {
|
|
140
150
|
basket.items = Object.values(basket.items)
|
|
141
151
|
res.json(basket)
|
|
152
|
+
}, err => {
|
|
153
|
+
res.json({err})
|
|
142
154
|
})
|
|
143
155
|
}
|
|
144
156
|
else {
|
|
@@ -152,9 +164,11 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
152
164
|
basket.items = {}
|
|
153
165
|
basket.meta = {}
|
|
154
166
|
if (req.session && req.session.user) {
|
|
155
|
-
saveBasket(req, basket).then(() => {
|
|
167
|
+
saveBasket(req, basket, 'items').then(() => {
|
|
156
168
|
basket.items = []
|
|
157
169
|
res.json(basket)
|
|
170
|
+
}, err => {
|
|
171
|
+
res.json({err})
|
|
158
172
|
})
|
|
159
173
|
}
|
|
160
174
|
else {
|
|
@@ -180,16 +194,21 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
180
194
|
basket.items = JSON.parse(basket.items)
|
|
181
195
|
}
|
|
182
196
|
else {
|
|
183
|
-
basket.items =
|
|
197
|
+
basket.items = {}
|
|
184
198
|
}
|
|
185
199
|
}
|
|
186
200
|
try {
|
|
187
201
|
basket.meta = JSON.parse(JSONSafeRead(basket.meta))
|
|
188
202
|
}
|
|
189
203
|
catch (error) {
|
|
190
|
-
console.log('data got saved incorrectly')
|
|
204
|
+
// console.log('data got saved incorrectly')
|
|
191
205
|
if (basket.meta) {
|
|
192
|
-
|
|
206
|
+
try {
|
|
207
|
+
basket.meta = JSON.parse(basket.meta)
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
//
|
|
211
|
+
}
|
|
193
212
|
}
|
|
194
213
|
else {
|
|
195
214
|
basket.meta = {}
|
|
@@ -208,8 +227,8 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
208
227
|
})
|
|
209
228
|
}
|
|
210
229
|
|
|
211
|
-
function saveBasket (req, basket) {
|
|
212
|
-
return new Promise((resolve, reject) => {
|
|
230
|
+
function saveBasket (req, basket, itemsMeta) {
|
|
231
|
+
return new Promise((resolve, reject) => {
|
|
213
232
|
const checkSql = `
|
|
214
233
|
SELECT COUNT(*) as count FROM ${req.params.basketCompare} WHERE userid = '${req.session.user.id}'
|
|
215
234
|
`
|
|
@@ -219,9 +238,19 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
219
238
|
dbHelper.execute(checkSql).then(result => {
|
|
220
239
|
if (result.rows.length > 0 && result.rows[0].count > 0) {
|
|
221
240
|
// update
|
|
222
|
-
|
|
223
|
-
UPDATE ${req.params.basketCompare} SET complete = ${basket.complete}
|
|
241
|
+
let sql = `
|
|
242
|
+
UPDATE ${req.params.basketCompare} SET complete = ${basket.complete}
|
|
224
243
|
`
|
|
244
|
+
if (itemsMeta === 'items') {
|
|
245
|
+
for (let key in basket.items) {
|
|
246
|
+
basket.items[key] = sanitizeItem(basket.items[key])
|
|
247
|
+
}
|
|
248
|
+
sql += `, items = '${JSON.stringify(basket.items)}' `
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
sql += `, meta = '${JSONSafeWrite(JSON.stringify(basket.meta))}' `
|
|
252
|
+
}
|
|
253
|
+
sql += `WHERE userid = '${req.session.user.id}'`
|
|
225
254
|
dbHelper.execute(sql).then(result => {
|
|
226
255
|
resolve()
|
|
227
256
|
}, err => reject(err))
|
|
@@ -240,10 +269,18 @@ function ShopRoutes (dbHelper, engine, app) {
|
|
|
240
269
|
}
|
|
241
270
|
|
|
242
271
|
function JSONSafeWrite (v) {
|
|
243
|
-
return v.replace(/'/g, '\'\'').replace(/\\(?=[bfnrtv0'
|
|
272
|
+
return v.replace(/'/g, '\'\'').replace(/\\(?=[bfnrtv0'])/g, '\\\\').replace(/\t/g, '')
|
|
244
273
|
}
|
|
245
274
|
function JSONSafeRead (v) {
|
|
246
|
-
return v.replace(/''/g, '\'').replace(/\\(?=[^bfnrtv0'
|
|
275
|
+
return v.replace(/''/g, '\'').replace(/\\(?=[^bfnrtv0'])/g, '\\\\').replace(/\t/g, '')
|
|
276
|
+
}
|
|
277
|
+
function sanitizeItem (item) {
|
|
278
|
+
for (let key in item) {
|
|
279
|
+
if (typeof item[key] === 'string') {
|
|
280
|
+
item[key] = item[key].replace(/"/g, '\\"')
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return item
|
|
247
284
|
}
|
|
248
285
|
|
|
249
286
|
function readyCallback () {
|
|
@@ -375,6 +375,7 @@ class WebsyDatePicker {
|
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
close (confirm, isRange = false) {
|
|
378
|
+
console.trace()
|
|
378
379
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
379
380
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
380
381
|
const el = document.getElementById(this.elementId)
|
|
@@ -391,19 +392,19 @@ class WebsyDatePicker {
|
|
|
391
392
|
for (let i = this.selectedRangeDates[0]; i < this.selectedRangeDates[1] + 1; i++) {
|
|
392
393
|
hoursOut.push(this.options.hours[i])
|
|
393
394
|
}
|
|
394
|
-
this.options.onChange(hoursOut, true)
|
|
395
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
395
396
|
}
|
|
396
397
|
else {
|
|
397
|
-
this.options.onChange(this.selectedRangeDates, true)
|
|
398
|
+
this.options.onChange(this.selectedRangeDates, true, this.selectedRange)
|
|
398
399
|
}
|
|
399
400
|
}
|
|
400
401
|
else {
|
|
401
402
|
if (this.options.mode === 'hour') {
|
|
402
403
|
let hoursOut = this.currentselection.map(h => this.options.hours[h])
|
|
403
|
-
this.options.onChange(hoursOut, true)
|
|
404
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
404
405
|
}
|
|
405
406
|
else {
|
|
406
|
-
this.options.onChange(this.currentselection, isRange)
|
|
407
|
+
this.options.onChange(this.currentselection, isRange, this.selectedRange)
|
|
407
408
|
}
|
|
408
409
|
}
|
|
409
410
|
}
|
|
@@ -426,7 +427,7 @@ class WebsyDatePicker {
|
|
|
426
427
|
d = new Date(d)
|
|
427
428
|
}
|
|
428
429
|
// d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
429
|
-
return new Date(d.
|
|
430
|
+
return new Date(d.setUTCHours(12, 0, 0, 0))
|
|
430
431
|
}
|
|
431
432
|
handleClick (event) {
|
|
432
433
|
if (event.target.classList.contains('websy-date-picker-header')) {
|
|
@@ -549,7 +550,7 @@ class WebsyDatePicker {
|
|
|
549
550
|
let rangeEnd
|
|
550
551
|
if (this.options.mode === 'date') {
|
|
551
552
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
552
|
-
d.
|
|
553
|
+
d.setUTCHours(12, 0, 0, 0)
|
|
553
554
|
d = d.getTime()
|
|
554
555
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
555
556
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
@@ -608,9 +609,11 @@ class WebsyDatePicker {
|
|
|
608
609
|
else if (this.options.mode === 'hour') {
|
|
609
610
|
dateEl = document.getElementById(`${this.elementId}_${d}_hour`)
|
|
610
611
|
}
|
|
611
|
-
dateEl
|
|
612
|
-
|
|
613
|
-
|
|
612
|
+
if (dateEl) {
|
|
613
|
+
dateEl.classList.add('selected')
|
|
614
|
+
dateEl.classList.add('first')
|
|
615
|
+
dateEl.classList.add('last')
|
|
616
|
+
}
|
|
614
617
|
})
|
|
615
618
|
}
|
|
616
619
|
}
|
|
@@ -832,7 +835,7 @@ class WebsyDatePicker {
|
|
|
832
835
|
yearList.reverse()
|
|
833
836
|
}
|
|
834
837
|
html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
|
|
835
|
-
html += yearList.map(d => `<li id='${this.elementId}_${d.id}_year' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
838
|
+
html += yearList.map(d => `<li id='${this.elementId}_${d.id}_year' data-id='${d.id}' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
836
839
|
html += `</ul></div>`
|
|
837
840
|
}
|
|
838
841
|
else if (this.options.mode === 'monthyear') {
|
|
@@ -849,7 +852,7 @@ class WebsyDatePicker {
|
|
|
849
852
|
}
|
|
850
853
|
html += paddedMonths.join('')
|
|
851
854
|
}
|
|
852
|
-
html += this.monthYears[year].map(d => `<li id='${this.elementId}_${d.id}_monthyear' data-year='${d.year}' class='websy-dp-date websy-dp-monthyear'>${d.month}</li>`).join('')
|
|
855
|
+
html += this.monthYears[year].map(d => `<li id='${this.elementId}_${d.id}_monthyear' data-id='${d.id}' data-year='${d.year}' class='websy-dp-date websy-dp-monthyear'>${d.month}</li>`).join('')
|
|
853
856
|
html += `</ul>`
|
|
854
857
|
}
|
|
855
858
|
html += `</div>`
|
|
@@ -942,15 +945,6 @@ class WebsyDatePicker {
|
|
|
942
945
|
this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
|
|
943
946
|
this.currentselection = this.options.ranges[this.options.mode][index].range.map(d => d.getTime())
|
|
944
947
|
this.selectedRange = +index
|
|
945
|
-
const el = document.getElementById(`${this.elementId}_header`)
|
|
946
|
-
if (el) {
|
|
947
|
-
if (this.selectedRange === 0) {
|
|
948
|
-
el.classList.remove('range-selected')
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
el.classList.add('range-selected')
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
948
|
this.highlightRange()
|
|
955
949
|
this.updateRange()
|
|
956
950
|
this.close(confirm, true)
|
|
@@ -959,14 +953,16 @@ class WebsyDatePicker {
|
|
|
959
953
|
selectCustomRange (rangeInput) {
|
|
960
954
|
this.selectedRange = -1
|
|
961
955
|
let isContinuousRange = true
|
|
962
|
-
if (rangeInput.length === 1) {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
}
|
|
966
|
-
else if (rangeInput.length === 2) {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
}
|
|
956
|
+
// if (rangeInput.length === 1) {
|
|
957
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
958
|
+
// this.customRangeSelected = true
|
|
959
|
+
// }
|
|
960
|
+
// else if (rangeInput.length === 2) {
|
|
961
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
962
|
+
// this.customRangeSelected = true
|
|
963
|
+
// }
|
|
964
|
+
this.selectedRangeDates = [...rangeInput]
|
|
965
|
+
this.customRangeSelected = true
|
|
970
966
|
rangeInput.forEach((r, i) => {
|
|
971
967
|
if (i > 0) {
|
|
972
968
|
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
@@ -1104,6 +1100,15 @@ class WebsyDatePicker {
|
|
|
1104
1100
|
if (labelEl) {
|
|
1105
1101
|
labelEl.innerHTML = range.label
|
|
1106
1102
|
}
|
|
1103
|
+
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
1104
|
+
if (headerEl) {
|
|
1105
|
+
if (this.selectedRange === 0) {
|
|
1106
|
+
headerEl.classList.remove('range-selected')
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
headerEl.classList.add('range-selected')
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1107
1112
|
}
|
|
1108
1113
|
}
|
|
1109
1114
|
|
|
@@ -1117,7 +1122,8 @@ class WebsyDragDrop {
|
|
|
1117
1122
|
const DEFAULTS = {
|
|
1118
1123
|
items: [],
|
|
1119
1124
|
orientation: 'horizontal',
|
|
1120
|
-
dropPlaceholder: 'Drop item here'
|
|
1125
|
+
dropPlaceholder: 'Drop item here',
|
|
1126
|
+
accepts: 'application/wd-item'
|
|
1121
1127
|
}
|
|
1122
1128
|
this.busy = false
|
|
1123
1129
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
@@ -1176,7 +1182,7 @@ class WebsyDragDrop {
|
|
|
1176
1182
|
item.id = WebsyDesigns.Utils.createIdentity()
|
|
1177
1183
|
}
|
|
1178
1184
|
let html = `
|
|
1179
|
-
<div id='${item.id}_item' class='websy-dragdrop-item' draggable='true' data-id='${item.id}'>
|
|
1185
|
+
<div id='${item.id}_item' class='websy-dragdrop-item ${(item.classes || []).join(' ')}' draggable='true' data-id='${item.id}'>
|
|
1180
1186
|
<div id='${item.id}_itemInner' class='websy-dragdrop-item-inner' data-id='${item.id}'>
|
|
1181
1187
|
`
|
|
1182
1188
|
if (item.component) {
|
|
@@ -1205,20 +1211,23 @@ class WebsyDragDrop {
|
|
|
1205
1211
|
}
|
|
1206
1212
|
handleDragStart (event) {
|
|
1207
1213
|
this.draggedId = event.target.getAttribute('data-id')
|
|
1208
|
-
event.dataTransfer.effectAllowed = 'move'
|
|
1209
|
-
event.dataTransfer.setData(
|
|
1210
|
-
|
|
1211
|
-
event.target.style.opacity = 0.5
|
|
1214
|
+
event.dataTransfer.effectAllowed = 'move'
|
|
1215
|
+
event.dataTransfer.setData(this.options.accepts, JSON.stringify({el: event.target.id, id: this.elementId, itemId: this.draggedId}))
|
|
1216
|
+
event.target.classList.add('dragging')
|
|
1217
|
+
// event.target.style.opacity = 0.5
|
|
1212
1218
|
this.dragging = true
|
|
1213
1219
|
}
|
|
1214
|
-
handleDragOver (event) {
|
|
1215
|
-
// console.log('drag over', event.target.classList)
|
|
1220
|
+
handleDragOver (event) {
|
|
1216
1221
|
if (event.preventDefault) {
|
|
1217
1222
|
event.preventDefault()
|
|
1218
1223
|
}
|
|
1224
|
+
console.log('drag', event.target.classList)
|
|
1219
1225
|
if (!event.target.classList.contains('droppable')) {
|
|
1220
1226
|
return
|
|
1221
1227
|
}
|
|
1228
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1229
|
+
return
|
|
1230
|
+
}
|
|
1222
1231
|
event.target.classList.add('drag-over')
|
|
1223
1232
|
}
|
|
1224
1233
|
handleDragLeave (event) {
|
|
@@ -1234,14 +1243,17 @@ class WebsyDragDrop {
|
|
|
1234
1243
|
}
|
|
1235
1244
|
handleDrop (event) {
|
|
1236
1245
|
// console.log('drag drop')
|
|
1237
|
-
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1238
|
-
const data = JSON.parse(event.dataTransfer.getData(
|
|
1246
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1247
|
+
const data = JSON.parse(event.dataTransfer.getData(this.options.accepts))
|
|
1239
1248
|
if (event.preventDefault) {
|
|
1240
1249
|
event.preventDefault()
|
|
1241
1250
|
}
|
|
1242
1251
|
if (!event.target.classList.contains('droppable')) {
|
|
1243
1252
|
return
|
|
1244
1253
|
}
|
|
1254
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1255
|
+
return
|
|
1256
|
+
}
|
|
1245
1257
|
let side = event.target.getAttribute('data-side')
|
|
1246
1258
|
let id = event.target.getAttribute('data-id')
|
|
1247
1259
|
let index = this.getItemIndex(id)
|
|
@@ -1291,6 +1303,7 @@ class WebsyDragDrop {
|
|
|
1291
1303
|
handleDragEnd (event) {
|
|
1292
1304
|
// console.log('drag end')
|
|
1293
1305
|
event.target.style.opacity = 1
|
|
1306
|
+
event.target.classList.remove('dragging')
|
|
1294
1307
|
this.draggedId = null
|
|
1295
1308
|
this.dragging = false
|
|
1296
1309
|
const startEl = document.getElementById(`${this.elementId}start_item`)
|
|
@@ -5271,10 +5284,16 @@ class WebsyTable3 {
|
|
|
5271
5284
|
data.forEach(row => {
|
|
5272
5285
|
bodyHtml += `<tr class="websy-table-row">`
|
|
5273
5286
|
row.forEach((cell, cellIndex) => {
|
|
5287
|
+
if (typeof sizingColumns[cellIndex] === 'undefined') {
|
|
5288
|
+
return // need to revisit this logic
|
|
5289
|
+
}
|
|
5274
5290
|
let style = ''
|
|
5275
5291
|
if (cell.style) {
|
|
5276
5292
|
style += cell.style
|
|
5277
5293
|
}
|
|
5294
|
+
if (useWidths === true) {
|
|
5295
|
+
style += `max-width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important;`
|
|
5296
|
+
}
|
|
5278
5297
|
if (cell.backgroundColor) {
|
|
5279
5298
|
style += `background-color: ${cell.backgroundColor}; `
|
|
5280
5299
|
if (!cell.color) {
|
|
@@ -5284,8 +5303,9 @@ class WebsyTable3 {
|
|
|
5284
5303
|
if (cell.color) {
|
|
5285
5304
|
style += `color: ${cell.color}; `
|
|
5286
5305
|
}
|
|
5306
|
+
console.log('rowspan', cell.rowspan)
|
|
5287
5307
|
bodyHtml += `<td
|
|
5288
|
-
class='websy-table-cell'
|
|
5308
|
+
class='websy-table-cell ${(cell.classes || []).join(' ')}'
|
|
5289
5309
|
style='${style}'
|
|
5290
5310
|
data-info='${cell.value}'
|
|
5291
5311
|
colspan='${cell.colspan || 1}'
|
|
@@ -5444,11 +5464,13 @@ class WebsyTable3 {
|
|
|
5444
5464
|
}
|
|
5445
5465
|
})
|
|
5446
5466
|
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
5467
|
+
this.sizes.totalNonPinnedWidth = this.options.columns[this.options.columns.length - 1].filter((c, i) => i >= this.pinnedColumns).reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
5447
5468
|
const outerSize = outerEl.getBoundingClientRect()
|
|
5448
5469
|
if (this.sizes.totalWidth < outerSize.width) {
|
|
5449
5470
|
this.sizes.totalWidth = 0
|
|
5471
|
+
this.sizes.totalNonPinnedWidth = 0
|
|
5450
5472
|
let equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length
|
|
5451
|
-
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5473
|
+
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5452
5474
|
if (!c.width) {
|
|
5453
5475
|
if (c.actualWidth < equalWidth) {
|
|
5454
5476
|
// adjust the width
|
|
@@ -5456,6 +5478,9 @@ class WebsyTable3 {
|
|
|
5456
5478
|
}
|
|
5457
5479
|
}
|
|
5458
5480
|
this.sizes.totalWidth += c.width || c.actualWidth
|
|
5481
|
+
if (i < this.pinnedColumns) {
|
|
5482
|
+
this.sizes.totalNonPinnedWidth += c.width || c.actualWidth
|
|
5483
|
+
}
|
|
5459
5484
|
equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
|
|
5460
5485
|
})
|
|
5461
5486
|
}
|
|
@@ -5476,9 +5501,15 @@ class WebsyTable3 {
|
|
|
5476
5501
|
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
5477
5502
|
this.vScrollRequired = true
|
|
5478
5503
|
}
|
|
5504
|
+
else {
|
|
5505
|
+
this.vScrollRequired = false
|
|
5506
|
+
}
|
|
5479
5507
|
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
5480
5508
|
this.hScrollRequired = true
|
|
5481
5509
|
}
|
|
5510
|
+
else {
|
|
5511
|
+
this.hScrollRequired = false
|
|
5512
|
+
}
|
|
5482
5513
|
this.options.allColumns = this.options.columns.map(c => c)
|
|
5483
5514
|
console.log('sizes', this.sizes)
|
|
5484
5515
|
return this.sizes
|
|
@@ -5623,10 +5654,10 @@ class WebsyTable3 {
|
|
|
5623
5654
|
if (this.hScrollRequired === true) {
|
|
5624
5655
|
hScrollEl.style.left = `${this.sizes.table.width - this.sizes.scrollableWidth}px`
|
|
5625
5656
|
hScrollEl.style.width = `${this.sizes.scrollableWidth - 20}px`
|
|
5626
|
-
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.
|
|
5657
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px'
|
|
5627
5658
|
}
|
|
5628
5659
|
else {
|
|
5629
|
-
hHandleEl.style.
|
|
5660
|
+
hHandleEl.style.width = '0px'
|
|
5630
5661
|
}
|
|
5631
5662
|
}
|
|
5632
5663
|
}
|
|
@@ -5656,9 +5687,7 @@ class WebsyTable3 {
|
|
|
5656
5687
|
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
5657
5688
|
if (el) {
|
|
5658
5689
|
el.classList.add('has-error')
|
|
5659
|
-
}
|
|
5660
|
-
const tableEl = document.getElementById(`${this.elementId}_tableInner`)
|
|
5661
|
-
tableEl.classList.add('hidden')
|
|
5690
|
+
}
|
|
5662
5691
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
5663
5692
|
if (containerEl) {
|
|
5664
5693
|
containerEl.classList.add('active')
|
|
@@ -5677,6 +5706,19 @@ class WebsyTable3 {
|
|
|
5677
5706
|
}
|
|
5678
5707
|
}
|
|
5679
5708
|
scrollX (diff) {
|
|
5709
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
5710
|
+
if (!el.classList.contains('scrolling')) {
|
|
5711
|
+
el.classList.add('scrolling')
|
|
5712
|
+
}
|
|
5713
|
+
if (this.scrollTimeoutFn) {
|
|
5714
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
5715
|
+
}
|
|
5716
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
5717
|
+
el.classList.remove('scrolling')
|
|
5718
|
+
}, 200)
|
|
5719
|
+
if (this.hScrollRequired === false) {
|
|
5720
|
+
return
|
|
5721
|
+
}
|
|
5680
5722
|
const scrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
|
|
5681
5723
|
const scrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
5682
5724
|
let handlePos
|
|
@@ -5690,11 +5732,11 @@ class WebsyTable3 {
|
|
|
5690
5732
|
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width)
|
|
5691
5733
|
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px'
|
|
5692
5734
|
if (this.options.onScroll) {
|
|
5693
|
-
let actualLeft = (this.sizes.
|
|
5735
|
+
let actualLeft = (this.sizes.totalNonPinnedWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace)
|
|
5694
5736
|
let cumulativeWidth = 0
|
|
5695
5737
|
this.startCol = 0
|
|
5696
5738
|
this.endCol = 0
|
|
5697
|
-
for (let i =
|
|
5739
|
+
for (let i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
5698
5740
|
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
5699
5741
|
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
5700
5742
|
if (actualLeft < cumulativeWidth) {
|
|
@@ -5720,6 +5762,19 @@ class WebsyTable3 {
|
|
|
5720
5762
|
}
|
|
5721
5763
|
}
|
|
5722
5764
|
scrollY (diff) {
|
|
5765
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
5766
|
+
if (!el.classList.contains('scrolling')) {
|
|
5767
|
+
el.classList.add('scrolling')
|
|
5768
|
+
}
|
|
5769
|
+
if (this.scrollTimeoutFn) {
|
|
5770
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
5771
|
+
}
|
|
5772
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
5773
|
+
el.classList.remove('scrolling')
|
|
5774
|
+
}, 200)
|
|
5775
|
+
if (this.vScrollRequired === false) {
|
|
5776
|
+
return
|
|
5777
|
+
}
|
|
5723
5778
|
const scrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
|
|
5724
5779
|
const scrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
5725
5780
|
let handlePos
|
|
@@ -6671,7 +6726,7 @@ bars
|
|
|
6671
6726
|
.attr('x', getBarX.bind(this))
|
|
6672
6727
|
.attr('y', getBarY.bind(this))
|
|
6673
6728
|
.transition(this.transition)
|
|
6674
|
-
.attr('fill', d => d.color || series.color)
|
|
6729
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
6675
6730
|
|
|
6676
6731
|
bars
|
|
6677
6732
|
.enter()
|
|
@@ -6681,7 +6736,7 @@ bars
|
|
|
6681
6736
|
.attr('x', getBarX.bind(this))
|
|
6682
6737
|
.attr('y', getBarY.bind(this))
|
|
6683
6738
|
// .transition(this.transition)
|
|
6684
|
-
.attr('fill', d => d.color || series.color)
|
|
6739
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
6685
6740
|
.attr('class', d => {
|
|
6686
6741
|
return `bar bar_${series.key}`
|
|
6687
6742
|
})
|
|
@@ -6696,7 +6751,7 @@ if (this.options.orientation === 'horizontal') {
|
|
|
6696
6751
|
xAxis = 'leftAxis'
|
|
6697
6752
|
yAxis = 'bottomAxis'
|
|
6698
6753
|
}
|
|
6699
|
-
if (this.options.showLabels) {
|
|
6754
|
+
if (this.options.showLabels === true || series.showLabels === true) {
|
|
6700
6755
|
// need to add logic to handle positioning options
|
|
6701
6756
|
// e.g. Inside, Outide, Auto (this will also affect the available plot space)
|
|
6702
6757
|
// We currently only support 'Auto'
|
|
@@ -6710,10 +6765,30 @@ if (this.options.showLabels) {
|
|
|
6710
6765
|
.attr('x', getLabelX.bind(this))
|
|
6711
6766
|
.attr('y', getLabelY.bind(this))
|
|
6712
6767
|
.attr('class', `label_${series.key}`)
|
|
6713
|
-
.
|
|
6714
|
-
.style('
|
|
6768
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6769
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
6715
6770
|
.transition(this.transition)
|
|
6716
6771
|
.text(d => d.y.label || d.y.value)
|
|
6772
|
+
.each(function (d, i) {
|
|
6773
|
+
if (that.options.orientation === 'horizontal') {
|
|
6774
|
+
if (that.options.grouping === 'stacked') {
|
|
6775
|
+
this.setAttribute('text-anchor', 'middle')
|
|
6776
|
+
}
|
|
6777
|
+
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
6778
|
+
this.setAttribute('text-anchor', 'end')
|
|
6779
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6780
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6781
|
+
}
|
|
6782
|
+
else {
|
|
6783
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
else {
|
|
6787
|
+
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
6788
|
+
this.setAttribute('y', +(this.getAttribute('y')) + 8)
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6791
|
+
})
|
|
6717
6792
|
|
|
6718
6793
|
labels
|
|
6719
6794
|
.enter()
|
|
@@ -6723,8 +6798,8 @@ if (this.options.showLabels) {
|
|
|
6723
6798
|
.attr('y', getLabelY.bind(this))
|
|
6724
6799
|
.attr('alignment-baseline', 'central')
|
|
6725
6800
|
.attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
|
|
6726
|
-
.
|
|
6727
|
-
.style('
|
|
6801
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6802
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
6728
6803
|
.text(d => d.y.label || d.y.value)
|
|
6729
6804
|
.each(function (d, i) {
|
|
6730
6805
|
if (that.options.orientation === 'horizontal') {
|
|
@@ -6733,8 +6808,12 @@ if (this.options.showLabels) {
|
|
|
6733
6808
|
}
|
|
6734
6809
|
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
6735
6810
|
this.setAttribute('text-anchor', 'end')
|
|
6736
|
-
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6811
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
6812
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
6737
6813
|
}
|
|
6814
|
+
else {
|
|
6815
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
6816
|
+
}
|
|
6738
6817
|
}
|
|
6739
6818
|
else {
|
|
6740
6819
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|