Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] website_slides: Fix reordering of slide after d&d #39086

Open
wants to merge 3 commits into
base: 13.0
from

Conversation

@qmo-odoo
Copy link
Contributor

qmo-odoo commented Oct 21, 2019

This PR fixes a few issues on the slide list in front-end:

  • Fixes the reordering of slides in case there are some uncategorized slides in the course
    and some slide upload issues in a few corner cases.

  • Fixes "empty" flag display whenever a slide gets drag&dropped/archived.

More info in sub-commits

TaskID: 2090927

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo robodoo added the seen 🙂 label Oct 21, 2019
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 21, 2019
This commit fixes the reordering of slides in case there are some
uncategorized slides in the course.

This issue was due to the fact that in a previous commit, uncategorized slides
were moved to the bottom of the list, which broke the reordering as we use
the dom order itself to reorder the slides with a simple rpc call
to dataset/resequence.

Furthermore, having the uncategorized slides at the bottom of the list,
allows us to be coherent with the backend behaviour.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 33f1821 to 3d30c41 Oct 21, 2019
@C3POdoo C3POdoo added the RD label Oct 21, 2019
@robodoo robodoo added the CI 🤖 label Oct 21, 2019
Copy link
Contributor

awa-odoo left a comment

2 things to check here:

  • Can you add the reference of the commit that broke it in the message ?
  • Would be nice to add a small python test to ensure that never happens again
@@ -357,7 +357,7 @@

<li t-if="category['total_slides'] or channel.can_publish" t-att-class="'o_wslides_slide_list_category o_wslides_js_list_item mb-2' if category_id else 'mt-4'" t-att-data-slide-id="category_id" t-att-data-category-id="category_id">
<div t-att-data-category-id="category_id"
t-att-class="'o_wslides_slide_list_category_header position-relative d-flex justify-content-between align-items-center %s' % ('o_wslides_js_category bg-white shadow-sm border-bottom-0' if category_id and channel.can_upload else 'border-0 py-1')">
t-att-class="'o_wslides_slide_list_category_header position-relative d-flex justify-content-between align-items-center mt8 %s' % ('o_wslides_js_category bg-white shadow-sm border-bottom-0' if category_id and channel.can_upload else 'border-0 py-1')">

This comment has been minimized.

Copy link
@awa-odoo

awa-odoo Oct 21, 2019

Contributor

Looks very unrelated ^^

qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
This commit fixes the reordering of slides in case there are some
uncategorized slides in the course.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

To avoid future problems, a test was added for _get_categorized_slides

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 3d30c41 to f144490 Oct 22, 2019
@robodoo robodoo removed the CI 🤖 label Oct 22, 2019
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
This commit fixes the reordering of slides in case there are some
uncategorized slides in the course.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

To avoid future problems, a test was added for _get_categorized_slides

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from f144490 to c043fd2 Oct 22, 2019
Copy link
Contributor

dbeguin left a comment

some broleke

'category': False, 'id': False,
'name': _('Uncategorized'), 'slug_name': _('Uncategorized'),
Comment on lines 549 to 550

This comment has been minimized.

Copy link
@dbeguin

dbeguin Oct 22, 2019

Contributor

each brol in one line, even if it's a move :) tankaffaire !

@@ -70,7 +70,6 @@ def test_resequence(self):
# self.assertEqual(self.category.sequence, 3)
# self.assertEqual(self.slide_2.sequence, 4)


This comment has been minimized.

Copy link
@dbeguin

dbeguin Oct 22, 2019

Contributor

hééééé. class need 2 empty lines before declaration. Be gentle with my linter, please :)

categorized_slides = self.channel._get_categorized_slides(base_domain, order)
self.assertEquals(categorized_slides[0]['category'], False)
self.assertEquals(categorized_slides[1]['category'], self.category)
self.assertEquals(categorized_slides[1]['total_slides'], 2)

This comment has been minimized.

Copy link
@dbeguin

dbeguin Oct 22, 2019

Contributor

We could also check if (following your long explanation here before), last category has no slides.

def test_get_categorized_slides(self):
base_domain = []
order = self.env['slide.slide']._order_by_strategy['sequence']
categorized_slides = self.channel._get_categorized_slides(base_domain, order)

