Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wiki page content title and overview numbering #357

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
674992a
#1 cleaned up the branch and implmented numbering to overview and con…
vidhyasagargm Sep 12, 2024
90d7840
Update widgets/PageListItemTitle.php
vidhyasagargm Sep 18, 2024
e591a41
Delete widgets/.WikiRichText.php.swp
vidhyasagargm Sep 18, 2024
59ee21d
added unit testing for numbering logic
vidhyasagargm Sep 18, 2024
b1e21c5
Merge branch '1-content-overview-title-numbering' of https://github.c…
vidhyasagargm Sep 18, 2024
0dc8f5d
Revert "Merge branch '1-content-overview-title-numbering' of https://…
vidhyasagargm Sep 18, 2024
3d1df8b
#1 Toggle button for numbering pagelist with unit testing
vidhyasagargm Sep 18, 2024
b1c56d5
#1 Fixed double numbering in content and added a button
vidhyasagargm Sep 20, 2024
7dd22b1
#1 Fixed double numbering in content and added a button
vidhyasagargm Sep 20, 2024
531d360
Delete widgets/.WikiRichText.php.swp
vidhyasagargm Sep 20, 2024
c9e2ba4
#1 Implemented German Language for button content
vidhyasagargm Sep 25, 2024
ffeb277
Update _view_body.php
vidhyasagargm Sep 25, 2024
f886205
Update _view_content.php
vidhyasagargm Sep 25, 2024
855c04c
Update _view_content.php
vidhyasagargm Sep 25, 2024
e1979a5
#1 toggle for numbering fixed appearance on edit page
vidhyasagargm Oct 1, 2024
6d93c5e
Update _view_body.php
vidhyasagargm Oct 1, 2024
f17a7ad
Restore menu.php
vidhyasagargm Oct 1, 2024
add39f1
Update widgets/PageListItemTitle.php
vidhyasagargm Oct 2, 2024
b14519e
Update widgets/PageListItemTitle.php
vidhyasagargm Oct 2, 2024
6dc658c
#1 Added CSS styling to css file and changed naming convention
vidhyasagargm Oct 4, 2024
1a67e0f
#1 changed the test case with html render
vidhyasagargm Oct 4, 2024
b9492e5
#1 implemented preserve settings
vidhyasagargm Oct 9, 2024
733b08d
#1 Matched numbering with TOC
vidhyasagargm Oct 17, 2024
fbe27ec
#1 used grunt build to generate min and less files
vidhyasagargm Oct 21, 2024
3f11786
#1 changed all the test files added a functional testing
vidhyasagargm Oct 21, 2024
9c1fb5e
#1 Added Numbering Setting Checkmark in wiki/config
vidhyasagargm Oct 22, 2024
5f5ea4a
Update DefaultSettings.php
vidhyasagargm Oct 22, 2024
c45de85
Update PageController.php
vidhyasagargm Oct 22, 2024
8ae5bfd
Update ConfigForm.php
vidhyasagargm Oct 22, 2024
7d652ad
Update messages/de/base.php
vidhyasagargm Oct 24, 2024
d788aff
Update resources/css/humhub.wiki.less
vidhyasagargm Oct 24, 2024
9ec7b1a
Update resources/css/humhub.wiki.css
vidhyasagargm Oct 24, 2024
6e8442b
Update resources/js/humhub.wiki.Page.js
vidhyasagargm Oct 24, 2024
ef94b75
Update resources/js/humhub.wiki.bundle.js
vidhyasagargm Oct 24, 2024
1b4162d
Update resources/js/humhub.wiki.Page.js
vidhyasagargm Oct 24, 2024
96d04a3
#1 updated code to show numbering on wiki/config
vidhyasagargm Oct 24, 2024
0cc7113
#1 removed min file
vidhyasagargm Oct 24, 2024
bec369f
#1 Added translation to the config page
vidhyasagargm Nov 1, 2024
b22ead0
#1 Changed button content of config form
vidhyasagargm Nov 6, 2024
c70fbad
#1 Added partial reload after sorting and removed unwanted comment
vidhyasagargm Nov 8, 2024
f7deb4c
#1 added condition for partial reload
vidhyasagargm Nov 11, 2024
6f561a4
#1 removed numbering button, created a new test file
vidhyasagargm Dec 4, 2024
785e08f
#1 Numbering on path and title
vidhyasagargm Dec 10, 2024
68661bd
Deleted unwanted test file
vidhyasagargm Dec 10, 2024
d8d8820
#1 NUmbering toggle for title and path
vidhyasagargm Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#1 removed numbering button, created a new test file
vidhyasagargm committed Dec 4, 2024
commit 6f561a429c30e2ada2319c594ce2d5b599a72f96
7 changes: 0 additions & 7 deletions controllers/ContainerConfigController.php
Original file line number Diff line number Diff line change
@@ -39,13 +39,6 @@ public function actionIndex()
$this->view->saved();
}

