[ADD]disable_fullscreen_slides

This commit is contained in:
2024-12-11 10:42:01 +01:00
parent 5597e4000d
commit b0353d2515
19 changed files with 1001 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
/**
* Main css of disable_fullscreen_slides addon.
*/
/*
.oe-disable_fullscreen_slides {
color: black
}
*/

View File

@@ -0,0 +1,90 @@
/** @odoo-module **/
import publicWidget from 'web.public.widget';
import { _t } from 'web.core';
import { SlideCoursePage } from '@website_slides/js/slides_course_page';
/** overwrite all website_slides/js/slides_course_page/slides_course_slides_liste.js to remove _updateHref()**/
publicWidget.registry.websiteSlidesCourseSlidesList = SlideCoursePage.extend({
selector: '.o_wslides_slides_list',
start: function () {
this._super.apply(this,arguments);
this.channelId = this.$el.data('channelId');
this._bindSortable();
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------,
/**
* Bind the sortable jQuery widget to both
* - course sections
* - course slides
*
* @private
*/
_bindSortable: function () {
this.$('ul.o_wslides_js_slides_list_container').sortable({
handle: '.o_wslides_slides_list_drag',
stop: this._reorderSlides.bind(this),
items: '.o_wslides_slide_list_category',
placeholder: 'o_wslides_slides_list_slide_hilight position-relative mb-1'
});
this.$('.o_wslides_js_slides_list_container ul').sortable({
handle: '.o_wslides_slides_list_drag',
connectWith: '.o_wslides_js_slides_list_container ul',
stop: this._reorderSlides.bind(this),
items: '.o_wslides_slides_list_slide:not(.o_wslides_js_slides_list_empty)',
placeholder: 'o_wslides_slides_list_slide_hilight position-relative mb-1'
});
},
/**
* This method will check that a section is empty/not empty
* when the slides are reordered and show/hide the
* "Empty category" placeholder.
*
* @private
*/
_checkForEmptySections: function (){
this.$('.o_wslides_slide_list_category').each(function (){
var $categoryHeader = $(this).find('.o_wslides_slide_list_category_header');
var categorySlideCount = $(this).find('.o_wslides_slides_list_slide:not(.o_not_editable)').length;
var $emptyFlagContainer = $categoryHeader.find('.o_wslides_slides_list_drag').first();
var $emptyFlag = $emptyFlagContainer.find('small');
if (categorySlideCount === 0 && $emptyFlag.length === 0){
$emptyFlagContainer.append($('<small>', {
'class': "ms-1 text-muted fw-bold",
text: _t("(empty)")
}));
} else if (categorySlideCount > 0 && $emptyFlag.length > 0){
$emptyFlag.remove();
}
});
},
_getSlides: function (){
var categories = [];
this.$('.o_wslides_js_list_item').each(function (){
categories.push(parseInt($(this).data('slideId')));
});
return categories;
},
_reorderSlides: function (){
var self = this;
self._rpc({
route: '/web/dataset/resequence',
params: {
model: "slide.slide",
ids: self._getSlides()
}
}).then(function (res) {
self._checkForEmptySections();
});
},
});
export default publicWidget.registry.websiteSlidesCourseSlidesList;

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<!-- QWEB Templates for UI Widgets and views -->
<!--
<t t-name="disable_fullscreen_slidesView">
<div class="oe_disable_fullscreen_slides_view">
<div class="oe_disable_fullscreen_slides_buttons"/>>
<table class="oe_disable_fullscreen_slides_groups">
<tr class="oe_disable_fullscreen_slides_groups_headers">
<td class="oe_disable_fullscreen_slides_dummy_cell"><div/></td>
</tr>
<tr class="oe_disable_fullscreen_slides_dummy_row">
</tr>
</table>
</div>
</t>
-->
</templates>