Skip to content

Commit

Permalink
lui: fixed modal in page editing / internal link editing; moved code …
Browse files Browse the repository at this point in the history
…to copage
  • Loading branch information
alex40724 committed Sep 27, 2024
1 parent 99b320b commit 6b6724b
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 18 deletions.
11 changes: 11 additions & 0 deletions components/ILIAS/COPage/COPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,16 @@ public function getTarget(): string
return "components/ILIAS/COPage/css";
}
};
$contribute[Component\Resource\PublicAsset::class] = static fn() => new class () implements Component\Resource\PublicAsset {
public function getSource(): string
{
return "components/ILIAS/COPage/IntLink/resources/ilIntLink.js";
}
public function getTarget(): string
{
return "assets/js/ilIntLink.js";
}
};

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*********************************************************************/

namespace ILIAS\Link\Setup;
namespace ILIAS\COPage\IntLink\Setup;

use ILIAS\Setup;
use ILIAS\Setup\Objective;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*********************************************************************/

namespace ILIAS\Link\Setup;
namespace ILIAS\COPage\IntLink\Setup;

/**
* @author Alexander Killing <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*********************************************************************/

namespace ILIAS\Link;
namespace ILIAS\COPage\IntLink;

use ILIAS\Repository\BaseGUIRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*********************************************************************/

use ILIAS\Link\StandardGUIRequest;
use ILIAS\COPage\IntLink\StandardGUIRequest;

/**
* Internal link selector
Expand Down Expand Up @@ -275,7 +275,7 @@ public function showLinkHelp(): void
}
}
if ($ilCtrl->isAsynch()) {
$tpl = new ilGlobalTemplate("tpl.link_help_asynch.html", true, true, "components/ILIAS/Link");
$tpl = new ilGlobalTemplate("tpl.link_help_asynch.html", true, true, "components/ILIAS/COPage/IntLink");
$tpl->setVariable("NEW_LINK_URL", $this->ctrl->getLinkTarget(
$this,
"",
Expand All @@ -284,7 +284,7 @@ public function showLinkHelp(): void
false
));
} else {
$tpl = new ilGlobalTemplate("tpl.link_help.html", true, true, "components/ILIAS/Link");
$tpl = new ilGlobalTemplate("tpl.link_help.html", true, true, "components/ILIAS/COPage/IntLink");
$tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
}

Expand Down Expand Up @@ -676,7 +676,7 @@ public function getFileLinkHTML(): string
$lng = $this->lng;
$ilCtrl = $this->ctrl;

$tpl = new ilTemplate("tpl.link_file.html", true, true, "components/ILIAS/Link");
$tpl = new ilTemplate("tpl.link_file.html", true, true, "components/ILIAS/COPage/IntLink");
if (!is_object($this->uploaded_file)) {
$tpl->setCurrentBlock("form");
$tpl->setVariable(
Expand Down Expand Up @@ -841,7 +841,7 @@ public function changeTargetObject(

$ilCtrl->setParameter($this, "link_type", $this->link_type);

$tpl = new ilTemplate("tpl.link_help_explorer.html", true, true, "components/ILIAS/Link");
$tpl = new ilTemplate("tpl.link_help_explorer.html", true, true, "components/ILIAS/COPage/IntLink");

$output = $this->getTargetExplorer();

Expand Down Expand Up @@ -927,18 +927,36 @@ public static function getInitHTML(string $a_url): string
$tpl->addJavaScript("assets/js/ilExplorer.js");
ilExplorerBaseGUI::init();

//$tpl->addJavascript("../components/ILIAS/COPage/IntLink/resources/ilIntLink.js");
$tpl->addJavascript("assets/js/ilIntLink.js");
// #18721
$tpl->addJavaScript("assets/js/Form.js");

$modal = ilModalGUI::getInstance();
$modal->setHeading($lng->txt("link_link"));
$modal->setId("ilIntLinkModal");
$modal->setBody("<div id='ilIntLinkModalContent'></div>");
$mt = self::getModalTemplate();

return $modal->getHTML();
$html = "<div id='ilIntLinkModal' data-show-signal='".$mt["show"]."' data-close-signal='".$mt["close"]."'>".
$mt["template"] .
"</div>";

return $html;
}

public static function getModalTemplate(): array
{
global $DIC;

$lng = $DIC->language();

$ui = $DIC->ui();
$modal = $ui->factory()->modal()->roundtrip($lng->txt("link_link"), $ui->factory()->legacy("<div id='ilIntLinkModalContent'></div>"));
$modalt["show"] = $modal->getShowSignal()->getId();
$modalt["close"] = $modal->getCloseSignal()->getId();
$modalt["template"] = $ui->renderer()->renderAsync($modal);

return $modalt;
}


/**
* Render internal link item
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,16 @@ il.IntLink =
* panel is used by other features, too (e.g. wiki link handling)
*/
showPanel: function() {
$('#ilIntLinkModal').modal('show');
const modalEl = document.getElementById("ilIntLinkModal");
const showSignal = modalEl.dataset.showSignal;
$(document).trigger(
showSignal,
{
id: showSignal,
triggerer: $(this),
options: JSON.parse('[]'),
},
);
},

sendAjaxGetRequestToUrl: function (url, par = {}, args= {}) {
Expand Down Expand Up @@ -351,7 +360,16 @@ il.IntLink =
},

hidePanel: function () {
$('#ilIntLinkModal').modal('hide');
const modalEl = document.getElementById("ilIntLinkModal");
const closeSignal = modalEl.dataset.closeSignal;
$(document).trigger(
closeSignal,
{
id: closeSignal,
triggerer: $(this),
options: JSON.parse('[]'),
},
);
},

setMepPoolFolder: function(mep_fold_id) {
Expand Down
4 changes: 1 addition & 3 deletions components/ILIAS/Link/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ public function init(
array | \ArrayAccess &$internal,
): void {
$contribute[\ILIAS\Setup\Agent::class] = static fn() =>
new \ILIAS\Link\Setup\Agent(
new COPage\IntLink\Setup\Agent(
$pull[\ILIAS\Refinery\Factory::class]
);

$contribute[Component\Resource\PublicAsset::class] = fn() =>
new Component\Resource\ComponentJS($this, "ilIntLink.js");
$contribute[Component\Resource\PublicAsset::class] = fn() =>
new Component\Resource\ComponentJS($this, "ilExtLink.js");
$contribute[Component\Resource\PublicAsset::class] = static fn() =>
Expand Down

1 comment on commit 6b6724b

@kergomard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alex40724 : As far as I can see, this broke the unit-tests.

Please sign in to comment.