$module = Yii::$app->getModule('wiki');
$user = Yii::$app->user->identity;
$defaultState = $module->settings->contentContainer($this->contentContainer)->get('wikiNumberingEnabled');
$module->settings->contentContainer($user)->set('wikiNumberingEnabled', $defaultState);
$defaultState = $module->settings->contentContainer($this->contentContainer)->get('overviewNumberingEnabled');
$module->settings->contentContainer($user)->set('overviewNumberingEnabled', $defaultState);

return $this->render('@wiki/views/common/defaultConfig', [
'model' => $model,
]);
12 changes: 0 additions & 12 deletions controllers/OverviewController.php
Original file line number Diff line number Diff line change
@@ -112,16 +112,4 @@ public function actionUpdateFoldingState(int $categoryId, int $state)
{
$this->updateFoldingState($categoryId, $state);
}

public function actionToggleNumbering()
{
$module = Yii::$app->getModule('wiki');
$user = Yii::$app->user->identity;
$numberingEnabled = $module->settings->contentContainer($user)->get('overviewNumberingEnabled');

$newState = !$numberingEnabled;
$module->settings->contentContainer($user)->set('overviewNumberingEnabled', $newState);

return $this->redirect(Url::toOverview($this->contentContainer));
}
}
17 changes: 0 additions & 17 deletions controllers/PageController.php
Original file line number Diff line number Diff line change
@@ -439,22 +439,5 @@ protected function getAccessRules()
];
}

public function actionToggleNumbering(int $id)
{

$module = Yii::$app->getModule('wiki');
$user = Yii::$app->user->identity;
$numberingEnabled = $module->settings->contentContainer($user)->get('wikiNumberingEnabled');

$newState = !$numberingEnabled;
$module->settings->contentContainer($user)->set('wikiNumberingEnabled', $newState);

try {
$page = $this->getWikiPage($id);
return $this->redirect(Url::toWiki($page));
}
catch(Exception $e) {
return $this->redirect(Url::previous());
}
}
}
8 changes: 4 additions & 4 deletions messages/de/base.php
Original file line number Diff line number Diff line change
@@ -88,8 +88,8 @@
'No wiki pages found.' => '',
'Enable Numbering' => 'Nummerierung aktivieren',
'Disable Numbering' => 'Nummerierung deaktivieren',
'Enable Default wiki page numbering for all spaces' => 'Standard-Wikiseitennummerierung für alle Bereiche aktivieren',
'Enable Default overview numbering for all spaces' => 'Standard-übersichtsnummerierung für alle Bereiche aktivieren',
'Enable wiki page header numbering for all users by default' => 'Nummerierung der Überschriften standardmäßig für alle Benutzer aktivieren',
'Enable overview numbering for all users by default' => 'Nummerierung der Seitentitel für alle Benutzer standardmäßig aktivieren',
'Enable Default wiki page numbering for current spaces' => 'Standard-Wikiseitennummerierung für aktuelle Bereiche aktivieren',
'Enable Default overview numbering for current spaces' => 'Standard-übersichtsnummerierung für aktuelle Bereiche aktivieren',
'Enable wiki page header numbering for all spaces by default' => 'Nummerierung der Überschriften standardmäßig für alle Bereiche aktivieren',
'Enable overview numbering for all spaces by default' => 'Nummerierung der Seitentitel für alle Bereiche standardmäßig aktivieren',
];
4 changes: 2 additions & 2 deletions models/ConfigForm.php
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ public function attributeLabels()
{
return [
'hideNavigationEntryDefault' => Yii::t('WikiModule.base', 'Hide Navigation Entries of this module globally by default'),
'wikiNumberingEnabledDefault'=> Yii::t('WikiModule.base', 'Enable wiki page header numbering for all users by default'),
'overviewNumberingEnabledDefault'=> Yii::t('WikiModule.base', 'Enable overview numbering for all users by default'),
'wikiNumberingEnabledDefault'=> Yii::t('WikiModule.base', 'Enable wiki page header numbering for all spaces by default'),
'overviewNumberingEnabledDefault'=> Yii::t('WikiModule.base', 'Enable overview numbering for all spaces by default'),
];
}

