-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrated open questions page to controller (#3257)
- Loading branch information
Showing
19 changed files
with
292 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Fetch data for open questions management | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* @package phpMyFAQ | ||
* @author Thorsten Rinne <[email protected]> | ||
* @copyright 2024 phpMyFAQ Team | ||
* @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 | ||
* @link https://www.phpmyfaq.de | ||
* @since 2024-12-02 | ||
*/ | ||
|
||
export const toggleQuestionVisibility = async (questionId, visibility, csrfToken) => { | ||
try { | ||
const response = await fetch(`./api/question/visibility/toggle`, { | ||
method: 'PUT', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
questionId: questionId, | ||
visibility: visibility, | ||
csrfToken: csrfToken, | ||
}), | ||
}); | ||
|
||
return await response.json(); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
140 changes: 71 additions & 69 deletions
140
phpmyfaq/assets/templates/admin/content/open-questions.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,80 @@ | ||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> | ||
<h1 class="h2"> | ||
<i aria-hidden="true" class="bi bi-question-circle"></i> | ||
{{ msgOpenQuestions }} | ||
</h1> | ||
</div> | ||
{% extends '@admin/index.twig' %} | ||
|
||
<div class="row"> | ||
<div class="col-lg-12"> | ||
{% block content %} | ||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> | ||
<h1 class="h2"> | ||
<i aria-hidden="true" class="bi bi-question-circle"></i> | ||
{{ msgOpenQuestions }} | ||
</h1> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-lg-12"> | ||
|
||
<div id="returnMessage"></div> | ||
<div id="returnMessage"></div> | ||
|
||
<form id="phpmyfaq-open-questions" name="phpmyfaq-open-questions" method="post" accept-charset="utf-8"> | ||
<input type="hidden" id="pmf-csrf-token" name="pmf-csrf-token" value="{{ csrfTokenDeleteQuestion }}"> | ||
<form id="phpmyfaq-open-questions" name="phpmyfaq-open-questions" method="post" accept-charset="utf-8"> | ||
<input type="hidden" id="pmf-csrf-token" name="pmf-csrf-token" value="{{ csrfTokenDeleteQuestion }}"> | ||
|
||
<table class="table table-striped align-middle border shadow"> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
<th>{{ msgAuthor }}</th> | ||
<th>{{ msgQuestion }}</th> | ||
<th colspan="2">{{ msgVisibility }}?</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for question in questions %} | ||
<table class="table table-striped align-middle border shadow"> | ||
<thead> | ||
<tr> | ||
<td> | ||
<label> | ||
<input id="questions[]" name="questions[]" value="{{ question.id }}" type="checkbox"> | ||
</label> | ||
</td> | ||
<td> | ||
{{ question.created | format_datetime(locale=currentLocale) }} | ||
<br> | ||
<a href="mailto:{{ question.email }}"> | ||
{{ question.username }} | ||
</a> | ||
</td> | ||
<td> | ||
<strong> | ||
{{ question.categoryId | categoryName }} | ||
</strong> | ||
<br> | ||
{{ question.question }} | ||
</td> | ||
<td> | ||
<a href="?action=question&id={{ question.id }}&is_visible=toggle&csrf={{ csrfTokenToggleVisibility }}" | ||
class="btn btn-info"> | ||
{{ question.isVisible == 'Y' ? yes : no }} | ||
</a> | ||
</td> | ||
<td> | ||
{% if enableCloseQuestion and question.answerId %} | ||
<a href="?action=editentry&id={{ question.answerId }}&lang={{ currentLocale }}" | ||
class="btn btn-success"> | ||
{{ msg2answerFAQ }} | ||
</a> | ||
{% else %} | ||
<a href="?action=takequestion&id={{ question.id }}" class="btn btn-success"> | ||
{{ msgTakeQuestion }} | ||
</a> | ||
{% endif %} | ||
</td> | ||
<th></th> | ||
<th>{{ msgAuthor }}</th> | ||
<th>{{ msgQuestion }}</th> | ||
<th colspan="2">{{ msgVisibility }}?</th> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</thead> | ||
<tbody> | ||
{% for question in questions %} | ||
<tr> | ||
<td> | ||
<label> | ||
<input id="questions[]" name="questions[]" value="{{ question.id }}" type="checkbox"> | ||
</label> | ||
</td> | ||
<td> | ||
{{ question.created | format_datetime(locale=currentLocale) }} | ||
<br> | ||
<a href="mailto:{{ question.email }}"> | ||
{{ question.username }} | ||
</a> | ||
</td> | ||
<td> | ||
<h6>{{ question.categoryId | categoryName }}</h6> | ||
{{ question.question }} | ||
</td> | ||
<td> | ||
<button type="button" class="btn btn-info pmf-toggle-visibility" | ||
data-pmf-visibility="{{ question.isVisible == 'Y' ? 'no' : 'yes' }}" | ||
data-pmf-question-id="{{ question.id }}" data-pmf-csrf="{{ csrfTokenToggleVisibility }}"> | ||
{{ question.isVisible == 'Y' ? yes : no }} | ||
</button> | ||
</td> | ||
<td> | ||
{% if enableCloseQuestion and question.answerId %} | ||
<a href="./faq/edit/{{ question.answerId }}/{{ currentLocale }}" | ||
class="btn btn-success"> | ||
{{ msg2answerFAQ }} | ||
</a> | ||
{% else %} | ||
<a href="./faq/add/{{ question.id }}" class="btn btn-success"> | ||
{{ msgTakeQuestion }} | ||
</a> | ||
{% endif %} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
<div class="text-end"> | ||
<button class="btn btn-danger" id="pmf-delete-questions" type="button"> | ||
{{ msgDeleteAllOpenQuestions }} | ||
</button> | ||
</div> | ||
<div class="text-end my-4"> | ||
<button class="btn btn-danger" id="pmf-delete-questions" type="button"> | ||
{{ msgDeleteAllOpenQuestions }} | ||
</button> | ||
</div> | ||
|
||
</form> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.