From c4eba6f5b150a0e881b7fb9b935ef1a0c3154bbf Mon Sep 17 00:00:00 2001 From: laa Date: Tue, 3 Sep 2019 07:09:11 +0000 Subject: [PATCH] [FIX] website_slides: correctly set sequence of newly added content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Purpose of this commit is to add new content at last position in frontend. Indeed backend uses last position in embedded list view, frontend should do the same. Moreover when having a lot of content, having everything at the bottom of the screen at the same position of Add content / section buttons makes sens. Specifications * when adding a new category: add it as last category; * when adding a new slide in a category: add it as last slide of the category; Specific case of slide without category * when adding a new slide without category: add it as last slide of the channel (display it as last) but keep it on top in backend view (display as first); Improve content list display in frontend of eLearning * contents without section are now at the bottom; * fixed alignment of buttons icon (Add Content and Add Section) * fixed broken design because of title too long Task 2049640 (website slides back2basics and fiximp) Task 2061672 (new content bug report) Co-Authored-By: Michaƫl Mattiello Co-Authored-By: Alexis Lacroix --- addons/website_slides/controllers/main.py | 3 ++ addons/website_slides/models/slide_channel.py | 20 ++++++------- .../tests/tours/slides_tour_tools.js | 4 +-- .../views/website_slides_templates_course.xml | 28 ++++++++++--------- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index f74728ba065..028be99a530 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -831,7 +831,10 @@ class WebsiteSlides(WebsiteProfile): else: values.update({ 'category_id': post['category_id'][0], + 'sequence': request.env['slide.slide'].browse(post['category_id'][0]).sequence + 1 }) + else: + values['sequence'] = -1 # create slide itself try: diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py index 20e62300ff4..ee846b3d0d1 100644 --- a/addons/website_slides/models/slide_channel.py +++ b/addons/website_slides/models/slide_channel.py @@ -523,16 +523,7 @@ class Channel(models.Model): all_slides = self.env['slide.slide'].sudo().search(base_domain, order=order) category_data = [] - # First add uncategorized slides - uncategorized_slides = all_slides.filtered(lambda slide: not slide.category_id) - if uncategorized_slides or force_void: - category_data.append({ - 'category': False, 'id': False, - 'name': _('Uncategorized'), 'slug_name': _('Uncategorized'), - 'total_slides': len(uncategorized_slides), - 'slides': uncategorized_slides[(offset or 0):(offset + limit or len(uncategorized_slides))], - }) - # Then all categories by natural order + # First add all categories by natural order for category in all_categories: category_slides = all_slides.filtered(lambda slide: slide.category_id == category) if not category_slides and not force_void: @@ -543,6 +534,15 @@ class Channel(models.Model): 'total_slides': len(category_slides), 'slides': category_slides[(offset or 0):(limit + offset or len(category_slides))], }) + # Then add uncategorized slides + uncategorized_slides = all_slides.filtered(lambda slide: not slide.category_id) + if uncategorized_slides or force_void: + category_data.append({ + 'category': False, 'id': False, + 'name': _('Uncategorized'), 'slug_name': _('Uncategorized'), + 'total_slides': len(uncategorized_slides), + 'slides': uncategorized_slides[(offset or 0):(offset + limit or len(uncategorized_slides))], + }) return category_data def _resequence_slides(self, slide): diff --git a/addons/website_slides/tests/tours/slides_tour_tools.js b/addons/website_slides/tests/tours/slides_tour_tools.js index 228ea3f9194..3485377fdfb 100644 --- a/addons/website_slides/tests/tours/slides_tour_tools.js +++ b/addons/website_slides/tests/tours/slides_tour_tools.js @@ -23,7 +23,7 @@ var addVideoToSection = function (sectionName, saveAsDraft) { var base_steps = [ { content: 'eLearning: add content to section', - trigger: 'div.o_wslides_slide_list_category_header:contains("' + sectionName + '") a:contains("Add content")', + trigger: 'div.o_wslides_slide_list_category_header:contains("' + sectionName + '") a:contains("Add Content")', }, { content: 'eLearning: click on video', trigger: 'a[data-slide-type=video]', @@ -57,7 +57,7 @@ var addWebPageToSection = function (sectionName, pageName) { return [ { content: 'eLearning: add content to section', - trigger: 'div.o_wslides_slide_list_category_header:contains("' + sectionName + '") a:contains("Add content")', + trigger: 'div.o_wslides_slide_list_category_header:contains("' + sectionName + '") a:contains("Add Content")', }, { content: 'eLearning: click on webpage', trigger: 'a[data-slide-type=webpage]', diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index bbaefa81aa5..e4b1bb8b7f2 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -353,7 +353,7 @@ -
  • +
  • @@ -374,7 +374,7 @@ t-att-data-category-id="category_id" t-att-data-can-upload="channel.can_upload" t-att-data-can-publish="channel.can_publish"> - Add content + Add Content
    @@ -399,10 +399,10 @@ t-att-data-modules-to-install="modules_to_install" t-att-data-channel-id="channel.id" t-att-data-can-upload="channel.can_upload" - t-att-data-can-publish="channel.can_publish">Add Content + t-att-data-can-publish="channel.can_publish">Add Content Add Section + groups="website.group_website_publisher">Add Section
    @@ -416,14 +416,16 @@ - - - - - - +
    + + + + + + +
    -
    +
    xp @@ -435,12 +437,12 @@ Free preview
    -
    +
    - +