Commit affb4e9f authored by Colin PUY's avatar Colin PUY Committed by benjaminParisel

fix(preview): reflect selected resolution from designer to preview

When opening the preview (and only when opening it), set selected resolution in preview the same as the one selected in designer.
Also make a slight perf improvement by registering watchers only when feature is activated in `resolutions-bar.directive.js`

Closes [BS-18062](https://bonitasoft.atlassian.net/browse/BS-18062)
parent 633984dd
......@@ -24,12 +24,13 @@
* The preview controller. It handles the loading of the page model, the resolution changes and provides
* common functions to the directives used inside the page.
*/
function PreviewCtrl($scope, $sce, $location, $httpParamSerializer, $window, $log, iframeParameters, resolutions, webSocket, clock, artifactRepo) {
function PreviewCtrl($scope, $sce, $location, $httpParamSerializer, $window, $log, iframeParameters, resolutions, webSocket, clock, artifactRepo, $state, mode) {
$scope.iframe = {};
$scope.refreshIframe = refreshIframe;
$scope.buildIframeSrc = buildIframeSrc;
$scope.iframeWidth = iframeWidth;
$scope.updateResolutionInUrl = updateResolutionInUrl;
$scope.isNavCollapsed = true;
artifactRepo
......@@ -75,6 +76,14 @@
function closeWindow() {
$window.close();
}
function updateResolutionInUrl(resolution) {
$state.transitionTo(`designer.preview`, {
resolution: resolution.key,
id: iframeParameters.id,
mode: mode
}, { notify: false });
}
}
})();
......@@ -7,7 +7,13 @@
<div class="Preview-toolbar collapse navbar-collapse" uib-collapse="isNavCollapsed">
<ul class="nav navbar-nav">
<li><language-picker on-change="refreshIframe()"></language-picker></li>
<li><resolutions-bar id="resolutions" class="btn-group Preview-resolutionBar"></resolutions-bar></li>
<li>
<resolutions-bar
on-change="updateResolutionInUrl"
id="resolutions"
class="btn-group Preview-resolutionBar">
</resolutions-bar>
</li>
</ul>
</div>
</nav>
......
......@@ -114,7 +114,7 @@
});
$stateProvider.state('designer.preview', {
url: '/preview/:mode/:id',
url: '/preview/:mode/:id?resolution',
views: {
'@designer': {
controller: 'PreviewCtrl',
......
......@@ -37,7 +37,8 @@ describe('PreviewCtrl', function() {
iframeParameters,
webSocket,
clock,
artifactRepo: pageRepo
artifactRepo: pageRepo,
mode: 'page'
});
webSocket.resolveConnection();
......
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