Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Commit 993e3dd

Browse files
David Tischmacherptsavdar
David Tischmacher
authored andcommitted
[WikiBundle] Fix for anonymous wiki access and display (#1979)
* [WikiBundle] Adding hyphen between chapter title and number * [WikiBundle] Fixing anonymous access to wiki page * [WikiBundle] Scroll to top of newly added or modified section after save
1 parent 9ff7b9e commit 993e3dd

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

plugin/wiki/Repository/SectionRepository.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function buildSectionTree(Wiki $wiki, $isAdmin, User $user = null)
3030
$queryBuilder->expr()->isNull('section.deleted')
3131
)
3232
)->setParameter('deleted', false);
33-
if ($isAdmin === false) {
33+
if ($isAdmin === false && $user !== null) {
3434
$queryBuilder
3535
->andWhere(
3636
$queryBuilder->expr()->orX(
@@ -39,6 +39,11 @@ public function buildSectionTree(Wiki $wiki, $isAdmin, User $user = null)
3939
)
4040
)->setParameter('visible', true)->setParameter('userId', $user->getId());
4141
}
42+
if ($isAdmin === false && $user === null) {
43+
$queryBuilder
44+
->andWhere('section.visible = :visible')
45+
->setParameter('visible', true);
46+
}
4247
$options = ['decorate' => false];
4348
$tree = $this->buildTree($queryBuilder->getQuery()->getArrayResult(), $options);
4449

plugin/wiki/Resources/modules/wiki/wiki.controller.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -243,26 +243,30 @@ export default class WikiController {
243243

244244
_saveSectionWithNewContribution(section, newContrib, updatedSection) {
245245
this.wiki.editSection(section, newContrib, updatedSection).then(
246-
() => {
246+
success => {
247247
if (newContrib.id === 0) {
248248
this._setMessage('success', 'icap_wiki_section_add_success')
249249
} else {
250250
this._setMessage('success', 'icap_wiki_section_update_success')
251251
}
252+
_$location.get(this).hash(`sect-${success.section.id}`)
252253
},
253254
() => {
254255
if (newContrib.id === 0) {
255256
this._setMessage('danger', 'icap_wiki_section_add_error')
256257
} else {
257258
this._setMessage('danger', 'icap_wiki_section_update_error')
258259
}
260+
_$location.get(this).hash('top')
259261
}
260262
).finally(
261263
() => {
262264
this.currentContributions = []
263265
this.currentSections = []
264266
this.disableFormButtons = false
265267
this.isFormOpen = false
268+
269+
_$anchorScroll.get(this)()
266270
}
267271
)
268272
}
@@ -280,6 +284,9 @@ export default class WikiController {
280284
).finally(() => {
281285
this.disableFormButtons = false
282286
this.isFormOpen = false
287+
288+
_$location.get(this).hash(`sect-${section.id}`)
289+
_$anchorScroll.get(this)()
283290
})
284291
}
285292

plugin/wiki/Resources/public/css/style.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ul#wiki-contents-list li.invisible-wiki-content a,
7777
ol#wiki-contents-list li.invisible-wiki-content a { color:#999; }
7878
ol#wiki-contents-list, ol#wiki-contents-list ol { list-style-type:none; counter-reset: item; }
7979
ol#wiki-contents-list li { counter-increment: item; }
80-
ol#wiki-contents-list li a:before { content: counters(item, "."); }
80+
ol#wiki-contents-list li a:before { content: counters(item, ".") " - "; }
8181

8282

8383
/*Wiki sections*/
@@ -112,7 +112,7 @@ div.wiki-sections ol#wiki-sections-list ol.wiki-sections-list-elem>li.with-numbe
112112
div.wiki-sections ol#wiki-sections-list ol.wiki-sections-list-elem>li.with-numbers h4::before,
113113
div.wiki-sections ol#wiki-sections-list ol.wiki-sections-list-elem>li.with-numbers h5::before,
114114
div.wiki-sections ol#wiki-sections-list ol.wiki-sections-list-elem>li.with-numbers h6::before
115-
{ content: counters(section, "."); }
115+
{ content: counters(section, ".") " - "; }
116116

117117
/*Delete section form*/
118118
.icap-wiki-delete-section-message {margin: 10px 0 20px 0; font-size: 16px;}

plugin/wiki/Resources/views/Wiki/view.html.twig

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<script type="text/javascript">
3434
angular.module('WikiModule').value('wiki', {
35-
activeUserId: {{ user is not empty ? user.id : "'null'" }},
35+
activeUserId: {{ user is not empty ? user.id : 'null' }},
3636
id: {{ _resource.id }},
3737
title: "{{ _resource.resourceNode.name }}",
3838
mode: {{ _resource.mode }},
@@ -42,7 +42,9 @@
4242
isPDFExportActive: {{ config.getParameter('is_pdf_export_active') == true ? 'true' : 'false' }},
4343
sections: {{ tree|json_encode(constant('JSON_PRETTY_PRINT'))|raw }},
4444
deletedSections: {{ deletedSections|json_encode(constant('JSON_PRETTY_PRINT'))|raw }},
45+
{% if user is not empty %}
4546
notificationButton: `{% render controller('IcapNotificationBundle:FollowerResource:renderForm', {'resourceId': _resource.resourceNode.id, 'resourceClass': _resource.resourceNode.class}) %}`
47+
{% endif %}
4648
});
4749
</script>
4850
{% endblock %}

0 commit comments

Comments
 (0)