Skip to content

Commit

Permalink
deploy: e798989
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 9, 2024
1 parent fb933e5 commit 4d44ee8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
22 changes: 21 additions & 1 deletion mjs/dtos.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Options:
Date: 2024-05-05 17:08:25
Date: 2024-05-09 12:12:17
Version: 8.23
Tip: To override a DTO option, remove "//" prefix before updating
BaseUrl: https://localhost:5001
Expand Down Expand Up @@ -1541,6 +1541,15 @@ export class CalculateLeaderBoard {
getMethod() { return 'GET' }
createResponse() { return new CalculateLeaderboardResponse() }
}
export class CalculateTop1KLeaderboard {
/** @param {{modelsToExclude?:string}} [init] */
constructor(init) { Object.assign(this, init) }
/** @type {?string} */
modelsToExclude;
getTypeName() { return 'CalculateTop1KLeaderboard' }
getMethod() { return 'GET' }
createResponse() { return new CalculateLeaderboardResponse() }
}
export class GetLeaderboardStatsByTag {
/** @param {{tag?:string,modelsToExclude?:string}} [init] */
constructor(init) { Object.assign(this, init) }
Expand Down Expand Up @@ -1581,6 +1590,17 @@ export class DeleteQuestion {
getMethod() { return 'GET' }
createResponse() { return new EmptyResponse() }
}
export class DeleteAnswer {
/** @param {{id?:string,returnUrl?:string}} [init] */
constructor(init) { Object.assign(this, init) }
/** @type {string} */
id;
/** @type {?string} */
returnUrl;
getTypeName() { return 'DeleteAnswer' }
getMethod() { return 'GET' }
createResponse() { return new EmptyResponse() }
}
export class AnswerQuestion {
/** @param {{postId?:number,body?:string,refId?:string,refUrn?:string}} [init] */
constructor(init) { Object.assign(this, init) }
Expand Down
33 changes: 31 additions & 2 deletions mjs/question.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { renderMarkdown } from "markdown"
import {
UserPostData, PostVote, GetQuestionFile,
AnswerQuestion, UpdateQuestion, PreviewMarkdown, GetAnswerBody, CreateComment, GetMeta,
DeleteQuestion, DeleteComment, GetUserReputations, CommentVote,
DeleteQuestion, DeleteAnswer, DeleteComment, GetUserReputations, CommentVote,
ShareContent, FlagContent, GetAnswer,
WaitForUpdate, GetLastUpdated,
} from "dtos.mjs"
Expand Down Expand Up @@ -436,6 +436,29 @@ const QuestionAside = {
}
}

const AnswerAside = {
template:`
<div v-if="isModerator" class="mt-2 flex justify-center">
<svg class="mr-1 align-sub text-gray-400 hover:text-gray-500 w-6 h-6 inline-block cursor-pointer" @click="deleteAnswer" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><title>Delete question</title><g fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="4"><path d="M9 10v34h30V10z"/><path stroke-linecap="round" d="M20 20v13m8-13v13M4 10h40"/><path d="m16 10l3.289-6h9.488L32 10z"/></g></svg>
</div>
`,
props:['id'],
setup(props) {
const { hasRole } = useAuth()
const isModerator = hasRole('Moderator')
const client = useClient()
async function deleteAnswer() {
if (confirm('Are you sure?')) {
const api = await client.api(new DeleteAnswer({ id:props.id }))
if (api.succeeded) {
location.href = location.href
}
}
}
return { deleteAnswer, isModerator }
}
}

const Comments = {
template:`
<div v-if="editing" class="mt-4 pb-1 flex w-full">
Expand Down Expand Up @@ -1067,6 +1090,7 @@ async function loadEditAnswers(ctx) {
edit = el.querySelector('.edit'),
preview = el.querySelector('.preview'),
previewHtml = preview?.innerHTML,
answerAside = el.querySelector('.answer-aside'),
footer = el.querySelector('.answer-footer')

const bus = new EventBus()
Expand All @@ -1080,7 +1104,12 @@ async function loadEditAnswers(ctx) {
footer.innerHTML = ''
}
} else {
console.warn(`could not find .edit'`)
console.warn(`could not find .edit'`, el)
}
if (answerAside) {
mount(answerAside, AnswerAside, { id })
} else {
console.warn(`could not find .answer-aside'`, el)
}
})
}
Expand Down

0 comments on commit 4d44ee8

Please sign in to comment.