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