Skip to content

Commit

Permalink
Refactor module manager
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Sep 19, 2024
1 parent cfe4539 commit 32e8ff5
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 50 deletions.
3 changes: 1 addition & 2 deletions app/Domain/Canvas/Templates/element.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ class="delete"
</ul>
</div>
<div class="pull-right" style="margin-right:10px;">
<a href="#/<?=$canvasName ?>canvas/editCanvasComment/<?=$row['id'] ?>"
class="commentCountLink" data="item_<?=$row['id'] ?>"> <span class="fas fa-comments"></span></a> <small><?=$nbcomments ?></small>
<span class="fas fa-comments"></span> <small><?=$nbcomments ?></small>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class="deleteComment formModal">

<script type='text/javascript'>

leantime.editorController.initSimpleEditor();
jQuery(document).ready(function() {
leantime.editorController.initSimpleEditor();
});

function toggleCommentBoxes(id, commentId, formHash,editComment = false, isReply = false) {
<?php if ($login::userIsAtLeast($roles::$commenter)) { ?>
Expand Down
12 changes: 5 additions & 7 deletions app/Domain/Goalcanvas/Templates/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@
</div>

<div class="right" style="margin-right:10px;">
<a href="{{ BASE_URL }}/goalcanvas/editCanvasComment/{{ $row['id'] }}" class="goalCanvasModal" data="item_{{ $row['id'] }}" @if($nbcomments == 0) style="color: grey;" @endif>
<span class="fas fa-comments"></span>
</a>
<span class="fas fa-comments"></span>
<small>{{ $nbcomments }}</small>
</div>
</div>
Expand Down Expand Up @@ -298,7 +296,7 @@



{{--
{{--
* showCanvasBottom.blade.php template - Bottom part of the main canvas page
*
* Required variables:
Expand All @@ -315,7 +313,7 @@
</div>
<h3>{{ __("headlines.goal.analysis") }}</h3>
<br>{!! __("text.goal.helper_content") !!}

@if ($login::userIsAtLeast($roles::$editor))
<br><br>
<a href='javascript:void(0)' class='addCanvasLink btn btn-primary'>
Expand Down Expand Up @@ -355,7 +353,7 @@
@if (isset($_GET['showModal']))
@php
$modalUrl = $_GET['showModal'] == ""
$modalUrl = $_GET['showModal'] == ""
? "&type=" . array_key_first($canvasTypes)
: "/" . (int)$_GET['showModal'];
@endphp
Expand All @@ -365,4 +363,4 @@
});
</script>

@endsection
@endsection
12 changes: 7 additions & 5 deletions app/Domain/Menu/Repositories/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ public function getMenuStructure(string $menuType = ''): array
$menuType = self::DEFAULT_MENU;
}

$this->menuStructures = self::dispatch_filter(
'menuStructures',
$this->menuStructures,
['menuType' => $menuType]
);

//If menu structure cannot be found, don't return anything
if(! isset($this->menuStructures[$menuType])) {
return [];
Expand All @@ -279,11 +285,7 @@ public function getMenuStructure(string $menuType = ''): array
['menuType' => $menuType]
);

$this->menuStructures = self::dispatch_filter(
'menuStructures',
$menuCollection,
['menuType' => $menuType]
);


$menuStructure = $this->menuStructures[$menuType];

Expand Down
21 changes: 2 additions & 19 deletions app/Domain/Modulemanager/Services/Modulemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,8 @@ public function __construct(Plugins $plugins)
}

/**
* @param $module
* @return bool
*/
public static function isModuleEnabled($module): bool
{
if (isset(self::$modules[$module])) {
if (self::$modules[$module]['enabled'] === true) {
return true;
}
}

return false;
}

/**
* Checks if a module is available.
* In Progress: This method is a stub to hook into via filters.
* Checks if a module is available and enabled.
* This also checks plugins and whether they are installed and enabled
*
* @param string $module The name of the module to check availability for.
*
Expand All @@ -82,7 +67,6 @@ public function isModuleAvailable(string $module): bool
{
$available = false;


$plugins = $this->pluginService->getEnabledPlugins();

$filtered = collect($plugins)->filter(function ($plugin) use ($module) {
Expand All @@ -95,7 +79,6 @@ public function isModuleAvailable(string $module): bool

$available = static::dispatch_filter("moduleAvailability", $available, ["module" => $module]);


return $available;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Domain/Plugins/Hxcontrollers/Details.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function install(): string
return 'plugin-installation';
}

if ($this->pluginService->isPluginEnabled($pluginModel->identifier)) {
if ($this->pluginService->isEnabled($pluginModel->identifier)) {
$this->tpl->assign('formNotification', __('marketplace.updated'));
return 'plugin-installation';
}
Expand Down
2 changes: 1 addition & 1 deletion app/Domain/Plugins/Services/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function getAllPlugins(bool $enabledOnly = false): false|array
*
* @api
*/
public function isPluginEnabled($pluginFolder): bool
public function isEnabled($pluginFolder): bool
{
$plugins = $this->getEnabledPlugins();

Expand Down
5 changes: 0 additions & 5 deletions public/assets/js/app/core/editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ leantime.editorController = (function () {
});
}

//&& !editor.plugins.autosave.hasDraft()
if (editor.getContent() === '' ) {
editor.setContent("<p class='tinyPlaceholder'>" + leantime.i18n.__('placeholder.type_slash') + "</p>");
}

});

//and remove it on focus
Expand Down
15 changes: 6 additions & 9 deletions public/assets/js/app/core/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ leantime.modals = (function () {
autoSizable: true,
callbacks: {
beforePostSubmit: function () {

jQuery(".showDialogOnLoad").show();

if(tinymce.editors.length>0) {

jQuery(".simpleEditor").each(function() {
jQuery(this).tinymce().save();
jQuery(this).tinymce().remove();
});

jQuery(".complexEditor").each(function() {
jQuery(this).tinymce().save();
jQuery(this).tinymce().remove();
tinymce.editors.forEach(function(editor) {
editor.save();
editor.destroy();
editor.remove();
});
}

},
beforeShowCont: function () {
jQuery(".showDialogOnLoad").show();
Expand Down
18 changes: 18 additions & 0 deletions tests/Unit/app/Domain/Menu/Repositories/MenuRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,22 @@ public function testGetFilteredMenuStructure()
$this->assertFalse(isset($fullMenuStructure[15]['submenu'][20]), "menu item was not removed");

}

public function testInjectNewProjectMenuType()
{

\Leantime\Core\Events\EventDispatcher::add_filter_listener("leantime.domain.menu.repositories.menu.getMenuStructure.menuStructures", function($menuStructure){

$testStructure = ["item" => "myNewMenu"];
$menuStructure["testType"] = $testStructure;

return $menuStructure;

}, 10);

$fullMenuStructure = $this->menu->getMenuStructure('testType');
$this->assertIsArray($fullMenuStructure);
$this->assertEquals("muNewMenu", $fullMenuStructure["item"]);

}
}

0 comments on commit 32e8ff5

Please sign in to comment.