Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-6337 - Variant Browser: Warnings displayed take the whole screen #932

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions src/webcomponents/commons/grid-commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,21 +324,56 @@ export default class GridCommons {
return columns;
}

displayResponseWarningEvents(response) {
displayResponseWarningEvents(response, maxVisibleEvents = 3) {
const eventsContainer = this.context.querySelector(`div#${this.gridId}WarningEvents`);
if (eventsContainer && (response?.events?.length > 0 || response?.responses?.[0]?.events?.length > 0)) {
const events = [...(response?.events || []), ...(response?.responses?.[0]?.events || [])]
.filter(event => event && event.type === "WARNING" && !!event.message);
if (events.length > 0) {
const eventsMessages = events.map(event => {
.filter(event => event && event.type === "WARNING" && !!event.message)
.map(event => {
return `
<div class="alert alert-warning" style="margin-bottom:8px;">
<i class="fas fa-exclamation-triangle icon-padding"></i>
<span>${event.message}</span>
</div>
`;
});
eventsContainer.replaceChildren(UtilsNew.renderHTML(eventsMessages.join("")));
if (events.length > 0) {
const defaultVisibleEvents = events.length > maxVisibleEvents ? events.slice(0, maxVisibleEvents) : events;
const defaultHiddenEvents = events.length > maxVisibleEvents ? events.slice(maxVisibleEvents) : [];
const eventsMessages = UtilsNew.renderHTML(`
<div>
${defaultVisibleEvents.join("")}
${defaultHiddenEvents.length > 0 ? `
<div data-role="hidden-events" style="display:none;">${defaultHiddenEvents.join("")}</div>
<div class="text-muted">
<div data-role="show-more-events" style="display:inline-block;cursor:pointer;">
<small><i class="fas fa-chevron-down" style="padding-right:6px;"></i>Show more warning events (<b>${defaultHiddenEvents.length}</b>)</small>
</div>
<div data-role="show-less-events" style="display:none;cursor:pointer;">
<small><i class="fas fa-chevron-up" style="padding-right:6px;"></i>Show less warning events</small>
</div>
</div>
` : ""}
</div>
`).querySelector("div");
eventsContainer.replaceChildren(eventsMessages);
if (defaultHiddenEvents.length > 0) {
const hiddenEventsElement = eventsMessages.querySelector(`div[data-role="hidden-events"]`);
const showMoreEventsElement = eventsMessages.querySelector(`div[data-role="show-more-events"]`);
const showLessEventsElement = eventsMessages.querySelector(`div[data-role="show-less-events"]`);
// Show more events click
showMoreEventsElement.addEventListener("click", () => {
hiddenEventsElement.style.display = "block";
showLessEventsElement.style.display = "inline-block";
showMoreEventsElement.style.display = "none";
});
// Show less events click
showLessEventsElement.addEventListener("click", () => {
hiddenEventsElement.style.display = "none";
showLessEventsElement.style.display = "none";
showMoreEventsElement.style.display = "inline-block";
});
}
}
}
}
Expand Down
Loading