feature: drag support in sort panel.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createElement, setTooltip, createIcon } from "../../ui";
|
||||
import { r as lang, nullOrEmpty, escapeHtml, escapeEmoji } from "../../utility";
|
||||
import { createBox, appendMedia } from "./lib";
|
||||
import { createBox, appendMedia, createHideMessageTitleButton, createHideMessageCommentTail } from "./lib";
|
||||
|
||||
let r = lang;
|
||||
|
||||
@@ -25,7 +25,9 @@ export default class CustomerRecordComment {
|
||||
}
|
||||
}
|
||||
|
||||
get messageHidden() { return this._var.option.showCommentHidden }
|
||||
/**
|
||||
* @param {boolean} flag
|
||||
*/
|
||||
set messageHidden(flag) {
|
||||
const el = this._var.container.querySelector('.msgadminsetting');
|
||||
if (el == null) {
|
||||
@@ -62,34 +64,14 @@ export default class CustomerRecordComment {
|
||||
}
|
||||
|
||||
create() {
|
||||
const option = this._var.option;
|
||||
const readonly = this._var.option.readonly;
|
||||
const spanv = createElement('span');
|
||||
if (option.userIsAdmin) {
|
||||
spanv.className = 'msgadminsetting sbutton iconnotview';
|
||||
spanv.style.padding = '0px 0px 0px 5px';
|
||||
spanv.addEventListener('click', function () {
|
||||
if (!option.showCommentHidden) {
|
||||
this.classList.remove('iconnotview');
|
||||
this.classList.add('iconview');
|
||||
option.showCommentHidden = true;
|
||||
container.querySelectorAll('.msgsetting').forEach(x => x.style.display = '');
|
||||
} else {
|
||||
this.classList.remove('iconview');
|
||||
this.classList.add('iconnotview');
|
||||
option.showCommentHidden = false;
|
||||
container.querySelectorAll('.msgsetting').forEach(x => x.style.display = 'none');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
const container = createBox(
|
||||
createElement('div', null,
|
||||
createElement('div', div => {
|
||||
div.className = 'title-module';
|
||||
div.innerText = r('P_CR_COMMENTS', 'Comments');
|
||||
},
|
||||
spanv
|
||||
createHideMessageTitleButton(this, 'showCommentHidden')
|
||||
)
|
||||
),
|
||||
[
|
||||
@@ -154,11 +136,18 @@ export default class CustomerRecordComment {
|
||||
return this._var.container = container;
|
||||
}
|
||||
|
||||
load(data, func) {
|
||||
load(data, func, hisFunc, keep) {
|
||||
const children = [];
|
||||
if (data?.length > 0) {
|
||||
const lastVisible = this._var.option.showCommentHidden;
|
||||
for (let comment of data) {
|
||||
const div = createElement('div', 'item-div');
|
||||
if (comment.Hidden) {
|
||||
div.classList.add('hidden-content');
|
||||
if (!lastVisible) {
|
||||
div.style.display = 'none';
|
||||
}
|
||||
}
|
||||
// if (sendto !== '') {
|
||||
// sendto = r('P_CU_SENDTO_COLON', 'Sent To :') + `\n${sendto}`;
|
||||
// }
|
||||
@@ -177,37 +166,19 @@ export default class CustomerRecordComment {
|
||||
}
|
||||
div.append(
|
||||
content,
|
||||
createElement('div', div => {
|
||||
div.className = 'item-time';
|
||||
},
|
||||
createElement('span', span => {
|
||||
span.className = 'msgsetting sbutton ' + (comment.Hidden ? 'iconnotview' : 'iconview');
|
||||
span.style.padding = '0px 0px 0px 5px';
|
||||
span.style.fontSize = '12px';
|
||||
span.style.display = this._var.option.showCommentHidden ? '' : 'none';
|
||||
span.addEventListener('click', function () {
|
||||
if (this.classList.contains('iconview')) {
|
||||
func(comment.Id, true);
|
||||
this.classList.remove('iconview');
|
||||
this.classList.add('iconnotview');
|
||||
} else {
|
||||
func(comment.Id, false);
|
||||
this.classList.remove('iconnotview');
|
||||
this.classList.add('iconview');
|
||||
}
|
||||
});
|
||||
}),
|
||||
createElement('span', span => {
|
||||
span.innerText = comment.SubmitLocalDateStr;
|
||||
})
|
||||
)
|
||||
createHideMessageCommentTail(
|
||||
this, 'showCommentHidden',
|
||||
comment, 'SubmitLocalDateStr',
|
||||
func, hisFunc)
|
||||
);
|
||||
children.push(div);
|
||||
}
|
||||
children[0].style.marginTop = '0';
|
||||
}
|
||||
if (this._var.message.children.length > 0) {
|
||||
this._var.lastTop = this._var.message.scrollTop;
|
||||
}
|
||||
this._var.message.replaceChildren(...children);
|
||||
this._var.message.scrollTop = this._var.message.scrollHeight
|
||||
// setTimeout(() => this._var.message.scrollTop = this._var.message.scrollHeight, 0);
|
||||
setTimeout(() => this._var.message.scrollTop = keep ? this._var.lastTop : this._var.message.scrollHeight, 0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user