This comment has been minimized.

Copy link
@dbeguin

dbeguin Oct 22, 2019

Contributor

categorized_slides = self.channel._get_categorized_slides([], order)
and remove base_domain

self.ensure_one()
all_categories = self.env['slide.slide'].sudo().search([('channel_id', '=', self.id), ('is_category', '=', True)])
all_slides = self.env['slide.slide'].sudo().search(base_domain, order=order)
category_data = []

# First add all categories by natural order

This comment has been minimized.

Copy link
@dbeguin

dbeguin Oct 22, 2019

Contributor

keep the comments ! Comments are good !

# First add uncategorized slides
...
# Then add all categories by natural order
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
If you create two empty categories then try to add in the first empty one,
the slide would be added to the last one.

This commit fixes that by using the category_id received from the frontend
instead of relying on the one on the slide itself
(which is wrong due to it not being sequenced not at that time)

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
If you create two empty categories then try to add in the first empty one,
the slide would be added to the second one instead.

This commit fixes that by using the category_id received from the frontend
instead of relying on the one on the slide itself
(which is wrong due to it not being resequenced at that time)

Category_id and sequence will no longer be set in the controller
before the resequencing occurs.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from d5969fd to 0b2ab4b Oct 22, 2019
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
If you create two empty categories then try to add in the first empty one,
the slide would be added to the second one instead.

This commit fixes that by using the category_id received from the frontend
instead of relying on the one on the slide itself.

Category_id and sequence will no longer be set in the controller
before the resequencing occurs. In fact, category_id will be set
no matter what during the resequencing as it will update the slide
sequence.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 0b2ab4b to 04c4fcb Oct 22, 2019
@robodoo robodoo added the CI 🤖 label Oct 22, 2019
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
If you create two empty categories then try to add in the first empty one,
the slide would be added to the second one instead.

This commit fixes that by using the category_id received from the frontend
instead of relying on the one on the slide itself.

Category_id will no longer be set in the controller
before the resequencing occurs. In fact, category_id will be set
no matter what during the resequencing as it will update the slide
sequence.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 04c4fcb to 4fe4fdc Oct 22, 2019
@robodoo robodoo removed the CI 🤖 label Oct 22, 2019
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
This commit fixes the reordering of slides in case there are some
uncategorized slides in the course.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

To avoid future problems, a test was added for _get_categorized_slides

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
If you create two empty categories then try to add in the first empty one,
the slide would be added to the second one instead.

This commit fixes that by using the category_id received from the frontend
instead of relying on the one on the slide itself.

Category_id will no longer be set in the controller
before the resequencing occurs. In fact, category_id will be set
no matter what during the resequencing as it will update the slide
sequence.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 4fe4fdc to 7d951d1 Oct 22, 2019
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 22, 2019
If you create two empty categories then try to add in the first empty one,
the slide would be added to the second one instead.

This commit fixes that by using the category_id received from the frontend
instead of relying on the one on the slide itself.

Category_id will no longer be set in the controller
before the resequencing occurs. In fact, category_id will be set
no matter what during the resequencing as it will update the slide
sequence.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 7d951d1 to 34f59fa Oct 22, 2019
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 23, 2019
This commit fixes the reordering of slides in case there are some
uncategorized slides in the course.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

To avoid future problems, a test was added for _get_categorized_slides

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 23, 2019
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
@robodoo robodoo removed the CI 🤖 label Jan 6, 2020
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
Before this commit, empty sections were not flagged correctly whenever
a slide got archived or dragged to another section.

This was due to the fact that the empty flag was modified during style revamp
but not the javascript.

LINKS

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
This commit fixes the reordering of slides on upload or drag and drop
in frontend.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering after drag and drop, as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

Another issue was that, on slide upload, in the controller, we used
the category_id on the slide (which seems to not always be correct at
this stage) instead of the one given by the javascript. This caused the slide
to not be uploaded in the right section.

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 73de89b to 6cd80c9 Jan 14, 2020
var categoryID = $(this).data('categoryId');
var categorySlideCount = $(this).find('.o_wslides_slides_list_slide:not(.o_not_editable)').length;
var $emptyFlagContainer = self.$('.o_wslides_slide_list_category_header[data-category-id="'+ categoryID +'"] > div:first-child');
var $emptyFlag = $emptyFlagContainer.find('small')[0];

