UI style adjustment

This commit is contained in:
Chen Lily 2023-06-05 15:21:56 +08:00
parent 93d5be462e
commit 2366b378d2
4 changed files with 138 additions and 36 deletions

View File

@ -73,7 +73,7 @@ class Contact {
if (item == null) { if (item == null) {
return false; return false;
} }
item.Id = -1; //item.Id = -1;
item.SaveToCustomer = 0; item.SaveToCustomer = 0;
if (typeof this.#option.onSave === 'function') { if (typeof this.#option.onSave === 'function') {
return this.#option.onSave.call(this, item, 'workorder'); return this.#option.onSave.call(this, item, 'workorder');

View File

@ -337,6 +337,7 @@ class CustomerCommunication {
if (option.autoUpdatesVisible === false) { if (option.autoUpdatesVisible === false) {
checkAutoUpdate.style.display = 'none'; checkAutoUpdate.style.display = 'none';
} }
const This = this;
const checkLink = createCheckbox({ const checkLink = createCheckbox({
className: 'check-status-link', className: 'check-status-link',
enabled: !readonly, enabled: !readonly,
@ -347,6 +348,9 @@ class CustomerCommunication {
setTooltip(checkLink, this.checked ? setTooltip(checkLink, this.checked ?
r('statusLinkIncluded', 'Status Link Included') : r('statusLinkIncluded', 'Status Link Included') :
r('statusLinkExcluded', 'Status Link Excluded')); r('statusLinkExcluded', 'Status Link Excluded'));
if (typeof option.onStatusLinkChanged === 'function') {
option.onStatusLinkChanged.call(This, this.checked);
}
} }
}); });
if (option.statusLinkVisible === false) { if (option.statusLinkVisible === false) {
@ -898,7 +902,33 @@ class CustomerCommunication {
}); });
}); });
}) })
) ),
createElement('div', div => {
div.className = 'bar-info';
div.innerText = r('contactInformation', 'Contact Information');
}),
createElement('div', div => {
if (option.contactCollapsed) {
container.classList.add('collapsed');
div.className = 'bar-collapser collapsed';
} else {
div.className = 'bar-collapser';
}
div.addEventListener('click', () => {
const collapsed = div.classList.contains('collapsed');
if (collapsed) {
div.classList.remove('collapsed');
container.classList.remove('collapsed');
} else {
div.classList.add('collapsed');
container.classList.add('collapsed');
}
if (typeof option.onContactCollapsed === 'function') {
option.onContactCollapsed.call(this, !collapsed);
}
});
div.append(createElement('span'));
})
) )
); );
return contacts; return contacts;

View File

@ -133,6 +133,7 @@
padding: 4px 0; padding: 4px 0;
display: flex; display: flex;
border-bottom: 1px solid var(--title-bg-color); border-bottom: 1px solid var(--title-bg-color);
position: relative;
>.bar-icon { >.bar-icon {
flex: 0 0 auto; flex: 0 0 auto;
@ -149,8 +150,10 @@
width: calc(100% - 46px); width: calc(100% - 46px);
.bar-list-container { .bar-list-container {
min-height: 26px;
max-height: 120px; max-height: 120px;
overflow: auto; overflow: auto;
position: relative;
} }
.contact-item { .contact-item {
@ -178,6 +181,46 @@
} }
} }
>.bar-info {
display: none;
flex: 1 1 auto;
text-align: right;
margin-right: 50px;
}
>.bar-collapser {
position: absolute;
top: 3px;
right: 18px;
width: 26px;
height: 26px;
box-sizing: border-box;
padding: 10px;
cursor: pointer;
border-radius: 13px;
transition: background-color .12s ease;
&:hover {
background-color: var(--light-color);
}
>span {
width: 6px;
height: 6px;
position: absolute;
border-top: 1px solid var(--strong-color);
border-right: 1px solid var(--strong-color);
top: 8px;
transform: rotate(135deg);
}
&.collapsed>span {
top: 9px;
left: 8px;
transform: rotate(45deg);
}
}
.roundbtn { .roundbtn {
float: right; float: right;
margin: 4px 10px 10px; margin: 4px 10px 10px;
@ -188,6 +231,25 @@
} }
} }
&.collapsed {
.contact-bar {
border-bottom-color: transparent;
>.bar-icon,
>.bar-list {
display: none;
}
>.bar-info {
display: block;
}
}
.follower-bar {
display: none !important;
}
}
.message-bar { .message-bar {
flex: 0 0 auto; flex: 0 0 auto;
border-bottom: 1px solid var(--title-bg-color); border-bottom: 1px solid var(--title-bg-color);

View File

@ -72,10 +72,10 @@ function setTooltip(container, content, flag = false, parent = null) {
top -= p.scrollTop; top -= p.scrollTop;
p = p.parentElement; p = p.parentElement;
} }
left += (c.offsetWidth - wrapper.offsetWidth) / 2;
wrapper.style.left = `${left}px`;
// check overflow // check overflow
let t = c.offsetTop; let t = c.offsetTop;
let l = c.offsetLeft;
let lastWidth = c.offsetWidth;
p = c.offsetParent; p = c.offsetParent;
while (p != null) { while (p != null) {
const overflow = window.getComputedStyle(p).overflow; const overflow = window.getComputedStyle(p).overflow;
@ -83,16 +83,26 @@ function setTooltip(container, content, flag = false, parent = null) {
break; break;
} }
t += p.offsetTop; t += p.offsetTop;
l += p.offsetLeft;
lastWidth = p.offsetWidth;
p = p.offsetParent; p = p.offsetParent;
} }
const offsetHeight = wrapper.offsetHeight + 14; const offsetHeight = wrapper.offsetHeight + 14;
if (t + top - offsetHeight < 0) { if (t + top - offsetHeight < 0) {
top += c.parentElement.offsetHeight + 14; top += c.parentElement.offsetHeight + 10;
wrapper.classList.add('ui-tooltip-down'); wrapper.classList.add('ui-tooltip-down');
} else { } else {
top -= offsetHeight; top -= offsetHeight;
wrapper.classList.remove('ui-tooltip-down'); wrapper.classList.remove('ui-tooltip-down');
} }
const offsetWidth = wrapper.offsetWidth;
left += (c.offsetWidth - offsetWidth) / 2;
if (left < -l) {
left = 2;
} else if (left + offsetWidth + 2 > lastWidth) {
left = lastWidth - offsetWidth - 2;
}
wrapper.style.left = `${left}px`;
wrapper.style.top = `${top}px`; wrapper.style.top = `${top}px`;
wrapper.style.visibility = 'visible'; wrapper.style.visibility = 'visible';
wrapper.style.opacity = 1; wrapper.style.opacity = 1;