UNPKG

devexpress-reporting

Version:

DevExpress Reporting provides the capability to develop a reporting application to create and customize reports.

63 lines (62 loc) 2.67 kB
/** * DevExpress HTML/JS Reporting (chart\widgets\_viewEditor.js) * Version: 25.1.3 * Build date: Jun 26, 2025 * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * License: https://www.devexpress.com/Support/EULAs/universal.xml */ import { Editor } from '@devexpress/analytics-core/analytics-widgets'; import { SvgTemplatesEngine } from '@devexpress/analytics-core/analytics-widgets-internal'; import * as ko from 'knockout'; import { getSeriesClassName } from '../_utils'; import { getLocalization } from '@devexpress/analytics-core/analytics-internal-native'; import { createViewModelGenerator } from '@devexpress/analytics-core/analytics-serializer-native'; export class ViewEditor extends Editor { createViewModel() { return createViewModelGenerator(super.createViewModel()) .generateProperty('generateViewItems', () => this.generateViewItems()) .generateProperty('generateHeaderValue', (undoEngine) => this.generateHeaderValue(undoEngine)) .generateProperty('contentValue', this.contentValue) .getViewModel(); } constructor(info, level, parentDisabled, textToSearch) { super(info, level, parentDisabled, textToSearch); this.viewItems = []; this.contentValue = ko.computed(() => { return this.value() && this.value().model() || {}; }); this._disposables.push(this.contentValue); } generateHeaderValue(undoEngine) { if (!this.headerValue) { this._disposables.push(this.headerValue = ko.computed({ read: () => { return this.value() && this.value().type(); }, write: (newVal) => { undoEngine().start(); this.value().type(newVal); undoEngine().end(); } })); } return this.headerValue; } generateViewItems() { if (!this.viewItems.length) { this.viewItems = this._get('values').map((x) => { return { ...x, displayValue: getLocalization(x.displayValue, x.localizationId), className: this.generateViewClassName(x.value), templateName: this.generateViewClassName(x.value, true) }; }); } return this.viewItems; } generateViewClassName(value, isTemplate = false) { const _name = (isTemplate ? 'dxrd-svg-fieldlist-' : 'dx-image-fieldlist-') + getSeriesClassName(value); if (isTemplate) return SvgTemplatesEngine.getExistingTemplate(_name); return _name; } }