This comment has been minimized.

Copy link
@awa-odoo

awa-odoo Jan 14, 2020

Contributor

Check length of $emptyFlag instead of the 0 positioned element.

Also, from my tests, it seems the "empty flag" appears when I archive a slide, even if the category is not empty.
Can you check?

var categorySlideList = $(this.$slideTarget.parents('li'));
var categoryId = categorySlideList.data('categoryId');
var slideList = $('.o_wslides_slide_list[data-category-id='+ categoryId +']').find('.o_wslides_js_list_item');
if (slideList.length === 0){
$('.o_wslides_slide_list_category_header[data-category-id="'+ categoryId +'"] > div:first-child').append('<small class="ml-1 text-muted">Empty</small>');
}

This comment has been minimized.

Copy link
@awa-odoo

awa-odoo Jan 14, 2020

Contributor

Well that's annoying.

I'm debating with myself how we should have done this.
Maybe a master widget on top of everything that handles the communication between the sub-widgets like list and delete?
Nothing we can do for stable anyway...

Then please:

  • apply the same mechanism with the block '<small class="ml-1 text-muted">Empty</small>' as explained in my other comment
  • prefix your variables containing jQuery elements with $
  • use closest('li') instead of $(this.$slideTarget.parents('li')) if possible
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo.addons.website_slides.tests import common as slides_common

This comment has been minimized.

Copy link
@awa-odoo

awa-odoo Jan 14, 2020

Contributor

from odoo.addons.website_slides.tests.common import SlidesCase instead?

qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
Before this commit, empty sections were not flagged correctly whenever
a slide got archived or dragged to another section.

This was due to the fact that the empty flag was modified during style revamp
but not the javascript.

LINKS

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
This commit fixes the reordering of slides on upload or drag and drop
in frontend.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering after drag and drop, as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

Another issue was that, on slide upload, in the controller, we used
the category_id on the slide (which seems to not always be correct at
this stage) instead of the one given by the javascript. This caused the slide
to not be uploaded in the right section.

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 6cd80c9 to 789d371 Jan 14, 2020
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
Before this commit, empty sections were not flagged correctly whenever
a slide got archived or dragged to another section.

This was due to the fact that the empty flag was modified during style revamp
but not the javascript.

LINKS

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
This commit fixes the reordering of slides on upload or drag and drop
in frontend.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering after drag and drop, as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

Another issue was that, on slide upload, in the controller, we used
the category_id on the slide (which seems to not always be correct at
this stage) instead of the one given by the javascript. This caused the slide
to not be uploaded in the right section.

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 14, 2020
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from 789d371 to e3f2547 Jan 14, 2020
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 15, 2020
Before this commit, empty sections were not flagged correctly whenever
a slide got archived or dragged to another section.

This was due to the fact that the empty flag was modified during style revamp
but not the javascript.

LINKS

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 15, 2020
This commit fixes the reordering of slides on upload or drag and drop
in frontend.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering after drag and drop, as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

Another issue was that, on slide upload, in the controller, we used
the category_id on the slide (which seems to not always be correct at
this stage) instead of the one given by the javascript. This caused the slide
to not be uploaded in the right section.

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 15, 2020
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from e3f2547 to af755d9 Jan 15, 2020
Before this commit, empty sections were not flagged correctly whenever
a slide got archived or dragged to another section.

This was due to the fact that the empty flag was modified during style revamp
but not the javascript.

LINKS

TaskID: 2090927
PR: #39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 15, 2020
This commit fixes the reordering of slides on upload or drag and drop
in frontend.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering after drag and drop, as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

Another issue was that, on slide upload, in the controller, we used
the category_id on the slide (which seems to not always be correct at
this stage) instead of the one given by the javascript. This caused the slide
to not be uploaded in the right section.

LINKS:

TaskID: 2090927
PR: odoo#39086
qmo-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 15, 2020
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: odoo#39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from af755d9 to cfee211 Jan 15, 2020
@awa-odoo

This comment has been minimized.

Copy link
Contributor

awa-odoo commented Jan 15, 2020

@qmo-odoo In your PR description, I don't think you mention the "empty flag" fix.
Maybe you could go for a quick bullet points approach and just say "More info in sub-commits"?

qmo-odoo added 2 commits Dec 30, 2019
This commit fixes the reordering of slides on upload or drag and drop
in frontend.

This issue was due to the fact that in a previous commit:
  c4eba6f

uncategorized slides were moved to the bottom of the list,
which broke the reordering after drag and drop, as we use the dom order itself
to reorder the slides with a simple rpc call to dataset/resequence.

Furthermore, having the uncategorized slides at the top of the list,
allows us to be coherent with the backend behaviour.

Another issue was that, on slide upload, in the controller, we used
the category_id on the slide (which seems to not always be correct at
this stage) instead of the one given by the javascript. This caused the slide
to not be uploaded in the right section.

LINKS:

TaskID: 2090927
PR: #39086
This commit adds some margin to the categories in frontend
for courses of type training.

The margin was needed to avoid having uncategorized slides
being too close to the first category.

LINKS:

TaskID: 2090927
PR: #39086
@qmo-odoo qmo-odoo force-pushed the odoo-dev:13.0-website-slides-fix-reordering-qmo branch from cfee211 to b22cfac Jan 15, 2020
@robodoo robodoo added the CI 🤖 label Jan 15, 2020
@qmo-odoo

This comment has been minimized.

Copy link
Contributor Author

qmo-odoo commented Jan 15, 2020

@awa-odoo Applied changes and updated the PR description

Copy link
Contributor

awa-odoo left a comment

Still not satisfied about the empty flag thing so I added more suggestions.
Please give it a try and we'll see how it looks.

Thanks for the PR description, looks better indeed!

For next time:
Put the bold part in a PURPOSE section and the bullet points in a SPECIFICATIONS section.
(For coherence with our other commit messages styling).

this.$('.o_wslides_slide_list_category > ul').each(function (){
var categoryID = $(this).data('categoryId');
var categorySlideCount = $(this).find('.o_wslides_slides_list_slide:not(.o_not_editable)').length;
var $emptyFlagContainer = self.$('.o_wslides_slide_list_category_header[data-category-id="'+ categoryID +'"] > div:first-child');
var $emptyFlag = $emptyFlagContainer.find('small');
if (categorySlideCount === 0 && $emptyFlag.length === 0){
$emptyFlagContainer.append($('<small>', {
'class': "ml-1 text-muted",
text: _t("Empty")
}));
} else if (categorySlideCount > 0 && $emptyFlag.length > 0){
$emptyFlag.remove();
}
Comment on lines +58 to 70

This comment has been minimized.

Copy link
@awa-odoo

awa-odoo Jan 16, 2020

Contributor

After some testing in my console:

  • Loop on o_wslides_slide_list_category instead.
    That way you can do $(this).find('.o_wslides_slide_list_category_header') directly, no need to do the categoryId trick.
  • Not sure about the > div:first-child part, can you remove it or find something more simple?
  • I would not try to find the container and then test for a 'small' tag.
    Instead, add a specific class on your small flag (o_wslides_no_category_flag) and test if it's there with $(this).find('o_wslides_no_category_flag').length
    Then you only need to find the appropriate container when you want to append.
    So $(this).find('o_wslides_slide_list_category_header [appropriate selector?]').append($('<small/>', { ... })

All this to try to simplify the code a little.
I find the new version very "code heavy" compared to the previous one.

@@ -30,6 +30,17 @@ var SlideArchiveDialog = Dialog.extend({
this.slideId = this.$slideTarget.data('slideId');
this._super(parent, options);
},
_displayCategoryEmptyFlag: function (){

This comment has been minimized.

Copy link
@awa-odoo

awa-odoo Jan 16, 2020

Contributor

Rename _checkForEmptySections for coherence.
And also check if any part of my previous comment applies here too.

@@ -46,8 +57,11 @@ var SlideArchiveDialog = Dialog.extend({
params: {
slide_id: this.slideId
},
}).then(function () {
self.$slideTarget.closest('.o_wslides_slides_list_slide').remove();
}).then(function (data) {

This comment has been minimized.

Copy link
@awa-odoo

awa-odoo Jan 16, 2020

Contributor

Rename data to is_archived

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.