Skip to content

Commit

Permalink
Merge branch '24_2' into 24_2_dataSource_d_ts
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeniyKiyashko committed Aug 30, 2024
2 parents 388a715 + cbba54f commit da6a7a9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 46 deletions.
21 changes: 0 additions & 21 deletions packages/devextreme-angular/src/ui/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,6 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
}


/**
* [descr:dxChatOptions.title]
*/
@Input()
get title(): string {
return this._getOption('title');
}
set title(value: string) {
this._setOption('title', value);
}


/**
* [descr:dxChatOptions.user]
Expand Down Expand Up @@ -367,13 +354,6 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
*/
@Output() rtlEnabledChange: EventEmitter<boolean>;

/**
* This member supports the internal infrastructure and is not intended to be used directly from your code.
*/
@Output() titleChange: EventEmitter<string>;

/**
* This member supports the internal infrastructure and is not intended to be used directly from your code.
Expand Down Expand Up @@ -434,7 +414,6 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
{ emit: 'hoverStateEnabledChange' },
{ emit: 'itemsChange' },
{ emit: 'rtlEnabledChange' },
{ emit: 'titleChange' },
{ emit: 'userChange' },
{ emit: 'visibleChange' },
{ emit: 'widthChange' }
Expand Down
5 changes: 3 additions & 2 deletions packages/devextreme-scss/scss/widgets/base/chat/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ $chat-bubble-border-radius: 12px;
$chat-text-area-height: 40px;

.dx-chat {
display: grid;
grid-template-rows: 24px 1fr minmax(40px, auto);
display: flex;
flex-direction: column;
width: $chat-width;
height: $chat-height;
padding: $chat-padding;
Expand All @@ -32,6 +32,7 @@ $chat-text-area-height: 40px;

.dx-chat-message-list {
box-sizing: border-box;
flex-grow: 1;
overflow: hidden;
}

Expand Down
3 changes: 0 additions & 3 deletions packages/devextreme-vue/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type AccessibleOptions = Pick<Properties,
"onMessageSend" |
"onOptionChanged" |
"rtlEnabled" |
"title" |
"user" |
"visible" |
"width"
Expand All @@ -44,7 +43,6 @@ const DxChat = createComponent({
onMessageSend: Function,
onOptionChanged: Function,
rtlEnabled: Boolean,
title: String,
user: Object,
visible: Boolean,
width: [Function, Number, String]
Expand All @@ -67,7 +65,6 @@ const DxChat = createComponent({
"update:onMessageSend": null,
"update:onOptionChanged": null,
"update:rtlEnabled": null,
"update:title": null,
"update:user": null,
"update:visible": null,
"update:width": null,
Expand Down
35 changes: 26 additions & 9 deletions packages/devextreme/js/__internal/ui/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ import MessageList from './chat_message_list';
const CHAT_CLASS = 'dx-chat';
const TEXTEDITOR_INPUT_CLASS = 'dx-texteditor-input';

class Chat extends Widget<Properties> {
_chatHeader!: ChatHeader;
type Title = string;

class Chat extends Widget<Properties & { title: Title }> {
_chatHeader?: ChatHeader;

_messageBox!: MessageBox;

_messageList!: MessageList;

_messageSendAction?: (e: Partial<MessageSendEvent>) => void;

_getDefaultOptions(): Properties {
_getDefaultOptions(): Properties & { title: Title } {
return {
...super._getDefaultOptions(),
activeStateEnabled: true,
Expand All @@ -51,15 +53,20 @@ class Chat extends Widget<Properties> {

super._initMarkup();

this._renderHeader();
const { title } = this.option();

if (title) {
this._renderHeader(title);
}

this._renderMessageList();
this._renderMessageBox();
}

_renderHeader(): void {
const { title = '' } = this.option();
_renderHeader(title: string): void {
const $header = $('<div>');

const $header = $('<div>').appendTo(this.element());
this.element().prepend($header.get(0));

this._chatHeader = this._createComponent($header, ChatHeader, {
title,
Expand Down Expand Up @@ -135,9 +142,19 @@ class Chat extends Widget<Properties> {
case 'hoverStateEnabled':
this._messageBox.option(name, value as Properties[typeof name]);
break;
case 'title':
this._chatHeader.option('title', (value as Properties[typeof name]) ?? '');
case 'title': {
if (value) {
if (this._chatHeader) {
this._chatHeader.option('title', (value as Title));
} else {
this._renderHeader((value as Title));
}
} else if (this._chatHeader) {
this._chatHeader.dispose();
this._chatHeader.$element().remove();
}
break;
}
case 'user':
this._messageList.option('currentUserId', (value as Properties[typeof name])?.id);
break;
Expand Down
6 changes: 0 additions & 6 deletions packages/devextreme/js/ui/chat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ export interface dxChatOptions extends WidgetOptions<dxChat> {
* @public
*/
user?: User;
/**
* @docid
* @default ''
* @public
*/
title?: string;
/**
* @docid
* @fires dxChatOptions.onOptionChanged
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,46 @@ const moduleConfig = {

QUnit.module('Chat', moduleConfig, () => {
QUnit.module('Render', () => {
QUnit.test('Header should be rendered', function(assert) {
QUnit.test('Header should be rendered if title is not empty', function(assert) {
this.reinit({ title: 'custom' });

const $header = this.$element.find(`.${CHAT_HEADER_CLASS}`);

assert.strictEqual($header.length, 1);
});

QUnit.test('Header should not be rendered if title is empty', function(assert) {
const $header = this.$element.find(`.${CHAT_HEADER_CLASS}`);

assert.strictEqual($header.length, 0);
});

QUnit.test('Header should be rendered if title is not empty on init and in runtime', function(assert) {
this.reinit({ title: 'custom' });
this.instance.option({ title: 'new custom' });

const $header = this.$element.find(`.${CHAT_HEADER_CLASS}`);

assert.strictEqual($header.length, 1);
});

QUnit.test('Header should be rendered if title is empty on init and not empty in runtime', function(assert) {
this.instance.option({ title: 'new custom' });

const $header = this.$element.find(`.${CHAT_HEADER_CLASS}`);

assert.strictEqual($header.length, 1);
});

QUnit.test('Header should be removed if title is empty in runtime', function(assert) {
this.reinit({ title: 'custom' });
this.instance.option({ title: '' });

const $header = this.$element.find(`.${CHAT_HEADER_CLASS}`);

assert.strictEqual($header.length, 0);
});

QUnit.test('Message list should be rendered', function(assert) {
const $messageList = this.$element.find(`.${CHAT_MESSAGE_LIST_CLASS}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import Chat from 'ui/chat';
import MessageList from '__internal/ui/chat/chat_message_list';
import MessageBox from '__internal/ui/chat/chat_message_box';
import keyboardMock from '../../../helpers/keyboardMock.js';

import { isRenderer } from 'core/utils/type';

import config from 'core/config';

const CHAT_HEADER_TEXT_CLASS = 'dx-chat-header-text';
Expand Down
4 changes: 0 additions & 4 deletions packages/devextreme/ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9479,10 +9479,6 @@ declare module DevExpress.ui {
* [descr:dxChatOptions.user]
*/
user?: DevExpress.ui.dxChat.User;
/**
* [descr:dxChatOptions.title]
*/
title?: string;
/**
* [descr:dxChatOptions.items]
*/
Expand Down

0 comments on commit da6a7a9

Please sign in to comment.