Skip to content

Commit 390855b

Browse files
committed
Fix infobox in list & grid view
Closes #6406
1 parent 9883e82 commit 390855b

File tree

7 files changed

+36
-9
lines changed

7 files changed

+36
-9
lines changed

com.woltlab.wcf/templates/shared_gridView.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
</table>
5454
</div>
5555

56-
<div class="gridView__footer">
56+
<woltlab-core-notice type="info" id="{$view->getID()}_noItemsNotice"{if $view->countRows()} hidden{/if}>{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
57+
58+
<div class="gridView__footer" id="{$view->getID()}_footer"{if $view->countPages() < 2} hidden{/if}>
5759
{if $view->hasBulkInteractions()}
5860
<div id="{$view->getID()}_selectionBar" class="gridView__selectionBar dropdown" hidden>
5961
<button type="button" id="{$view->getID()}_bulkInteractionButton" class="button small gridView__bulkInteractionButton dropdownToggle"></button>
@@ -77,8 +79,6 @@
7779
></woltlab-core-pagination>
7880
</div>
7981
</div>
80-
81-
<woltlab-core-notice type="info" id="{$view->getID()}_noItemsNotice"{if $view->countRows()} hidden{/if}>{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
8282
</div>
8383

8484
<script data-relocate="true">

com.woltlab.wcf/templates/shared_listView.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
</div>
5555
</div>
5656

57+
<woltlab-core-notice type="info" id="{$view->getID()}_noItemsNotice"{if $view->countItems()} hidden{/if}>{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
58+
5759
<div class="listView__footer" id="{$view->getID()}_footer"{if $view->countPages() < 2} hidden{/if}>
5860
{if $view->hasBulkInteractions()}
5961
<div id="{$view->getID()}_selectionBar" class="listView__selectionBar dropdown" hidden>
@@ -78,8 +80,6 @@
7880
></woltlab-core-pagination>
7981
</div>
8082
</div>
81-
82-
<woltlab-core-notice type="info" id="{$view->getID()}_noItemsNotice"{if $view->countItems()} hidden{/if}>{lang}wcf.global.noItems{/lang}</woltlab-core-notice>
8383
</div>
8484

8585
<script data-relocate="true">

ts/WoltLabSuite/Core/Component/GridView/Selection.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export class Selection extends EventTarget {
5151
this.#restoreSelection();
5252
}
5353

54+
selectionBarVisible(): boolean {
55+
return this.#selectionBar !== null && this.getSelectedIds().length > 0;
56+
}
57+
5458
refresh(): void {
5559
this.#restoreSelection();
5660
}
@@ -168,6 +172,8 @@ export class Selection extends EventTarget {
168172
return;
169173
}
170174

175+
this.dispatchEvent(new CustomEvent("grid-view:update-selection"));
176+
171177
if (selectedIds.length === 0) {
172178
this.#selectionBar.hidden = true;
173179
return;
@@ -284,6 +290,7 @@ export class Selection extends EventTarget {
284290

285291
interface SelectionEventMap {
286292
"grid-view:get-bulk-interactions": CustomEvent<{ objectIds: number[] }>;
293+
"grid-view:update-selection": CustomEvent<void>;
287294
}
288295

289296
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging

ts/WoltLabSuite/Core/Component/GridView/State.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class State extends EventTarget {
2424
readonly #pagination: WoltlabCorePaginationElement;
2525
readonly #selection: Selection;
2626
readonly #sorting: Sorting;
27+
readonly #gridViewFooter: HTMLElement;
2728
#pageNo: number;
2829

2930
constructor(
@@ -39,6 +40,8 @@ export class State extends EventTarget {
3940
this.#baseUrl = baseUrl;
4041
this.#pageNo = pageNo;
4142

43+
this.#gridViewFooter = document.getElementById(`${gridId}_footer`) as HTMLElement;
44+
4245
this.#pagination = document.getElementById(`${gridId}_pagination`) as WoltlabCorePaginationElement;
4346
this.#pagination.addEventListener("switchPage", (event: CustomEvent) => {
4447
void this.#switchPage(event.detail, StateChangeCause.Pagination);
@@ -60,12 +63,16 @@ export class State extends EventTarget {
6063
new CustomEvent("grid-view:get-bulk-interactions", { detail: { objectIds: event.detail.objectIds } }),
6164
);
6265
});
66+
this.#selection.addEventListener("grid-view:update-selection", () => {
67+
this.#updateGridViewFooter();
68+
});
6369

6470
window.addEventListener("popstate", () => {
6571
this.#handlePopState();
6672
});
6773

6874
this.#updatePaginationUrl();
75+
this.#updateGridViewFooter();
6976
}
7077

7178
getPageNo(): number {
@@ -176,6 +183,10 @@ export class State extends EventTarget {
176183
this.#switchPage(pageNo, StateChangeCause.History);
177184
}
178185

186+
#updateGridViewFooter(): void {
187+
this.#gridViewFooter.hidden = this.#pagination.count < 2 && !this.#selection.selectionBarVisible();
188+
}
189+
179190
setBulkInteractionContextMenuOptions(options: string): void {
180191
this.#selection.setBulkInteractionContextMenuOptions(options);
181192
}

wcfsetup/install/files/js/WoltLabSuite/Core/Component/GridView/Selection.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wcfsetup/install/files/js/WoltLabSuite/Core/Component/GridView/State.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wcfsetup/install/files/style/ui/gridView.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,3 @@
258258
box-shadow: rgba(0, 0, 0, 0.08) 0px 10px 16px 2px;
259259
}
260260
}
261-
262-
.gridView .info {
263-
margin-top: 0;
264-
}

0 commit comments

Comments
 (0)