chart type
This commit is contained in:
@@ -505,23 +505,12 @@ export class ChartConfigManagerComponent implements OnInit {
|
|||||||
|
|
||||||
this.chartTemplateLoadingState = ClrLoadingState.LOADING;
|
this.chartTemplateLoadingState = ClrLoadingState.LOADING;
|
||||||
|
|
||||||
// Create a complete chartType object with only the ID
|
// Remove the chartType from the template data since we're passing it as a parameter
|
||||||
const chartTypeWithId = {
|
const chartTemplateData = { ...this.newChartTemplate };
|
||||||
id: this.selectedChartType.id,
|
// Remove chartType property if it exists
|
||||||
name: '',
|
delete (chartTemplateData as any).chartType;
|
||||||
displayName: '',
|
|
||||||
description: '',
|
|
||||||
isActive: true,
|
|
||||||
createdAt: '',
|
|
||||||
updatedAt: ''
|
|
||||||
};
|
|
||||||
|
|
||||||
const chartTemplateData = {
|
this.chartTemplateService.createChartTemplate(chartTemplateData, this.selectedChartType.id).subscribe({
|
||||||
...this.newChartTemplate,
|
|
||||||
chartType: chartTypeWithId
|
|
||||||
};
|
|
||||||
|
|
||||||
this.chartTemplateService.createChartTemplate(chartTemplateData).subscribe({
|
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.chartTemplates.push(data);
|
this.chartTemplates.push(data);
|
||||||
this.newChartTemplate = {};
|
this.newChartTemplate = {};
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import { ChartTemplate } from './chart-config-manager.component';
|
|||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
}
|
})
|
||||||
)
|
|
||||||
export class ChartTemplateService {
|
export class ChartTemplateService {
|
||||||
private chartTemplatesUrl = 'api/chart-templates';
|
private chartTemplatesUrl = 'api/chart-templates';
|
||||||
|
|
||||||
@@ -24,9 +23,13 @@ export class ChartTemplateService {
|
|||||||
return this.apiRequest.get(url);
|
return this.apiRequest.get(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new chart template
|
// Create new chart template with optional chart type ID as parameter
|
||||||
createChartTemplate(chartTemplate: Partial<ChartTemplate>): Observable<ChartTemplate> {
|
createChartTemplate(chartTemplate: Partial<ChartTemplate>, chartTypeId?: number): Observable<ChartTemplate> {
|
||||||
return this.apiRequest.post(this.chartTemplatesUrl, chartTemplate);
|
let url = this.chartTemplatesUrl;
|
||||||
|
if (chartTypeId) {
|
||||||
|
url = `${this.chartTemplatesUrl}?chartTypeId=${chartTypeId}`;
|
||||||
|
}
|
||||||
|
return this.apiRequest.post(url, chartTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update chart template
|
// Update chart template
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export class ChartTypeTemplatesComponent implements OnInit {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.loadingState = ClrLoadingState.LOADING;
|
this.loadingState = ClrLoadingState.LOADING;
|
||||||
this.chartTemplateService.createChartTemplate(templateData).subscribe({
|
this.chartTemplateService.createChartTemplate(templateData, this.chartType.id).subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.chartTemplates.push(data);
|
this.chartTemplates.push(data);
|
||||||
this.newChartTemplate = { isDefault: false };
|
this.newChartTemplate = { isDefault: false };
|
||||||
|
|||||||
Reference in New Issue
Block a user