Commit 6aadcd02 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon

Bug 1813987: Display Dashboard and profile page

+ fix for loading block with ajax
+ also display group page with new layout

behatnotneeded

Change-Id: If93da8afb3069349e5c7612dc41df0faa3394e10
parent b8afbd15
......@@ -82,7 +82,44 @@ if ($group->invitefriends) {
$editwindow = group_format_editwindow($group);
$view = group_get_homepage_view($group->id);
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
if ($newlayout = $view->uses_new_layout()) {
$layoutjs = array('js/lodash/lodash.js', 'js/gridstack/gridstack.js');
$blocks = $view->get_blocks();
$blocks = json_encode($blocks);
$blocksjs = <<<EOF
$(function () {
var options = {
verticalMargin: 10,
float: true,
ddPlugin: false,
};
var grid = $('.grid-stack');
grid.gridstack(options);
grid = $('.grid-stack').data('gridstack');
// should add the blocks one by one
var blocks = {$blocks};
$.each(blocks, function(blockid, block) {
grid.addWidget(
$('<div id="block_' + blockid + '"><div class="grid-stack-item-content">'
+ block.content +
'<div/><div/>'),
block.positionx,
block.positiony,
block.width,
block.height,
null, null, null, null, null,
blockid);
});
jQuery(document).trigger('blocksloaded');
});
EOF;
}
else {
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
$layoutjs= array();
$blocksjs = "$(function () {jQuery(document).trigger('blocksloaded');});";
}
$headers = array();
if ($group->public) {
......@@ -91,6 +128,7 @@ if ($group->public) {
}
$javascript = array('paginator');
$javascript = array_merge($javascript, $layoutjs);
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = <<<JS
......@@ -127,9 +165,12 @@ $smarty = smarty(
)
);
$smarty->assign('INLINEJAVASCRIPT', $inlinejs);
$smarty->assign('INLINEJAVASCRIPT', $blocksjs . $inlinejs);
$smarty->assign('viewid', $view->get('id'));
$smarty->assign('viewcontent', $viewcontent);
$smarty->assign('newlayout', $newlayout);
if (!$newlayout) {
$smarty->assign('viewcontent', $viewcontent);
}
$smarty->assign('group', $group);
$smarty->assign('editwindow', $editwindow);
$smarty->assign('cancopy', group_can_create_groups());
......
......@@ -30,8 +30,13 @@ if ($USER->is_logged_in()) {
// get the user's dashboard view
require_once(get_config('libroot') . 'view.php');
$view = $USER->get_view_by_type('dashboard');
$layoutjs = array();
if ($newlayout = $view->uses_new_layout()) {
$layoutjs = array('js/lodash/lodash.js', 'js/gridstack/gridstack.js');
}
$javascript = array('paginator');
$javascript = array_merge($javascript, $layoutjs);
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "jQuery( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
......@@ -46,8 +51,42 @@ if ($USER->is_logged_in()) {
else {
$skin = false;
}
if ($newlayout) {
$blocks = $view->get_blocks();
$blocks = json_encode($blocks);
$blocksjs = <<<EOF
$(function () {
var options = {
verticalMargin: 10,
float: true,
ddPlugin: false,
};
var grid = $('.grid-stack');
grid.gridstack(options);
grid = $('.grid-stack').data('gridstack');
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
// should add the blocks one by one
var blocks = {$blocks};
$.each(blocks, function(blockid, block) {
grid.addWidget(
$('<div id="block_' + blockid + '"><div class="grid-stack-item-content">'
+ block.content +
'<div/><div/>'),
block.positionx,
block.positiony,
block.width,
block.height,
null, null, null, null, null,
blockid);
});
jQuery(document).trigger('blocksloaded');
});
EOF;
}
else {
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
$blocksjs = "$(function () {jQuery(document).trigger('blocksloaded');});";
}
$smarty = smarty(
$javascript,
$stylesheets,
......@@ -86,10 +125,13 @@ jQuery(function($) {
JAVASCRIPT;
}
$smarty->assign('INLINEJAVASCRIPT', $js . $inlinejs);
$smarty->assign('INLINEJAVASCRIPT', $blocksjs . $js . $inlinejs);
$smarty->assign('dashboardview', true);
$smarty->assign('viewcontent', $viewcontent);
$smarty->assign('newlayout', $newlayout);
if (!$newlayout) {
$smarty->assign('viewcontent', $viewcontent);
}
$smarty->assign('viewid', $view->get('id'));
}
else {
......
/*jslint browser: true, nomen: true, white: true */
/* global jQuery, $ */
jQuery(function($) {
jQuery(window).on('blocksloaded', {}, function() {
"use strict";
function ajaxBlocks() {
......
......@@ -6,7 +6,11 @@
</div>
{/if}
<div class="grouphomepage">
{$viewcontent|safe}
<div class="grid-stack">
{if $viewcontent}
{$viewcontent|safe}
{/if}
</div>
</div>
<div class="metadata text-right">
{$lastupdatedstr}{if $visitstring}; {$visitstring}{/if}
......
<div id="view" class="dashboard view-container">
<div id="bottom-pane">
<div id="column-container">
{$viewcontent|safe}
<div class="grid-stack">
{if $viewcontent}
{$viewcontent|safe}
{/if}
</div>
</div>
</div>
</div>
......@@ -6,9 +6,11 @@
{if $restrictedview}
<strong>{str tag=profilenotshared section=view}</strong>
{else}
{$viewcontent|safe}
<div class="grid-stack">
{if !$newlayout}
{$viewcontent|safe}
{/if}
</div>
{/if}
</div>
</div>
......
......@@ -26,12 +26,10 @@
<div id="view" class="view-container">
<div id="bottom-pane">
<div id="column-container" class="user-page-content">
<div class="container-fluid">
<div class="grid-stack">
{if $viewcontent}
{$viewcontent|safe}
{/if}
</div>
<div class="grid-stack">
{if $viewcontent}
{$viewcontent|safe}
{/if}
</div>
</div>
</div>
......
......@@ -104,10 +104,50 @@ else if ($restrictedview) {
}
if (!$restrictedview) {
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
if ($newlayout = $view->uses_new_layout()) {
$layoutjs = array('js/lodash/lodash.js', 'js/gridstack/gridstack.js');
$blocks = $view->get_blocks();
$blocks = json_encode($blocks);
$blocksjs = <<<EOF
$(function () {
var options = {
verticalMargin: 10,
float: true,
ddPlugin: false,
};
var grid = $('.grid-stack');
grid.gridstack(options);
grid = $('.grid-stack').data('gridstack');
// should add the blocks one by one
var blocks = {$blocks};
$.each(blocks, function(blockid, block) {
grid.addWidget(
$('<div id="block_' + blockid + '"><div class="grid-stack-item-content">'
+ block.content +
'<div/><div/>'),
block.positionx,
block.positiony,
block.width,
block.height,
null, null, null, null, null,
blockid);
});
jQuery(document).trigger('blocksloaded');
});
EOF;
}
else {
$layoutjs= array();
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
$blocksjs = "$(function () {jQuery(document).trigger('blocksloaded');});";
}
}
$javascript = array('paginator', 'lib/pieforms/static/core/pieforms.js');
$javascript = array('paginator',
'lib/pieforms/static/core/pieforms.js',
);
$javascript = array_merge($javascript, $layoutjs);
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
if (is_plugin_active('externalvideo', 'blocktype')) {
......@@ -361,7 +401,7 @@ if ($remoteuserrelationship) {
$smarty->assign('loginas', $loginas);
$smarty->assign('INLINEJAVASCRIPT', $inlinejs);
$smarty->assign('INLINEJAVASCRIPT', $blocksjs . $inlinejs);
$smarty->assign('institutions', get_institution_string_for_user($userid));
$smarty->assign('canmessage', $loggedinid != $userid && can_send_message($loggedinid, $userid));
......@@ -376,9 +416,11 @@ if ($loggedinid && $loggedinid == $userid) {
$smarty->assign('ownprofile', true);
}
$smarty->assign('pageheadinghtml', $view->display_title(false));
if (!$restrictedview) {
$smarty->assign('viewcontent', $viewcontent);
$smarty->assign('newlayout', $newlayout);
if (!$newlayout) {
$smarty->assign('viewcontent', $viewcontent);
}
}
safe_require('module', 'multirecipientnotification');
$smarty->assign('mrmoduleactive', PluginModuleMultirecipientnotification::is_active());
......
......@@ -387,6 +387,7 @@ EOF;
}
else {
$viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
$blocksjs = "$(function () {jQuery(document).trigger('blocksloaded');});";
}
}
......@@ -540,7 +541,7 @@ if (!empty($blocktype_toolbar['toolbarhtml'])) {
$smarty->assign('toolbarhtml', join("\n", $blocktype_toolbar['toolbarhtml']));
}
$smarty->assign('canremove', $can_edit);
$smarty->assign('INLINEJAVASCRIPT', $javascript . $inlinejs . $blocksjs);
$smarty->assign('INLINEJAVASCRIPT', $blocksjs . $javascript . $inlinejs);
$smarty->assign('viewid', $viewid);
$smarty->assign('viewtype', $viewtype);
$smarty->assign('feedback', $feedback);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment