+
+# User Metadata
+
+
+# Directory
+
diff --git a/plugins/discourse-gamification/admin/assets/javascripts/admin/components/admin-create-leaderboard.gjs b/plugins/discourse-gamification/admin/assets/javascripts/admin/components/admin-create-leaderboard.gjs
new file mode 100644
index 00000000000..ee04f978d37
--- /dev/null
+++ b/plugins/discourse-gamification/admin/assets/javascripts/admin/components/admin-create-leaderboard.gjs
@@ -0,0 +1,95 @@
+import Component from "@glimmer/component";
+import { tracked } from "@glimmer/tracking";
+import { action } from "@ember/object";
+import { readOnly } from "@ember/object/computed";
+import { service } from "@ember/service";
+import Form from "discourse/components/form";
+import { ajax } from "discourse/lib/ajax";
+import { popupAjaxError } from "discourse/lib/ajax-error";
+import { i18n } from "discourse-i18n";
+
+export default class AdminCreateLeaderboard extends Component {
+ @service currentUser;
+ @service router;
+ @service toasts;
+
+ @tracked newLeaderboardName = "";
+ @tracked loading = false;
+
+ @readOnly("newLeaderboardName") nameValid;
+
+ get formData() {
+ return { name: "", created_by_id: this.currentUser.id };
+ }
+
+ @action
+ async createNewLeaderboard(data) {
+ if (this.loading) {
+ return;
+ }
+
+ this.loading = true;
+
+ try {
+ const leaderboard = await ajax(
+ "/admin/plugins/gamification/leaderboard",
+ {
+ data,
+ type: "POST",
+ }
+ );
+ this.toasts.success({
+ duration: 3000,
+ data: {
+ message: i18n("gamification.leaderboard.create_success"),
+ },
+ });
+ this.args.onCancel();
+ this.router.transitionTo(
+ "adminPlugins.show.discourse-gamification-leaderboards.show",
+ leaderboard.id
+ );
+ } catch (err) {
+ popupAjaxError(err);
+ } finally {
+ this.loading = false;
+ }
+ }
+
+
+ | {{i18n "gamification.admin.name"}} | +{{i18n "gamification.admin.period"}} | ++ + + + {{#each @controller.sortedLeaderboards as |leaderboard|}} + |
|---|---|---|
|
+ |
+ + {{#if leaderboard.fromDate}} + {{formatDate + (@controller.parseDate leaderboard.fromDate) + }} + - + {{formatDate (@controller.parseDate leaderboard.toDate)}} + {{else}} + {{leaderboard.defaultPeriod}} + {{/if}} + | +
+
+
+ |
+
{{this.model.reason}}
+