From c9ace2713560905ea2aa5905e5ebe70312cd57ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Hennecart?= Date: Fri, 27 Dec 2019 06:50:45 +0000 Subject: [PATCH 1/3] [IMP] website_slides: improve the ui on a course (documentation) Before, uncategorized slides weren't display correctly on the slide_channel. It was impossible to view all the slides if there were more than 4 slides uncategorized because the "View all" link wasn't display. Now, when there is no section/category on a course, it displays the last 4 slides with the "View all" link which allows to be redirected to the uncategorized category (category_id=-1). This request displays all the uncategorized slides with a pager if the limit of 12 slides per page is exceeded. If there is at least one category created, all uncategorized slides are displayed under a section "Uncategorized". Additionaly, there is a new button which allows to create a category directly on the course page to allow the user to organize is course more effectively. task-2161391 --- addons/website_slides/controllers/main.py | 17 +++++++++++--- .../views/website_slides_templates_course.xml | 23 +++++++++++-------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index 05d4b455b06..ee023857b95 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -348,9 +348,12 @@ class WebsiteSlides(WebsiteProfile): '/slides//tag/', '/slides//tag//page/', '/slides//category/', - '/slides//category//page/' + '/slides//category//page/', ], type='http', auth="public", website=True, sitemap=sitemap_slide) def channel(self, channel, category=None, tag=None, page=1, slide_type=None, uncategorized=False, sorting=None, search=None, **kw): + """ + Will return all necessary data to display the requested slide_channel along with a possible category. + """ if not channel.can_access_from_current_website(): raise werkzeug.exceptions.NotFound() @@ -376,7 +379,7 @@ class WebsiteSlides(WebsiteProfile): pager_url += "/tag/%s" % tag.id if uncategorized: domain += [('category_id', '=', False)] - pager_url += "?uncategorized=1" + pager_args['uncategorized'] = 1 elif slide_type: domain += [('slide_type', '=', slide_type)] pager_url += "?slide_type=%s" % slide_type @@ -463,10 +466,18 @@ class WebsiteSlides(WebsiteProfile): # documentation mode may display less slides than content by category but overhead of # computation is reasonable values['slide_promoted'] = request.env['slide.slide'].sudo().search(domain, limit=1, order=order) + + limit_category_data = False + if channel.channel_type == 'documentation': + if category or uncategorized: + limit_category_data = self._slides_per_page + else: + limit_category_data = self._slides_per_category + values['category_data'] = channel._get_categorized_slides( domain, order, force_void=not category, - limit=False if channel.channel_type != 'documentation' else self._slides_per_page if category else self._slides_per_category, + limit=limit_category_data, offset=pager['offset']) values['channel_progress'] = self._get_channel_progress(channel, include_quiz=True) diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index 6f8887a8345..ab253f7ebb0 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -549,6 +549,12 @@ t-att-data-can-publish="channel.can_publish"> Upload new content + + Add a section +
@@ -592,11 +598,14 @@
-
- + + +
+
+ View all
@@ -609,14 +618,8 @@
- - -
- -
-
- +
From 68dd11b6f2f5b5bc1e414fe4b7f5e7b6098afcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Hennecart?= Date: Mon, 30 Dec 2019 06:58:40 +0000 Subject: [PATCH 2/3] [IMP] website_slides: upload document doesn't rewrite title everytime Before when you uploaded a document, the title was set to the filename even when the field was set by the user before. Now, the field title is set to the filename only when it is empty. task-2161391 --- addons/website_slides/static/src/js/slides_upload.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/website_slides/static/src/js/slides_upload.js b/addons/website_slides/static/src/js/slides_upload.js index 3d92cbbcb4a..828207840f1 100644 --- a/addons/website_slides/static/src/js/slides_upload.js +++ b/addons/website_slides/static/src/js/slides_upload.js @@ -516,7 +516,9 @@ var SlideUploadDialog = Dialog.extend({ if (!preventOnchange) { var input = file.name; var inputVal = input.substr(0, input.lastIndexOf('.')) || input; - this._formSetFieldValue('name', inputVal); + if (this._formGetFieldValue('name') === "") { + this._formSetFieldValue('name', inputVal); + } } }, _onChangeSlideUrl: function (ev) { From 9d94c1db9252eef0928d8f18dac83368ed763c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Hennecart?= Date: Mon, 30 Dec 2019 07:04:59 +0000 Subject: [PATCH 3/3] [IMP] website_slides: add customize button to display/hide the promoted slide There is now a button in the Customize tab which can be used to choose to display or hide the promoted slide of a course. task-2161391 --- .../views/website_slides_templates_course.xml | 66 +++++++++++-------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index ab253f7ebb0..eb276c03e7f 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -452,6 +452,38 @@ + + + +