remove dependency of jQuery plugins.

Grid.expandAll
add total field of exported data.
This commit is contained in:
2024-04-24 14:10:28 +08:00
parent 4e8be83625
commit f676ec76db
6 changed files with 400 additions and 183 deletions

View File

@ -25,6 +25,18 @@ export default class CustomerRecordComment {
}
}
get messageHidden() { return this._var.option.showCommentHidden }
set messageHidden(flag) {
const el = this._var.container.querySelector('.msgadminsetting');
if (el == null) {
return;
}
this._var.option.showCommentHidden = flag;
// TODO: 是否与参数 flag 无关
el.classList.remove('iconview');
el.classList.add('iconnotview');
}
/**
* @param {boolean} flag
*/
@ -50,13 +62,35 @@ 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
)
),
[
createElement('button', button => {
@ -120,7 +154,7 @@ export default class CustomerRecordComment {
return this._var.container = container;
}
load(data) {
load(data, func) {
const children = [];
if (data?.length > 0) {
for (let comment of data) {
@ -145,8 +179,28 @@ export default class CustomerRecordComment {
content,
createElement('div', div => {
div.className = 'item-time';
div.innerText = comment.SubmitLocalDateStr;
})
},
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;
})
)
);
children.push(div);
}

View File

@ -69,6 +69,18 @@ export default class CustomerCommunication {
element.dispatchEvent(new Event('change'));
}
get messageHidden() { return this._var.option.showMessageHidden }
set messageHidden(flag) {
const el = this._var.container.querySelector('.msgadminsetting');
if (el == null) {
return;
}
this._var.option.showMessageHidden = flag;
// TODO: 是否与参数 flag 无关
el.classList.remove('iconview');
el.classList.add('iconnotview');
}
get _statusLink() { return this._var.container.querySelector('.check-status-link>input') }
get statusLinkEnabled() { return this._statusLink?.disabled !== true }
set statusLinkEnabled(flag) {
@ -413,12 +425,33 @@ export default class CustomerCommunication {
if (option.statusLinkVisible === false) {
checkLink.style.display = 'none';
}
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.showMessageHidden) {
this.classList.remove('iconnotview');
this.classList.add('iconview');
option.showMessageHidden = true;
container.querySelectorAll('.msgsetting').forEach(x => x.style.display = '');
} else {
this.classList.remove('iconview');
this.classList.add('iconnotview');
option.showMessageHidden = 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 = option.title ?? r('P_WO_CUSTOMERCOMMUNICATION', 'Customer Communication');
}),
},
spanv
),
createElement('div', div => {
div.className = 'title-company';
if (nullOrEmpty(option.companyName)) {
@ -1146,7 +1179,7 @@ export default class CustomerCommunication {
return followers;
}
load(data, contacts, followers) {
load(data, contacts, followers, func) {
const children = [];
if (data?.length > 0) {
contacts ??= this._var.data.contacts;
@ -1216,8 +1249,28 @@ export default class CustomerCommunication {
content,
createElement('div', div => {
div.className = 'item-time';
div.innerText = comm.TimeStr;
})
},
createElement('span', span => {
span.className = 'msgsetting sbutton ' + (comm.Hidden ? 'iconnotview' : 'iconview');
span.style.padding = '0px 0px 0px 5px';
span.style.fontSize = '12px';
span.style.display = this._var.option.showMessageHidden ? '' : 'none';
span.addEventListener('click', function () {
if (this.classList.contains('iconview')) {
func(comm.Id, true);
this.classList.remove('iconview');
this.classList.add('iconnotview');
} else {
func(comm.Id, false);
this.classList.remove('iconnotview');
this.classList.add('iconview');
}
});
}),
createElement('span', span => {
span.innerText = comm.TimeStr;
})
)
);
children.push(div);
}

View File

@ -32,6 +32,18 @@ export default class InternalComment {
}
}
get messageHidden() { return this._var.option.showCommentHidden }
set messageHidden(flag) {
const el = this._var.container.querySelector('.msgadminsetting');
if (el == null) {
return;
}
this._var.option.showMessageHidden = flag;
// TODO: 是否与参数 flag 无关
el.classList.remove('iconview');
el.classList.add('iconnotview');
}
/**
* @param {any} contacts
*/
@ -110,7 +122,28 @@ export default class InternalComment {
createElement('div', div => {
div.className = 'title-module';
div.innerText = r('P_WO_INTERNALCOMMENTS', 'Internal Comments');
})
},
createElement('span', span => {
if (option.userIsAdmin) {
span.className = 'msgadminsetting sbutton iconnotview';
span.style.padding = '0px 0px 0px 5px';
span.addEventListener('click', function () {
if (!option.showMessageHidden) {
this.classList.remove('iconnotview');
this.classList.add('iconview');
option.showMessageHidden = true;
container.querySelectorAll('.msgsetting').forEach(x => x.style.display = '');
}
else {
this.classList.remove('iconview');
this.classList.add('iconnotview');
option.showMessageHidden = false;
container.querySelectorAll('.msgsetting').forEach(x => x.style.display = 'none');
}
});
}
})
)
), []
);
const readonly = option.readonly;
@ -245,7 +278,7 @@ export default class InternalComment {
return this._var.container = container;
}
load(data) {
load(data, func) {
const children = [];
if (data?.length > 0) {
this._var.comments = data;
@ -302,8 +335,28 @@ export default class InternalComment {
content,
createElement('div', div => {
div.className = 'item-time';
div.innerText = comment.TimeStr;
})
},
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.showMessageHidden ? '' : '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.TimeStr;
})
)
);
children.push(div);
}