From eddcfbe12b862e786ba110c93aca9fe860e3aef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 13 May 2024 13:11:55 +0200 Subject: [PATCH] MOBILE-4470 forum: Change Sort order selector page to select combobox --- .../mod/forum/components/components.module.ts | 2 - .../mod/forum/components/index/index.html | 8 ++-- .../mod/forum/components/index/index.ts | 36 ++------------ .../sort-order-selector.html | 25 ---------- .../sort-order-selector.ts | 47 ------------------- 5 files changed, 10 insertions(+), 108 deletions(-) delete mode 100644 src/addons/mod/forum/components/sort-order-selector/sort-order-selector.html delete mode 100644 src/addons/mod/forum/components/sort-order-selector/sort-order-selector.ts diff --git a/src/addons/mod/forum/components/components.module.ts b/src/addons/mod/forum/components/components.module.ts index d57add762..9fd976bba 100644 --- a/src/addons/mod/forum/components/components.module.ts +++ b/src/addons/mod/forum/components/components.module.ts @@ -24,7 +24,6 @@ import { AddonModForumDiscussionOptionsMenuComponent } from './discussion-option import { AddonModForumIndexComponent } from './index/index'; import { AddonModForumPostComponent } from './post/post'; import { AddonModForumPostOptionsMenuComponent } from './post-options-menu/post-options-menu'; -import { AddonModForumSortOrderSelectorComponent } from './sort-order-selector/sort-order-selector'; @NgModule({ declarations: [ @@ -32,7 +31,6 @@ import { AddonModForumSortOrderSelectorComponent } from './sort-order-selector/s AddonModForumIndexComponent, AddonModForumPostComponent, AddonModForumPostOptionsMenuComponent, - AddonModForumSortOrderSelectorComponent, ], imports: [ CoreSharedModule, diff --git a/src/addons/mod/forum/components/index/index.html b/src/addons/mod/forum/components/index/index.html index 20bfbdbec..ed1795069 100644 --- a/src/addons/mod/forum/components/index/index.html +++ b/src/addons/mod/forum/components/index/index.html @@ -60,9 +60,11 @@
- + + + {{ order.label | translate }} + +
{ - if (this.discussions && sortOrder.value != this.discussions.getSource().selectedSortOrder?.value) { + async setSortOrder(sortOrderValue: number): Promise { + const sortOrder = this.sortOrders.find(sortOrder => sortOrder.value === sortOrderValue); + + if (this.discussions && sortOrder && sortOrder.value != this.discussions.getSource().selectedSortOrder?.value) { this.discussions.getSource().selectedSortOrder = sortOrder; this.discussions.getSource().setDirty(true); - if (this.sortOrderSelectorModalOptions.componentProps) { - this.sortOrderSelectorModalOptions.componentProps.selected = sortOrder.value; - } - try { await CoreUser.setUserPreference(AddonModForumProvider.PREFERENCE_SORTORDER, sortOrder.value.toFixed(0)); await this.showLoadingAndFetch(); @@ -625,17 +610,6 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom } } - /** - * Display the sort order selector modal. - */ - async showSortOrderSelector(): Promise { - const modalData = await CoreDomUtils.openModal(this.sortOrderSelectorModalOptions); - - if (modalData) { - this.setSortOrder(modalData); - } - } - /** * Show the context menu. * diff --git a/src/addons/mod/forum/components/sort-order-selector/sort-order-selector.html b/src/addons/mod/forum/components/sort-order-selector/sort-order-selector.html deleted file mode 100644 index 77c0309ad..000000000 --- a/src/addons/mod/forum/components/sort-order-selector/sort-order-selector.html +++ /dev/null @@ -1,25 +0,0 @@ - - - -

{{ 'core.sort' | translate }}

-
- - - - -
-
- - - - - -

{{ sortOrder.label | translate }}

-
-
-
-
-
diff --git a/src/addons/mod/forum/components/sort-order-selector/sort-order-selector.ts b/src/addons/mod/forum/components/sort-order-selector/sort-order-selector.ts deleted file mode 100644 index 6de83877c..000000000 --- a/src/addons/mod/forum/components/sort-order-selector/sort-order-selector.ts +++ /dev/null @@ -1,47 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component, Input } from '@angular/core'; -import { AddonModForumSortOrder } from '@addons/mod/forum/services/forum'; -import { ModalController } from '@singletons'; - -/** - * Page that displays the sort selector. - */ -@Component({ - selector: 'page-addon-mod-forum-sort-order-selector', - templateUrl: 'sort-order-selector.html', -}) -export class AddonModForumSortOrderSelectorComponent { - - @Input() sortOrders!: AddonModForumSortOrder[]; - @Input() selected!: number; - - /** - * Close the modal. - */ - closeModal(): void { - ModalController.dismiss(); - } - - /** - * Select a sort order. - * - * @param sortOrder Selected sort order. - */ - selectSortOrder(sortOrder: AddonModForumSortOrder): void { - ModalController.dismiss(sortOrder); - } - -}