Skip to content
Snippets Groups Projects
Commit dcb6a3ce authored by Aurélien Warnon's avatar Aurélien Warnon
Browse files

[FIX] website_slides: close fullscreen mode when opening web editor


The web editor does not work well with the e-learning fullscreen view.
It actually completely closes the fullscreen view and opens the edition on a
blank page.

To avoid this, we intercept the click on the 'edit' button and redirect to the
non-fullscreen view of this slide with the editor enabled, whose layout is more
suited to edit in-place anyway.

A small testing tour was added to ensure this behavior is kept.

Task-2507179

closes odoo/odoo#69363

Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent eeeb18a2
No related branches found
No related tags found
No related merge requests found
......@@ -707,11 +707,32 @@ odoo.define('website_slides.fullscreen', function (require) {
selector: '.o_wslides_fs_main',
xmlDependencies: ['/website_slides/static/src/xml/website_slides_fullscreen.xml', '/website_slides/static/src/xml/website_slides_share.xml'],
start: function (){
var self = this;
var proms = [this._super.apply(this, arguments)];
var fullscreen = new Fullscreen(this, this._getSlides(), this._getCurrentSlideID(), this._extractChannelData());
proms.push(fullscreen.attachTo(".o_wslides_fs_main"));
return Promise.all(proms);
return Promise.all(proms).then(function () {
$('#edit-page-menu a[data-action="edit"]').on('click', self._onWebEditorClick.bind(self));
});
},
/**
* The web editor does not work well with the e-learning fullscreen view.
* It actually completely closes the fullscreen view and opens the edition on a blank page.
*
* To avoid this, we intercept the click on the 'edit' button and redirect to the
* non-fullscreen view of this slide with the editor enabled, which is more suited to edit
* in-place anyway.
*
* @param {MouseEvent} e
*/
_onWebEditorClick: function (e) {
e.preventDefault();
e.stopPropagation();
window.location = `${window.location.pathname}?fullscreen=0&enable_editor=1`;
},
_extractChannelData: function (){
return this.$el.data();
},
......
......@@ -50,6 +50,20 @@ class TestUi(tests.HttpCase):
'odoo.__DEBUG__.services["web_tour.tour"].tours.course_member.ready',
login=user_portal.login)
def test_full_screen_edition_website_publisher(self):
# group_website_designer
user_demo = self.env.ref('base.user_demo')
user_demo.flush()
user_demo.write({
'groups_id': [(5, 0), (4, self.env.ref('base.group_user').id), (4, self.env.ref('website.group_website_publisher').id)]
})
self.phantom_js(
'/slides',
'odoo.__DEBUG__.services["web_tour.tour"].run("full_screen_web_editor")',
'odoo.__DEBUG__.services["web_tour.tour"].tours.full_screen_web_editor.ready',
login=user_demo.login)
@tests.common.tagged('external', '-standard')
class TestUiYoutube(tests.HttpCase):
......
odoo.define('website_slides.tour.fullscreen.edition.publisher', function (require) {
'use strict';
var tour = require('web_tour.tour');
/**
* Global use case:
* - a user (website publisher) lands on the fullscreen view of a course ;
* - he clicks on the website editor "Edit" button ;
* - he is redirected to the non-fullscreen view with the editor opened.
*
* This tour tests a fix made when editing a course in fullscreen view.
* See "Fullscreen#_onWebEditorClick" for more information.
*
*/
tour.register('full_screen_web_editor', {
url: '/slides',
test: true
}, [{
// open to the course
trigger: 'a:contains("Basics of Gardening")'
}, {
// click on a slide to open the fullscreen view
trigger: 'a.o_wslides_js_slides_list_slide_link:contains("Home Gardening")'
}, {
trigger: '.o_wslides_fs_main',
run: function () {} // check we land on the fullscreen view
}, {
// click on the main "Edit" button to open the web editor
trigger: '#edit-page-menu a[data-action="edit"]',
}, {
trigger: '.o_wslides_lesson_main',
run: function () {} // check we are redirected on the detailed view
}, {
trigger: 'body.editor_enable',
run: function () {} // check the editor is automatically opened on the detailed view
}]);
});
......@@ -38,6 +38,7 @@
<script type="text/javascript" src="/website_slides/tests/tours/slides_course_member.js"/>
<script type="text/javascript" src="/website_slides/tests/tours/slides_course_member_yt.js"/>
<script type="text/javascript" src="/website_slides/tests/tours/slides_course_publisher.js"/>
<script type="text/javascript" src="/website_slides/tests/tours/slides_full_screen_web_editor.js"/>
</xpath>
</template>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment