1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-11-24 20:02:35 +01:00

Set comment add box to show with correct permissions

- Also fixed const assignment issue in translations.js
This commit is contained in:
Dan Brown 2019-08-25 11:02:58 +01:00
parent 88e076a12a
commit 4bf77f67dd
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 12 additions and 11 deletions

View File

@ -52,9 +52,7 @@ class Translator {
const rangeRegex = /^\[([0-9]+),([0-9*]+)]/; const rangeRegex = /^\[([0-9]+),([0-9*]+)]/;
let result = null; let result = null;
for (const i = 0, len = splitText.length; i < len; i++) { for (let t of splitText) {
const t = splitText[i];
// Parse exact matches // Parse exact matches
const exactMatches = t.match(exactCountRegex); const exactMatches = t.match(exactCountRegex);
if (exactMatches !== null && Number(exactMatches[1]) === count) { if (exactMatches !== null && Number(exactMatches[1]) === count) {
@ -77,7 +75,10 @@ class Translator {
result = (count === 1) ? splitText[0] : splitText[1]; result = (count === 1) ? splitText[0] : splitText[1];
} }
if (result === null) result = splitText[0]; if (result === null) {
result = splitText[0];
}
return this.performReplacements(result, replacements); return this.performReplacements(result, replacements);
} }

View File

@ -9,7 +9,7 @@
<div comment-count-bar class="grid half left-focus v-center no-row-gap"> <div comment-count-bar class="grid half left-focus v-center no-row-gap">
<h5 comments-title>{{ trans_choice('entities.comment_count', count($page->comments), ['count' => count($page->comments)]) }}</h5> <h5 comments-title>{{ trans_choice('entities.comment_count', count($page->comments), ['count' => count($page->comments)]) }}</h5>
@if (count($page->comments) === 0) @if (count($page->comments) === 0 && userCan('comment-create-all'))
<div class="text-m-right" comment-add-button-container> <div class="text-m-right" comment-add-button-container>
<button type="button" action="addComment" <button type="button" action="addComment"
class="button outline">{{ trans('entities.comment_add') }}</button> class="button outline">{{ trans('entities.comment_add') }}</button>
@ -25,13 +25,13 @@
@if(userCan('comment-create-all')) @if(userCan('comment-create-all'))
@include('comments.create') @include('comments.create')
@endif
@if (count($page->comments) > 0) @if (count($page->comments) > 0)
<div class="text-right" comment-add-button-container> <div class="text-right" comment-add-button-container>
<button type="button" action="addComment" <button type="button" action="addComment"
class="button outline">{{ trans('entities.comment_add') }}</button> class="button outline">{{ trans('entities.comment_add') }}</button>
</div> </div>
@endif
@endif @endif
</div> </div>