Skip to content

Commit 392c188

Browse files
authored
Merge pull request #6119 from WoltLab/user-activity-point-list-typescript
Migrate `WCF.User.Profile.ActivityPointList` to Typescript
2 parents 9f91c1d + 4fd3a35 commit 392c188

File tree

6 files changed

+77
-4
lines changed

6 files changed

+77
-4
lines changed

com.woltlab.wcf/templates/headIncludeJavaScript.tpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ window.addEventListener('pageshow', function(event) {
160160

161161
<script data-relocate="true">
162162
$(function() {
163-
WCF.User.Profile.ActivityPointList.init();
164-
165163
{if MODULE_TROPHY && $__wcf->session->getPermission('user.profile.trophy.canSeeTrophies')}
166164
require(['WoltLabSuite/Core/Ui/User/Trophy/List'], function (UserTrophyList) {
167165
new UserTrophyList();

ts/WoltLabSuite/Core/Bootstrap.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ export function setup(options: BoostrapOptions): void {
175175
void import("./Component/File/woltlab-core-file");
176176
void import("./Component/File/Upload").then(({ setup }) => setup());
177177
});
178+
whenFirstSeen(".activityPointsDisplay", () => {
179+
void import("./Component/User/ActivityPointList").then(({ setup }) => setup());
180+
});
178181

179182
whenFirstSeen("[data-fancybox]", () => {
180183
void import("./Component/Image/Viewer").then(({ setup }) => setup());
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Shows the activity point list for users.
3+
*
4+
* @author Marcel Werk
5+
* @copyright 2001-2024 WoltLab GmbH
6+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7+
* @since 6.2
8+
*/
9+
10+
import { dboAction } from "WoltLabSuite/Core/Ajax";
11+
import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex";
12+
import { wheneverFirstSeen } from "WoltLabSuite/Core/Helper/Selector";
13+
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
14+
import { getPhrase } from "WoltLabSuite/Core/Language";
15+
16+
type ResponseGetDetailedActivityPointList = {
17+
template: string;
18+
};
19+
20+
async function showDialog(userId: number): Promise<void> {
21+
const response = (await dboAction("getDetailedActivityPointList", "wcf\\data\\user\\UserProfileAction")
22+
.objectIds([userId])
23+
.dispatch()) as ResponseGetDetailedActivityPointList;
24+
25+
const dialog = dialogFactory().fromHtml(response.template).withoutControls();
26+
dialog.show(getPhrase("wcf.user.activityPoint"));
27+
}
28+
29+
export function setup(): void {
30+
wheneverFirstSeen(".activityPointsDisplay", (button) => {
31+
button.addEventListener(
32+
"click",
33+
promiseMutex((event) => {
34+
event.preventDefault();
35+
return showDialog(parseInt(button.dataset.userId!));
36+
}),
37+
);
38+
});
39+
}

wcfsetup/install/files/js/WCF.User.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ WCF.User.Profile = {};
1515

1616
/**
1717
* Shows the activity point list for users.
18+
*
19+
* @deprecated 6.2 Use `WoltLabSuite/Core/Component/User/ActivityPointList` instead.
1820
*/
1921
WCF.User.Profile.ActivityPointList = {
2022
/**

wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js

Lines changed: 5 additions & 2 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/User/ActivityPointList.js

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

0 commit comments

Comments
 (0)