Skip to content

Commit b7a63ed

Browse files
r-farkhutdinovRuslan Farkhutdinovmpreyskurantov
authored
Chat: Add FileUploading types (#31352)
Co-authored-by: Ruslan Farkhutdinov <[email protected]> Co-authored-by: Mikhail Preyskurantov <[email protected]>
1 parent 960b878 commit b7a63ed

File tree

12 files changed

+1164
-9
lines changed

12 files changed

+1164
-9
lines changed

packages/devextreme-angular/src/core/tokens/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const PROPERTY_TOKEN_series = new InjectionToken<string>('property-token-
1717
export const PROPERTY_TOKEN_strips = new InjectionToken<string>('property-token-strips');
1818
export const PROPERTY_TOKEN_valueAxis = new InjectionToken<string>('property-token-valueAxis');
1919
export const PROPERTY_TOKEN_alerts = new InjectionToken<string>('property-token-alerts');
20+
export const PROPERTY_TOKEN_attachments = new InjectionToken<string>('property-token-attachments');
2021
export const PROPERTY_TOKEN_typingUsers = new InjectionToken<string>('property-token-typingUsers');
2122
export const PROPERTY_TOKEN_ranges = new InjectionToken<string>('property-token-ranges');
2223
export const PROPERTY_TOKEN_groupItems = new InjectionToken<string>('property-token-groupItems');

packages/devextreme-angular/src/ui/chat/index.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ import {
2424

2525
import DataSource from 'devextreme/data/data_source';
2626
import dxChat from 'devextreme/ui/chat';
27-
import { Alert, Message, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, OptionChangedEvent, TypingEndEvent, TypingStartEvent, User } from 'devextreme/ui/chat';
27+
import { Alert, Message, AttachmentDownloadEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, OptionChangedEvent, TypingEndEvent, TypingStartEvent, User } from 'devextreme/ui/chat';
2828
import { DataSourceOptions } from 'devextreme/data/data_source';
2929
import { Store } from 'devextreme/data/store';
3030
import { Format } from 'devextreme/common/core/localization';
31+
import { dxFileUploaderOptions } from 'devextreme/ui/file_uploader';
3132

3233
import DxChat from 'devextreme/ui/chat';
3334

@@ -53,15 +54,18 @@ import { DxiTypingUserModule } from 'devextreme-angular/ui/nested';
5354
import { DxoUserModule } from 'devextreme-angular/ui/nested';
5455

5556
import { DxiChatAlertModule } from 'devextreme-angular/ui/chat/nested';
57+
import { DxiChatAttachmentModule } from 'devextreme-angular/ui/chat/nested';
5658
import { DxoChatAuthorModule } from 'devextreme-angular/ui/chat/nested';
5759
import { DxoChatDayHeaderFormatModule } from 'devextreme-angular/ui/chat/nested';
5860
import { DxoChatEditingModule } from 'devextreme-angular/ui/chat/nested';
61+
import { DxoChatFileUploaderOptionsModule } from 'devextreme-angular/ui/chat/nested';
5962
import { DxiChatItemModule } from 'devextreme-angular/ui/chat/nested';
6063
import { DxoChatMessageTimestampFormatModule } from 'devextreme-angular/ui/chat/nested';
6164
import { DxiChatTypingUserModule } from 'devextreme-angular/ui/chat/nested';
6265
import { DxoChatUserModule } from 'devextreme-angular/ui/chat/nested';
6366
import {
6467
PROPERTY_TOKEN_alerts,
68+
PROPERTY_TOKEN_attachments,
6569
PROPERTY_TOKEN_items,
6670
PROPERTY_TOKEN_typingUsers,
6771
} from 'devextreme-angular/core/tokens';
@@ -91,6 +95,11 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
9195
this.setChildren('alerts', value);
9296
}
9397

98+
@ContentChildren(PROPERTY_TOKEN_attachments)
99+
set _attachmentsContentChildren(value: QueryList<CollectionNestedOption>) {
100+
this.setChildren('attachments', value);
101+
}
102+
94103
@ContentChildren(PROPERTY_TOKEN_items)
95104
set _itemsContentChildren(value: QueryList<CollectionNestedOption>) {
96105
this.setChildren('items', value);
@@ -220,6 +229,16 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
220229
}
221230

222231

232+
233+
@Input()
234+
get fileUploaderOptions(): dxFileUploaderOptions {
235+
return this._getOption('fileUploaderOptions');
236+
}
237+
set fileUploaderOptions(value: dxFileUploaderOptions) {
238+
this._setOption('fileUploaderOptions', value);
239+
}
240+
241+
223242
/**
224243
* [descr:dxChatOptions.focusStateEnabled]
225244
@@ -440,6 +459,14 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
440459
this._setOption('width', value);
441460
}
442461

462+
/**
463+
464+
* [descr:undefined]
465+
466+
467+
*/
468+
@Output() onAttachmentDownload: EventEmitter<AttachmentDownloadEvent>;
469+
443470
/**
444471
445472
* [descr:dxChatOptions.onDisposing]
@@ -599,6 +626,13 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
599626
*/
600627
@Output() emptyViewTemplateChange: EventEmitter<any>;
601628

629+
/**
630+
631+
* This member supports the internal infrastructure and is not intended to be used directly from your code.
632+
633+
*/
634+
@Output() fileUploaderOptionsChange: EventEmitter<dxFileUploaderOptions>;
635+
602636
/**
603637
604638
* This member supports the internal infrastructure and is not intended to be used directly from your code.
@@ -731,6 +765,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
731765
super(elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId);
732766

733767
this._createEventEmitters([
768+
{ subscribe: 'attachmentDownload', emit: 'onAttachmentDownload' },
734769
{ subscribe: 'disposing', emit: 'onDisposing' },
735770
{ subscribe: 'initialized', emit: 'onInitialized' },
736771
{ subscribe: 'messageDeleted', emit: 'onMessageDeleted' },
@@ -752,6 +787,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
752787
{ emit: 'editingChange' },
753788
{ emit: 'elementAttrChange' },
754789
{ emit: 'emptyViewTemplateChange' },
790+
{ emit: 'fileUploaderOptionsChange' },
755791
{ emit: 'focusStateEnabledChange' },
756792
{ emit: 'heightChange' },
757793
{ emit: 'hintChange' },
@@ -831,9 +867,11 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
831867
DxiTypingUserModule,
832868
DxoUserModule,
833869
DxiChatAlertModule,
870+
DxiChatAttachmentModule,
834871
DxoChatAuthorModule,
835872
DxoChatDayHeaderFormatModule,
836873
DxoChatEditingModule,
874+
DxoChatFileUploaderOptionsModule,
837875
DxiChatItemModule,
838876
DxoChatMessageTimestampFormatModule,
839877
DxiChatTypingUserModule,
@@ -852,9 +890,11 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
852890
DxiTypingUserModule,
853891
DxoUserModule,
854892
DxiChatAlertModule,
893+
DxiChatAttachmentModule,
855894
DxoChatAuthorModule,
856895
DxoChatDayHeaderFormatModule,
857896
DxoChatEditingModule,
897+
DxoChatFileUploaderOptionsModule,
858898
DxiChatItemModule,
859899
DxoChatMessageTimestampFormatModule,
860900
DxiChatTypingUserModule,
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* tslint:disable:max-line-length */
2+
3+
4+
import {
5+
Component,
6+
NgModule,
7+
Host,
8+
SkipSelf,
9+
Input
10+
} from '@angular/core';
11+
12+
13+
14+
15+
16+
import {
17+
DxIntegrationModule,
18+
NestedOptionHost,
19+
} from 'devextreme-angular/core';
20+
import { CollectionNestedOption } from 'devextreme-angular/core';
21+
22+
import { PROPERTY_TOKEN_attachments } from 'devextreme-angular/core/tokens';
23+
24+
@Component({
25+
selector: 'dxi-chat-attachment',
26+
standalone: true,
27+
template: '',
28+
styles: [''],
29+
imports: [ DxIntegrationModule ],
30+
providers: [
31+
NestedOptionHost,
32+
{
33+
provide: PROPERTY_TOKEN_attachments,
34+
useExisting: DxiChatAttachmentComponent,
35+
}
36+
]
37+
})
38+
export class DxiChatAttachmentComponent extends CollectionNestedOption {
39+
@Input()
40+
get name(): string {
41+
return this._getOption('name');
42+
}
43+
set name(value: string) {
44+
this._setOption('name', value);
45+
}
46+
47+
@Input()
48+
get size(): number {
49+
return this._getOption('size');
50+
}
51+
set size(value: number) {
52+
this._setOption('size', value);
53+
}
54+
55+
56+
protected get _optionPath() {
57+
return 'attachments';
58+
}
59+
60+
61+
constructor(@SkipSelf() @Host() parentOptionHost: NestedOptionHost,
62+
@Host() optionHost: NestedOptionHost) {
63+
super();
64+
parentOptionHost.setNestedOption(this);
65+
optionHost.setHost(this, this._fullOptionPath.bind(this));
66+
}
67+
68+
69+
70+
ngOnDestroy() {
71+
this._deleteRemovedOptions(this._fullOptionPath());
72+
}
73+
74+
}
75+
76+
@NgModule({
77+
imports: [
78+
DxiChatAttachmentComponent
79+
],
80+
exports: [
81+
DxiChatAttachmentComponent
82+
],
83+
})
84+
export class DxiChatAttachmentModule { }

0 commit comments

Comments
 (0)