forked from enviPath/enviPy
[Feature] Adds timeseries display (#313)
Adds a way to input/display timeseries data to the additional information Reviewed-on: enviPath/enviPy#313 Reviewed-by: jebus <lorsbach@envipath.com> Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-committed-by: Tobias O <tobias.olenyi@envipath.com>
This commit is contained in:
@ -18,7 +18,9 @@
|
||||
const names = Object.keys(this.schemas);
|
||||
// Remove duplicates, exclude existing types, and sort alphabetically by display title
|
||||
const unique = [...new Set(names)];
|
||||
const available = unique.filter(name => !this.existingTypes.includes(name));
|
||||
const available = unique.filter(name =>
|
||||
!this.existingTypes.includes(name) || this.schemas[name]?.schema?.['x-repeatable']
|
||||
);
|
||||
return available.sort((a, b) => {
|
||||
const titleA = (this.schemas[a]?.schema?.['x-title'] || a).toLowerCase();
|
||||
const titleB = (this.schemas[b]?.schema?.['x-title'] || b).toLowerCase();
|
||||
@ -32,6 +34,9 @@
|
||||
// Reset formData when type changes and increment key to force re-render
|
||||
this.formData = null;
|
||||
this.formRenderKey++;
|
||||
// Clear previous errors
|
||||
this.error = null;
|
||||
Alpine.store('validationErrors').clearErrors(); // No context - clears all
|
||||
});
|
||||
|
||||
// Load schemas and existing items
|
||||
@ -63,6 +68,7 @@
|
||||
this.selectedType = '';
|
||||
this.error = null;
|
||||
this.formData = null;
|
||||
Alpine.store('validationErrors').clearErrors(); // No context - clears all
|
||||
},
|
||||
|
||||
setFormData(data) {
|
||||
@ -96,11 +102,12 @@
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
if (err.isValidationError && err.fieldErrors) {
|
||||
window.dispatchEvent(new CustomEvent('set-field-errors', {
|
||||
detail: err.fieldErrors
|
||||
}));
|
||||
// No context for add modal - simple flat errors
|
||||
Alpine.store('validationErrors').setErrors(err.fieldErrors);
|
||||
this.error = err.message || 'Please correct the errors in the form';
|
||||
} else {
|
||||
this.error = err.message || 'An error occurred. Please try again.';
|
||||
}
|
||||
this.error = err.message;
|
||||
} finally {
|
||||
this.isSubmitting = false;
|
||||
}
|
||||
@ -155,7 +162,7 @@
|
||||
<template x-for="name in sortedSchemaNames" :key="name">
|
||||
<option
|
||||
:value="name"
|
||||
x-text="(schemas[name].schema && schemas[name].schema['x-title']) || name"
|
||||
x-text="(schemas[name].schema && (schemas[name].schema['x-title'] || schemas[name].schema.title)) || name"
|
||||
></option>
|
||||
</template>
|
||||
</select>
|
||||
@ -169,6 +176,7 @@
|
||||
x-data="schemaRenderer({
|
||||
rjsf: schemas[selectedType],
|
||||
mode: 'edit'
|
||||
// No context - single form, backward compatible
|
||||
})"
|
||||
x-init="await init(); $dispatch('form-data-ready', data)"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user