From cbf2021396614723673024b920abc67dc623a0b2 Mon Sep 17 00:00:00 2001 From: EugeniyKiyashko Date: Thu, 29 Aug 2024 15:49:11 +0400 Subject: [PATCH] Chan: publish dataSource option --- .../devextreme-angular/src/ui/chat/index.ts | 25 +++++++++++++++++++ packages/devextreme-vue/src/chat.ts | 3 +++ .../devextreme/js/__internal/ui/chat/chat.ts | 1 + packages/devextreme/js/ui/chat.d.ts | 13 +++++++++- packages/devextreme/ts/dx.all.d.ts | 6 +++++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/packages/devextreme-angular/src/ui/chat/index.ts b/packages/devextreme-angular/src/ui/chat/index.ts index 76c5db468900..c6545c97766c 100644 --- a/packages/devextreme-angular/src/ui/chat/index.ts +++ b/packages/devextreme-angular/src/ui/chat/index.ts @@ -22,6 +22,8 @@ import { } from '@angular/core'; +import { Store } from 'devextreme/data'; +import DataSource, { Options as DataSourceOptions } from 'devextreme/data/data_source'; import { DisposingEvent, InitializedEvent, Message, MessageSendEvent, OptionChangedEvent, User } from 'devextreme/ui/chat'; import DxChat from 'devextreme/ui/chat'; @@ -88,6 +90,19 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges } + /** + * [descr:dxChatOptions.dataSource] + + */ + @Input() + get dataSource(): Store | DataSource | DataSourceOptions | null | string | Array { + return this._getOption('dataSource'); + } + set dataSource(value: Store | DataSource | DataSourceOptions | null | string | Array) { + this._setOption('dataSource', value); + } + + /** * [descr:WidgetOptions.disabled] @@ -289,6 +304,13 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges */ @Output() activeStateEnabledChange: EventEmitter; + /** + + * This member supports the internal infrastructure and is not intended to be used directly from your code. + + */ + @Output() dataSourceChange: EventEmitter>; + /** * This member supports the internal infrastructure and is not intended to be used directly from your code. @@ -403,6 +425,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges { subscribe: 'optionChanged', emit: 'onOptionChanged' }, { emit: 'accessKeyChange' }, { emit: 'activeStateEnabledChange' }, + { emit: 'dataSourceChange' }, { emit: 'disabledChange' }, { emit: 'elementAttrChange' }, { emit: 'focusStateEnabledChange' }, @@ -433,6 +456,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); + this.setupChanges('dataSource', changes); this.setupChanges('items', changes); } @@ -443,6 +467,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges } ngDoCheck() { + this._idh.doCheck('dataSource'); this._idh.doCheck('items'); this._watcherHelper.checkWatchers(); super.ngDoCheck(); diff --git a/packages/devextreme-vue/src/chat.ts b/packages/devextreme-vue/src/chat.ts index 54a67dc1680e..2ffc0116a838 100644 --- a/packages/devextreme-vue/src/chat.ts +++ b/packages/devextreme-vue/src/chat.ts @@ -5,6 +5,7 @@ import { createConfigurationComponent } from "./core/index"; type AccessibleOptions = Pick { ...super._getDefaultOptions(), title: '', items: [], + dataSource: null, user: { id: new Guid().toString() }, onMessageSend: undefined, }; diff --git a/packages/devextreme/js/ui/chat.d.ts b/packages/devextreme/js/ui/chat.d.ts index 5ec786dbd800..bb480880c07d 100644 --- a/packages/devextreme/js/ui/chat.d.ts +++ b/packages/devextreme/js/ui/chat.d.ts @@ -5,6 +5,7 @@ import { InitializedEventInfo, ChangedOptionInfo, } from '../events/index'; +import DataSource, { DataSourceLike } from '../data/data_source'; /** * @docid _ui_chat_DisposingEvent @@ -108,6 +109,13 @@ export type Message = { * @docid */ export interface dxChatOptions extends WidgetOptions { + /** + * @docid + * @type string | Array | Store | DataSource | DataSourceOptions | null + * @default null + * @public + */ + dataSource?: DataSourceLike | null; /** * @docid * @default { id: new Guid().toString() } @@ -122,6 +130,7 @@ export interface dxChatOptions extends WidgetOptions { title?: string; /** * @docid + * @type Array * @fires dxChatOptions.onOptionChanged * @public */ @@ -138,7 +147,7 @@ export interface dxChatOptions extends WidgetOptions { /** * @docid - * @inherits Widget + * @inherits Widget, DataHelperMixin * @namespace DevExpress.ui * @public */ @@ -149,6 +158,8 @@ export default class dxChat extends Widget { * @public */ renderMessage(message: Message): void; + + getDataSource(): DataSource; } /** @public */ diff --git a/packages/devextreme/ts/dx.all.d.ts b/packages/devextreme/ts/dx.all.d.ts index 80039db74b04..64ac3a9ff570 100644 --- a/packages/devextreme/ts/dx.all.d.ts +++ b/packages/devextreme/ts/dx.all.d.ts @@ -9420,6 +9420,8 @@ declare module DevExpress.ui { * [descr:dxChat.renderMessage(message)] */ renderMessage(message: DevExpress.ui.dxChat.Message): void; + + getDataSource(): DevExpress.data.DataSource; } module dxChat { /** @@ -9461,6 +9463,10 @@ declare module DevExpress.ui { * @deprecated [depNote:dxChatOptions] */ export interface dxChatOptions extends WidgetOptions { + /** + * [descr:dxChatOptions.dataSource] + */ + dataSource?: DevExpress.data.DataSource.DataSourceLike | null; /** * [descr:dxChatOptions.user] */