@stoker-platform/web-app 0.5.229 → 0.5.231
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/DashboardChart.tsx +24 -14
- package/src/Form.tsx +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @stoker-platform/web-app
|
|
2
2
|
|
|
3
|
+
## 0.5.231
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: pad empty months in Dashboard charts
|
|
8
|
+
|
|
9
|
+
## 0.5.230
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix: refresh form state from server after successful save
|
|
14
|
+
|
|
3
15
|
## 0.5.229
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/package.json
CHANGED
package/src/DashboardChart.tsx
CHANGED
|
@@ -215,20 +215,30 @@ export const DashboardChart = ({ chart, title, collection }: DashboardChartProps
|
|
|
215
215
|
})
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
218
|
+
const startDate = DateTime.now()
|
|
219
|
+
.setZone(timezone)
|
|
220
|
+
.startOf(interval)
|
|
221
|
+
.plus({ [`${interval}s`]: offset })
|
|
222
|
+
const endDate = DateTime.now()
|
|
223
|
+
.setZone(timezone)
|
|
224
|
+
.endOf(interval)
|
|
225
|
+
.plus({ [`${interval}s`]: (numberOfIntervals || 0) + offset })
|
|
226
|
+
|
|
227
|
+
const byDate = new Map(chartData.map((item) => [item.date, item]))
|
|
228
|
+
const padMetric2 = !!(chart.metricField2 || chart.formula2)
|
|
229
|
+
const paddedChartData: ChartData = []
|
|
230
|
+
for (let cursor = startDate; cursor < endDate; cursor = cursor.plus({ [`${interval}s`]: 1 })) {
|
|
231
|
+
const key = cursor.toFormat("yyyy-MM-dd")
|
|
232
|
+
const existing = byDate.get(key)
|
|
233
|
+
if (existing) {
|
|
234
|
+
paddedChartData.push(existing)
|
|
235
|
+
} else if (padMetric2) {
|
|
236
|
+
paddedChartData.push({ date: key, metric1: 0, metric2: 0 })
|
|
237
|
+
} else {
|
|
238
|
+
paddedChartData.push({ date: key, metric1: 0 })
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return paddedChartData
|
|
232
242
|
}, [results])
|
|
233
243
|
|
|
234
244
|
const metricField1 = chart.metricField1 ? getField(fields, chart.metricField1) : undefined
|
package/src/Form.tsx
CHANGED
|
@@ -2474,6 +2474,10 @@ function RecordForm({
|
|
|
2474
2474
|
|
|
2475
2475
|
const formValues = form.watch()
|
|
2476
2476
|
const [prevState, setPrevState] = useState<Partial<StokerRecord>>({} as Partial<StokerRecord>)
|
|
2477
|
+
const prevStateRef = useRef<Partial<StokerRecord>>(prevState)
|
|
2478
|
+
useEffect(() => {
|
|
2479
|
+
prevStateRef.current = prevState
|
|
2480
|
+
}, [prevState])
|
|
2477
2481
|
const [originalRecord, setOriginalRecord] = useState<StokerRecord | undefined>(undefined)
|
|
2478
2482
|
const [formResetKey, setFormResetKey] = useState(0)
|
|
2479
2483
|
const [formSavedKey, setFormSavedKey] = useState(0)
|
|
@@ -3235,6 +3239,19 @@ function RecordForm({
|
|
|
3235
3239
|
key.startsWith("accessible-"),
|
|
3236
3240
|
),
|
|
3237
3241
|
)
|
|
3242
|
+
if (!initial) {
|
|
3243
|
+
const currentValues = form.getValues()
|
|
3244
|
+
for (const [key, value] of Object.entries(filteredRecord)) {
|
|
3245
|
+
if (
|
|
3246
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
3247
|
+
isEqual(currentValues[key], prevStateRef.current?.[key]) &&
|
|
3248
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
3249
|
+
!isEqual(currentValues[key], value)
|
|
3250
|
+
) {
|
|
3251
|
+
form.setValue(key, value)
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3238
3255
|
setPrevState({ ...prevState, ...permissionValues })
|
|
3239
3256
|
}
|
|
3240
3257
|
},
|