implement hints
This commit is contained in:
parent
1b99440d70
commit
166dd37359
7 changed files with 21 additions and 8 deletions
|
@ -123,12 +123,14 @@ export default class AdminController_Auth$Admin extends Controller {
|
|||
if (typeof(adminBadgeViewModel.id) !== "undefined" && badge) {
|
||||
adminBadgeViewModel.name = badge.Name;
|
||||
adminBadgeViewModel.description = badge.Description;
|
||||
adminBadgeViewModel.hint = badge.Hint;
|
||||
adminBadgeViewModel.imageUrl = badge.ImageUrl;
|
||||
adminBadgeViewModel.forUrl = badge.ForUrl;
|
||||
adminBadgeViewModel.isSecret = badge.IsSecret;
|
||||
} else {
|
||||
adminBadgeViewModel.name = "";
|
||||
adminBadgeViewModel.description = "";
|
||||
adminBadgeViewModel.hint = "";
|
||||
adminBadgeViewModel.imageUrl = "";
|
||||
adminBadgeViewModel.forUrl = "";
|
||||
adminBadgeViewModel.isSecret = false;
|
||||
|
@ -142,7 +144,7 @@ export default class AdminController_Auth$Admin extends Controller {
|
|||
return this.badRequest();
|
||||
}
|
||||
|
||||
await BadgeService.SaveBadge(this.session.userId, parseInt(adminBadgeViewModel.id), adminBadgeViewModel.name ?? "", adminBadgeViewModel.description ?? "", adminBadgeViewModel.imageUrl ?? "", adminBadgeViewModel.forUrl ?? "", (adminBadgeViewModel.isSecret?.toString() ?? "") === "on");
|
||||
await BadgeService.SaveBadge(this.session.userId, parseInt(adminBadgeViewModel.id), adminBadgeViewModel.name ?? "", adminBadgeViewModel.description ?? "", adminBadgeViewModel.hint ?? "", adminBadgeViewModel.imageUrl ?? "", adminBadgeViewModel.forUrl ?? "", (adminBadgeViewModel.isSecret?.toString() ?? "") === "on");
|
||||
|
||||
return this.redirectToAction("badges");
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ export default class Badge {
|
|||
public Id: number;
|
||||
public Name: string;
|
||||
public Description: string;
|
||||
public Hint: string;
|
||||
public ImageUrl: string;
|
||||
public ForUrl: string;
|
||||
public IsSecret: boolean;
|
||||
|
@ -17,6 +18,7 @@ export default class Badge {
|
|||
this.Id = Number.MIN_VALUE;
|
||||
this.Name = "";
|
||||
this.Description = "";
|
||||
this.Hint = "";
|
||||
this.ImageUrl = "";
|
||||
this.ForUrl = "";
|
||||
this.IsSecret = false;
|
||||
|
|
|
@ -2,6 +2,7 @@ export default interface AdminBadgeViewModel {
|
|||
id?: string,
|
||||
name?: string,
|
||||
description?: string,
|
||||
hint?: string,
|
||||
imageUrl?: string,
|
||||
forUrl?: string,
|
||||
isSecret?: boolean
|
||||
|
|
|
@ -48,12 +48,12 @@ export default abstract class BadgeRepo {
|
|||
|
||||
public static async insertUpdate(badge:Badge) {
|
||||
if (badge.Id === Number.MIN_VALUE) {
|
||||
badge.Id = (await Database.Instance.query("INSERT Badge (Name, Description, ImageUrl, ForUrl, IsSecret, CreatedByUserId, CreatedDatetime, LastModifiedByUserId, LastModifiedDatetime, DeletedByUserId, DeletedDatetime, IsDeleted) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING Id;", [
|
||||
badge.Name, badge.Description, badge.ImageUrl, badge.ForUrl, Number(badge.IsSecret), badge.CreatedByUserId, badge.CreatedDatetime.getTime(), badge.LastModifiedByUserId ?? null, badge.LastModifiedDatetime?.getTime() ?? null, badge.DeletedByUserId ?? null, badge.DeletedDatetime?.getTime() ?? null, Number(badge.IsDeleted)
|
||||
badge.Id = (await Database.Instance.query("INSERT Badge (Name, Description, Hint, ImageUrl, ForUrl, IsSecret, CreatedByUserId, CreatedDatetime, LastModifiedByUserId, LastModifiedDatetime, DeletedByUserId, DeletedDatetime, IsDeleted) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING Id;", [
|
||||
badge.Name, badge.Description, badge.Hint, badge.ImageUrl, badge.ForUrl, Number(badge.IsSecret), badge.CreatedByUserId, badge.CreatedDatetime.getTime(), badge.LastModifiedByUserId ?? null, badge.LastModifiedDatetime?.getTime() ?? null, badge.DeletedByUserId ?? null, badge.DeletedDatetime?.getTime() ?? null, Number(badge.IsDeleted)
|
||||
]))[0]["Id"];
|
||||
} else {
|
||||
await Database.Instance.query(`UPDATE Badge SET Name = ?, Description = ?, ImageUrl = ?, ForUrl = ?, IsSecret = ?, CreatedByUserId = ?, CreatedDatetime = ?, LastModifiedByUserId = ?, LastModifiedDatetime = ?, DeletedByUserId = ?, DeletedDatetime = ?, IsDeleted = ? WHERE Id = ?`, [
|
||||
badge.Name, badge.Description, badge.ImageUrl, badge.ForUrl, Number(badge.IsSecret), badge.CreatedByUserId, badge.CreatedDatetime.getTime(), badge.LastModifiedByUserId ?? null, badge.LastModifiedDatetime?.getTime() ?? null, badge.DeletedByUserId ?? null, badge.DeletedDatetime?.getTime() ?? null, Number(badge.IsDeleted), badge.Id
|
||||
await Database.Instance.query(`UPDATE Badge SET Name = ?, Description = ?, Hint = ?, ImageUrl = ?, ForUrl = ?, IsSecret = ?, CreatedByUserId = ?, CreatedDatetime = ?, LastModifiedByUserId = ?, LastModifiedDatetime = ?, DeletedByUserId = ?, DeletedDatetime = ?, IsDeleted = ? WHERE Id = ?`, [
|
||||
badge.Name, badge.Description, badge.Hint, badge.ImageUrl, badge.ForUrl, Number(badge.IsSecret), badge.CreatedByUserId, badge.CreatedDatetime.getTime(), badge.LastModifiedByUserId ?? null, badge.LastModifiedDatetime?.getTime() ?? null, badge.DeletedByUserId ?? null, badge.DeletedDatetime?.getTime() ?? null, Number(badge.IsDeleted), badge.Id
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ function populateBadgeFromDB(badge:Badge, dbBadge:any) {
|
|||
badge.Id = dbBadge.Id;
|
||||
badge.Name = dbBadge.Name;
|
||||
badge.Description = dbBadge.Description;
|
||||
badge.Hint = dbBadge.Hint;
|
||||
badge.ImageUrl = dbBadge.ImageUrl;
|
||||
badge.ForUrl = dbBadge.ForUrl;
|
||||
badge.IsSecret = dbBadge.IsSecret[0] === 1;
|
||||
|
|
|
@ -5,7 +5,7 @@ import BadgeCache from "../objects/BadgeCache";
|
|||
import UserBadgeRepo from "../repos/UserBadgeRepo";
|
||||
|
||||
export default abstract class BadgeService {
|
||||
public static async SaveBadge(currentUserId:number, id:number | undefined, name:string, description:string, imageUrl: string, forUrl:string, isSecret: boolean) {
|
||||
public static async SaveBadge(currentUserId:number, id:number | undefined, name:string, description:string, hint: string, imageUrl: string, forUrl:string, isSecret: boolean) {
|
||||
try {
|
||||
let badge = id ? await BadgeRepo.selectById(id) : null;
|
||||
if (badge === null) {
|
||||
|
@ -19,6 +19,7 @@ export default abstract class BadgeService {
|
|||
|
||||
badge.Name = name;
|
||||
badge.Description = description;
|
||||
badge.Hint = hint;
|
||||
badge.ImageUrl = imageUrl;
|
||||
badge.ForUrl = forUrl;
|
||||
badge.IsSecret = isSecret;
|
||||
|
|
|
@ -30,7 +30,13 @@
|
|||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<label for="description" class="form-label">Description</label>
|
||||
<textarea class="form-control" name="description" required><%= typeof(description) === "undefined" ? "" : description %></textarea>
|
||||
<textarea class="form-control" id="description" name="description" required><%= typeof(description) === "undefined" ? "" : description %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<label for="hint" class="form-label">Hint</label>
|
||||
<textarea class="form-control" id="hint" name="hint" required><%= typeof(hint) === "undefined" ? "" : hint %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<img width="32" height="32" src="<%= badge.ImageUrl %>">
|
||||
</span>
|
||||
<% } else if (!badge.IsSecret) { %>
|
||||
<span class="d-inline-block mb-3" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="top" data-bs-title="???">
|
||||
<span class="d-inline-block mb-3" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-placement="top" data-bs-title="???" data-bs-content="<%= badge.Hint %>">
|
||||
<img src="https://eusv.net/Mu6LedXkxrZDUB">
|
||||
</span>
|
||||
<% } %>
|
||||
|
|
Loading…
Reference in a new issue