Skip to content

Commit

Permalink
Ticket #4641 - Use HTMX to load page content without genaral page str…
Browse files Browse the repository at this point in the history
…ucture. Profile/Context submenu.
  • Loading branch information
AntonLV committed Mar 15, 2024
1 parent 3015d16 commit b31be9c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 22 deletions.
8 changes: 6 additions & 2 deletions inc/classes/BxDolInformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ public function setEnabled($bEnabled)
*/
public function add ($sId, $sMsg, $iType = BX_INFORMER_INFO)
{
$this->_aMessages[$sId] = array (
if(!$this->_bEnabled)
return;

$this->_addJsCss();
$this->_aMessages[$sId] = [
'id' => $sId,
'msg' => $sMsg,
'type' => $iType,
);
];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/classes/BxDolPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public function displayPage ($oTemplate = null)
$oTemplate->setPageType($this->getType());
$oTemplate->setPageInjections($this->getInjections());
if($oTemplate->getPageNameIndex() == BX_PAGE_CONTENT_PRELOAD)
$oTemplate->setPageContent('page_main_code', $this->getCodeDynamic(true));
$oTemplate->setPageContent('page_main_code', $this->getIncludes());
else
$oTemplate->setPageContent('page_main_code', $this->getCode());
$oTemplate->getPageCode();
Expand Down
6 changes: 2 additions & 4 deletions modules/base/groups/classes/BxBaseModGroupsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,9 @@ public function actionGetQuestionnaire()

public function serviceManageTools($sType = 'common')
{
$sResult = parent::serviceManageTools($sType);
if(!empty($sResult))
$this->_oTemplate->addJsSystem(['modules/base/groups/js/|manage_tools.js']);
$this->_oTemplate->addJs(['modules/base/groups/js/|manage_tools.js']);

return $sResult;
return parent::serviceManageTools($sType);
}

public function decodeDataAPI($aData, $aParams = [])
Expand Down
4 changes: 2 additions & 2 deletions modules/base/groups/classes/BxBaseModGroupsSearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function __construct($sMode = '', $aParams = array())
public function displaySearchBox ($sContent, $sPaginate = '')
{
$aResult = parent::displaySearchBox($sContent, $sPaginate);
if(!empty($aResult['content'])) {

if(!empty($aResult['content']) && $this->oModule->_oConfig->getJsClass('main') != '') {
$this->oModule->_oTemplate->addJs(['modules/base/groups/js/|main.js', 'main.js']);

$aResult['content'] = $this->oModule->_oTemplate->getJsCode('main', [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ul id="__html_id__" class="bx-menu-main-submenu<bx_if:show_more_auto_class> bx-menu-more-auto</bx_if:show_more_auto_class> bx-menu-object-__object__ flex items-stretch">
<bx_repeat:menu_items>
<li class="bx-menu-item bx-menu-item-__name__ __class_add__ flex">
<li class="bx-menu-item bx-menu-item-__name__ __class_add__ flex" __attrs_wrp__>
<a href="__link__" <bx_if:onclick>onclick="__onclick__"</bx_if:onclick> class="group block relative py-4 px-4 text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-700 dark:hover:text-gray-200 whitespace-nowrap text-sm font-medium text-center hover:bg-transparent focus:z-10 box-sizing"__attrs__>__title__<span class="bx-mi-underline absolute inset-x-0 bottom-0 h-0.5 group-hover:bg-gray-500 rounded-md"></span></a></a>__popup__
</li>
</bx_repeat:menu_items>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct ($aObject, $oTemplate = false)

if(isset($aObject['object'])) {
//--- For page submenus ---//
if(strpos($aObject['object'], '_submenu') !== false && !($this instanceof BxBaseModProfileMenuView)) {
if(strpos($aObject['object'], '_submenu') !== false) {
$sClass = 'bx-menu-tab-active';

$this->_bHx = true;
Expand Down
4 changes: 2 additions & 2 deletions modules/boonex/events/install/langs/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@
<string name="_bx_events_page_title_sys_manage_profile"><![CDATA[Manage Event]]></string>
<string name="_bx_events_page_title_sys_delete_profile"><![CDATA[Delete Event]]></string>
<string name="_bx_events_page_title_delete_profile"><![CDATA[Delete Event]]></string>
<string name="_bx_events_page_title_sys_join_profile"><![CDATA[Join Course]]></string>
<string name="_bx_events_page_title_join_profile"><![CDATA[Join Course]]></string>
<string name="_bx_events_page_title_sys_join_profile"><![CDATA[Join Event]]></string>
<string name="_bx_events_page_title_join_profile"><![CDATA[Join Event]]></string>
<string name="_bx_events_page_title_sys_view_profile_closed"><![CDATA[View Closed Event]]></string>
<string name="_bx_events_page_title_sys_view_profile"><![CDATA[View Event]]></string>
<string name="_bx_events_page_title_view_profile"><![CDATA[{display_name}]]></string>
Expand Down
4 changes: 2 additions & 2 deletions modules/boonex/russian/data/langs/bx_events/ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@
<string name="_bx_events_form_price_input_sys_do_cancel"><![CDATA[Отменить]]></string>
<string name="_bx_events_form_price_input_do_cancel"><![CDATA[Отменить]]></string>
<string name="_bx_events_acl_action_use_paid_join"><![CDATA[Использовать платное подключение]]></string>
<string name="_bx_events_page_title_sys_join_profile"><![CDATA[Присоединиться к курсу]]></string>
<string name="_bx_events_page_title_join_profile"><![CDATA[Присоединиться к курсу]]></string>
<string name="_bx_events_page_title_sys_join_profile"><![CDATA[Присоединиться к событию]]></string>
<string name="_bx_events_page_title_join_profile"><![CDATA[Присоединиться к событию]]></string>
<string name="_bx_events_page_title_browse_upcoming"><![CDATA[Предстоящие События]]></string>
<string name="_bx_events_page_title_sys_profile_sessions"><![CDATA[Сессии]]></string>
<string name="_bx_events_page_title_profile_sessions"><![CDATA[Сессии]]></string>
Expand Down
14 changes: 10 additions & 4 deletions template/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@
}
};
var oOptions = __options__;

var oBxFullCalendar = null;
document.addEventListener('DOMContentLoaded', function() {
oBxFullCalendar = new FullCalendar.Calendar(document.getElementById('__id__'), $.extend({}, oDefaults, oOptions));
var fBxFullCalendarInit = function() {
oBxFullCalendar = new FullCalendar.Calendar(oElement, $.extend({}, oDefaults, oOptions));
oBxFullCalendar.render();
});
};

var oElement = document.getElementById('__id__');
if(oElement)
fBxFullCalendarInit();
else
document.addEventListener('DOMContentLoaded', fBxFullCalendarInit);
</script>
2 changes: 1 addition & 1 deletion template/scripts/BxBaseMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected function _getMenuItem ($a)
$a['attrs'] = $this->_getMenuAttrs($a);
$a['attrs_wrp'] = '';

if($this->_bHx /*&& strpos($a['name'], '-manage') === false*/) {
if($this->_bHx && !empty($a['link']) && strpos($a['link'], 'javascript:') === false) {
$this->_aHx['get'] = $a['link'];
$a['attrs'] .= bx_get_htmx_attrs($this->_aHx);

Expand Down
25 changes: 23 additions & 2 deletions template/scripts/BxBasePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function performActionEmbed ()
* Very similar to BxBasePage::getCode
* but adds css and js files which are needed for the corect page display
*/
public function getCodeDynamic ($bIncludesOnly = false)
public function getCodeDynamic ()
{
// TODO: remake to use use collect* template methods

Expand Down Expand Up @@ -155,7 +155,28 @@ public function getCodeDynamic ($bIncludesOnly = false)
foreach ($aJsNew as $a)
$sJs .= $oTemplate->addJs($a['url'], true);

return $sJs . $sCss . (!$bIncludesOnly ? $sContent : '');
return $sJs . $sCss . $sContent;
}

public function getIncludes ()
{
$oTemplate = BxDolTemplate::getInstance();

// generate page code
$this->getCode();

// get js&css after the page code is generated
$aCss = $oTemplate->getCss();
$aJs = $oTemplate->getJs();

// add js&css files in static mode
$sResult = '';
foreach ($aCss as $a)
$sResult .= $oTemplate->addCss($a['url'], true);
foreach ($aJs as $a)
$sResult .= $oTemplate->addJs($a['url'], true);

return $sResult;
}

/**
Expand Down

0 comments on commit b31be9c

Please sign in to comment.