4 changes: 2 additions & 2 deletions models/DefaultSettings.php
Original file line number Diff line number Diff line change
@@ -106,8 +106,8 @@ public function attributeLabels()
return [
'module_label' => Yii::t('WikiModule.base', 'Module name'),
'hideNavigationEntry' => Yii::t('WikiModule.base', 'Hide Navigation Entry'),
'wikiNumberingEnabled'=> Yii::t('WikiModule.base', 'Enable Default wiki page numbering for all spaces'),
'overviewNumberingEnabled'=> Yii::t('WikiModule.base', 'Enable Default overview numbering for all spaces'),
'wikiNumberingEnabled'=> Yii::t('WikiModule.base', 'Enable Default wiki page numbering for current spaces'),
'overviewNumberingEnabled'=> Yii::t('WikiModule.base', 'Enable Default overview numbering for current spaces'),
];
}
public function save(): bool
5 changes: 0 additions & 5 deletions resources/css/humhub.wiki.less
Original file line number Diff line number Diff line change
@@ -1056,8 +1056,3 @@
padding: 0;
}
}
/* CSS Styling for toggle button */
.toggle-numbering {
margin-left: auto;
padding-right: 10px;
}
2 changes: 1 addition & 1 deletion resources/js/humhub.wiki.CategoryListView.js
Original file line number Diff line number Diff line change
@@ -259,7 +259,7 @@ humhub.module('wiki.CategoryListView', function(module, require, $) {
$item.closest('.category_list_view, .wiki-page-list').sortable('cancel');
}
pageTitle.removeClass('wiki-page-dropped');
if(document.querySelector('.toggle-numbering').textContent.trim() === 'Disable Numbering'){
if(document.querySelector('.numbered') !== null){
client.reload();
}
}).catch(function (e) {
39 changes: 22 additions & 17 deletions tests/codeception/functional/NumberingButtonCest.php
Original file line number Diff line number Diff line change
@@ -14,30 +14,35 @@ class NumberingButtonCest
{
public function testNumberingButtonHtml(FunctionalTester $I)
{
$I->wantTo('check if the numbering button toggles between enabled and disabled states at page view');
$I->wantTo('check if the numbering toggles between enabled and disabled');
$space = $I->loginBySpaceUserGroup(Space::USERGROUP_MEMBER);
$I->amAdmin(true);
$I->enableModule($space->guid, 'wiki');
$category = $I->createWiki($space, 'Test Wiki Page', 'Test Wiki Page content');

$I->amOnSpace($space->guid, '/wiki/page/view', ['id' => $category->id, 'title' => $category->title]);

$I->seeElement('a.toggle-numbering');
$I->see('Enable Numbering', 'a.toggle-numbering');
$I->click('a.toggle-numbering');
$I->see('Disable Numbering', 'a.toggle-numbering');
$I->click('a.toggle-numbering');
$I->see('Enable Numbering', 'a.toggle-numbering');

$I->wantTo('check if the numbering button toggles between enabled and disabled states at overview');
$I->amOnSpace($space->guid, '/wiki/container-config', ['id' => $category->id]);
$I->seeElement('input#defaultsettings-wikinumberingenabled');
$I->checkOption('input#defaultsettings-wikinumberingenabled');
$I->seeElement('input#defaultsettings-overviewnumberingenabled');
$I->checkOption('input#defaultsettings-overviewnumberingenabled');
$I->click('Save', 'button');

$I->amOnSpace($space->guid, '/wiki/overview/list-categories');
$I->seeElement('div.numbered');
$I->amOnSpace($space->guid, '/wiki/page/view', ['id' => $category->id, 'title'=> $category->title]);
$I->seeElement('div.numbered');

$I->amOnSpace($space->guid, '/wiki/container-config', ['id' => $category->id]);
$I->seeElement('input#defaultsettings-wikinumberingenabled');
$I->uncheckOption('input#defaultsettings-wikinumberingenabled');
$I->seeElement('input#defaultsettings-overviewnumberingenabled');
$I->uncheckOption('input#defaultsettings-overviewnumberingenabled');
$I->click('Save', 'button');

$I->amOnSpace($space->guid, '/wiki/overview/list-categories');
$I->dontSeeElement('div.numbered');
$I->amOnSpace($space->guid, '/wiki/page/view', ['id' => $category->id, 'title'=> $category->title]);
$I->dontSeeElement('div.numbered');

$I->seeElement('a.toggle-numbering');
$I->see('Enable Numbering', 'a.toggle-numbering');
$I->click('a.toggle-numbering');
$I->see('Disable Numbering', 'a.toggle-numbering');
$I->click('a.toggle-numbering');
$I->see('Enable Numbering', 'a.toggle-numbering');
}
}
12 changes: 3 additions & 9 deletions views/overview/list-categories.php
Original file line number Diff line number Diff line change
@@ -29,8 +29,10 @@
}

$settings = new DefaultSettings(['contentContainer' => $contentContainer]);
$module = Yii::$app->getModule('wiki');
$numberingEnabled = $module->settings->space()->get('overviewNumberingEnabled');
?>
<div class="panel panel-default">
<div class="panel panel-default <?php if($numberingEnabled) echo 'numbered';?>">
<div class="panel-body">
<div class="row">
<?php WikiContent::begin(['cssClass' => 'wiki-page-content']) ?>
@@ -40,14 +42,6 @@
<div class="wiki-page-content-header-actions">
<?= Button::info(Yii::t('WikiModule.base', 'Last edited'))->sm()->link(Url::toLastEdited($contentContainer))->cssClass(Helper::isEnterpriseTheme() ? 'hidden-lg' : '') ?>
<?= Button::info($createPageTitle)->icon('fa-plus')->sm()->link(Url::toWikiCreate($contentContainer))->visible($canCreate) ?>
<?php
$module = Yii::$app->getModule('wiki');
$user = Yii::$app->user->identity;
$numberingEnabled = $module->settings->contentContainer($user)->get('overviewNumberingEnabled');
?>
<a href="<?= Url::current(['toggle-numbering']) ?>" class="btn btn-info btn-sm toggle-numbering">
<?= $numberingEnabled ? Yii::t('WikiModule.base', 'Disable Numbering') : Yii::t('WikiModule.base', 'Enable Numbering') ?>
</a>
</div>
<div class="clearfix"></div>
</div>
9 changes: 2 additions & 7 deletions views/page/_view_body.php
Original file line number Diff line number Diff line change
@@ -20,13 +20,8 @@
/* @var $canEdit bool */

Assets::register($this);

// Get the current module
$module = Yii::$app->getModule('wiki');
// Get the current user
$user = Yii::$app->user->identity;
// Retrieve the current numbering state for this user from the settings
$numberingEnabled = $module->settings->contentContainer($user)->get('wikiNumberingEnabled');
$module = Yii::$app->getModule('wiki');
$numberingEnabled = $module->settings->space()->get('wikiNumberingEnabled');
?>
<?= $this->render('_view_header', ['page' => $page, 'revision' => $revision, 'displayTitle' => false]) ?>

13 changes: 0 additions & 13 deletions views/page/_view_header.php
Original file line number Diff line number Diff line change
@@ -18,24 +18,11 @@
if (empty($buttons)) {
$buttons = WikiMenu::LINK_EDIT;
}

// Get the current module
$module = Yii::$app->getModule('wiki');
// Get the current user
$user = Yii::$app->user->identity;
// Retrieve the current numbering state for this user from the settings
$numberingEnabled = $module->settings->contentContainer($user)->get('wikiNumberingEnabled');
?>

<div class="wiki-headline">
<div class="wiki-headline-top">
<?= WikiPath::widget(['page' => $page]) ?>
<div class="toggle-numbering">
<!-- Add toggle switch with URL-based parameter for numbering-->
<a href="<?= Url::current(['toggle-numbering']) ?>" class="btn-sm btn btn-info toggle-numbering">
<?= $numberingEnabled ? Yii::t('WikiModule.base', 'Disable Numbering') : Yii::t('WikiModule.base', 'Enable Numbering') ?>
</a>
</div>
<?= WikiMenu::widget([
'object' => $page,
'buttons' => $buttons,
7 changes: 1 addition & 6 deletions widgets/PageListItemTitle.php
Original file line number Diff line number Diff line change
@@ -90,14 +90,9 @@ public function run()
$this->titleInfo = Yii::t('WikiModule.base', '({n,plural,=1{+1 subpage}other{+{count} subpages}})', ['n' => $this->page->childrenCount, 'count' => $this->page->childrenCount]);
}

// Get the current module
$module = Yii::$app->getModule('wiki');
// Get the current user
$user = Yii::$app->user->identity;
// Retrieve the current numbering state for this user from the settings
$numberingEnabled = $module->settings->contentContainer($user)->get('overviewNumberingEnabled');
$numberingEnabled = $module->settings->space()->get('overviewNumberingEnabled');

// Generate numbering for categories and pages
return $this->render('pageListItemTitle', [
'page' => $this->page,
'title' => $numberingEnabled ? ($this->generateNumbering($this->level) . ' ' . $this->title) : $this->title,