Skip to content

Commit

Permalink
Migrate WCF.User.Profile.ActivityPointList to Typescript
Browse files Browse the repository at this point in the history
Closes #6092
  • Loading branch information
BurntimeX committed Nov 25, 2024
1 parent e004b8f commit d909211
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 2 deletions.
2 changes: 0 additions & 2 deletions com.woltlab.wcf/templates/headIncludeJavaScript.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ window.addEventListener('pageshow', function(event) {

<script data-relocate="true">
$(function() {
WCF.User.Profile.ActivityPointList.init();
{if MODULE_TROPHY && $__wcf->session->getPermission('user.profile.trophy.canSeeTrophies')}
require(['WoltLabSuite/Core/Ui/User/Trophy/List'], function (UserTrophyList) {
new UserTrophyList();
Expand Down
3 changes: 3 additions & 0 deletions ts/WoltLabSuite/Core/Bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export function setup(options: BoostrapOptions): void {
void import("./Component/File/woltlab-core-file");
void import("./Component/File/Upload").then(({ setup }) => setup());
});
whenFirstSeen(".activityPointsDisplay", () => {
void import("./Component/User/ActivityPointList").then(({ setup }) => setup());
});

// Move the reCAPTCHA widget overlay to the `pageOverlayContainer`
// when widget form elements are placed in a dialog.
Expand Down
39 changes: 39 additions & 0 deletions ts/WoltLabSuite/Core/Component/User/ActivityPointList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Shows the activity point list for users.
*
* @author Marcel Werk
* @copyright 2001-2024 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/

import { dboAction } from "WoltLabSuite/Core/Ajax";
import { promiseMutex } from "WoltLabSuite/Core/Helper/PromiseMutex";
import { wheneverFirstSeen } from "WoltLabSuite/Core/Helper/Selector";
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
import { getPhrase } from "WoltLabSuite/Core/Language";

type ResponseGetDetailedActivityPointList = {
template: string;
};

async function showDialog(userId: number): Promise<void> {
const response = (await dboAction("getDetailedActivityPointList", "wcf\\data\\user\\UserProfileAction")
.objectIds([userId])
.dispatch()) as ResponseGetDetailedActivityPointList;

const dialog = dialogFactory().fromHtml(response.template).withoutControls();
dialog.show(getPhrase("wcf.user.activityPoint"));
}

export function setup(): void {
wheneverFirstSeen(".activityPointsDisplay", (button) => {
button.addEventListener(
"click",
promiseMutex((event) => {
event.preventDefault();
return showDialog(parseInt(button.dataset.userId!));
}),
);
});
}
2 changes: 2 additions & 0 deletions wcfsetup/install/files/js/WCF.User.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ WCF.User.Profile = {};

/**
* Shows the activity point list for users.
*
* @deprecated 6.2 Use `WoltLabSuite/Core/Component/User/ActivityPointList` instead.
*/
WCF.User.Profile.ActivityPointList = {
/**
Expand Down
3 changes: 3 additions & 0 deletions wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d909211

Please sign in to comment.