From 774ce35fa8f0737315ad361cd9d5ddb2499e6b09 Mon Sep 17 00:00:00 2001 From: Du Peng Date: Thu, 22 Dec 2022 15:18:28 +0100 Subject: [PATCH] (feat) add accordion for calendar filter --- .../delete-machine-category-modal.tsx | 10 +++--- .../javascript/controllers/admin/calendar.js | 8 +++++ .../src/javascript/controllers/calendar.js | 8 +++++ app/frontend/templates/calendar/filter.html | 36 ++++++++++++------- .../templates/calendar/filterAside.html | 2 +- config/locales/app.admin.en.yml | 6 ++++ config/locales/app.admin.fr.yml | 6 ++++ 7 files changed, 58 insertions(+), 18 deletions(-) diff --git a/app/frontend/src/javascript/components/machines/delete-machine-category-modal.tsx b/app/frontend/src/javascript/components/machines/delete-machine-category-modal.tsx index 357c4479d..141670895 100644 --- a/app/frontend/src/javascript/components/machines/delete-machine-category-modal.tsx +++ b/app/frontend/src/javascript/components/machines/delete-machine-category-modal.tsx @@ -23,21 +23,21 @@ export const DeleteMachineCategoryModal: React.FC => { try { await MachineCategoryAPI.destroy(machineCategoryId); - onSuccess(t('app.admin.machines.delete_machine_category_modal.deleted')); + onSuccess(t('app.admin.delete_machine_category_modal.deleted')); } catch (e) { - onError(t('app.admin.machines.delete_machine_category_modal.unable_to_delete') + e); + onError(t('app.admin.delete_machine_category_modal.unable_to_delete') + e); } }; return ( - -

{t('app.admin.machines.delete_machine_category_modal.confirm_machine_category')}

+

{t('app.admin.delete_machine_category_modal.confirm_machine_category')}

); }; diff --git a/app/frontend/src/javascript/controllers/admin/calendar.js b/app/frontend/src/javascript/controllers/admin/calendar.js index dc0c97eaf..e9a88227e 100644 --- a/app/frontend/src/javascript/controllers/admin/calendar.js +++ b/app/frontend/src/javascript/controllers/admin/calendar.js @@ -451,6 +451,14 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state $scope.hasMachineCategory = _.some(machines, 'machine_category_id'); $scope.spaces = spaces; $scope.filter = filter; + $scope.accordion = { + trainings: false, + machines: false, + spaces: false + }; + $scope.machinesGroupByCategory.forEach(c => $scope.accordion[c.name] = false); + + $scope.toggleAccordion = (type) => $scope.accordion[type] = !$scope.accordion[type]; $scope.toggleFilter = (type, filter, machineCategoryId) => toggleFilter(type, filter, machineCategoryId); diff --git a/app/frontend/src/javascript/controllers/calendar.js b/app/frontend/src/javascript/controllers/calendar.js index b153235bd..743da2999 100644 --- a/app/frontend/src/javascript/controllers/calendar.js +++ b/app/frontend/src/javascript/controllers/calendar.js @@ -167,6 +167,14 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$ $scope.spaces = spaces; $scope.externals = externals; $scope.filter = filter; + $scope.accordion = { + trainings: false, + machines: false, + spaces: false + }; + $scope.machinesGroupByCategory.forEach(c => $scope.accordion[c.name] = false); + + $scope.toggleAccordion = (type) => $scope.accordion[type] = !$scope.accordion[type]; $scope.toggleFilter = (type, filter, machineCategoryId) => toggleFilter(type, filter, machineCategoryId); diff --git a/app/frontend/templates/calendar/filter.html b/app/frontend/templates/calendar/filter.html index eafbd6044..a88ffd769 100644 --- a/app/frontend/templates/calendar/filter.html +++ b/app/frontend/templates/calendar/filter.html @@ -1,30 +1,39 @@ -
+

{{ 'app.shared.calendar.show_unavailables' }}

-
+
-

{{ 'app.shared.calendar.trainings' }}

+

+ + {{ 'app.shared.calendar.trainings' }} +

-
+
{{::t.name}}
-
+
-

{{ 'app.shared.calendar.machines' }}

+

+ + {{ 'app.shared.calendar.machines' }} +

-
+
{{::m.name}}
-
- {{::category.name}} +
+ + + {{::category.name}} + -
+
{{::m.name}} @@ -34,10 +43,13 @@
-

{{ 'app.shared.calendar.spaces' }}

+

+ + {{ 'app.shared.calendar.spaces' }} +

-
+
{{::s.name}}
diff --git a/app/frontend/templates/calendar/filterAside.html b/app/frontend/templates/calendar/filterAside.html index 9c0d2b11e..9651c292f 100644 --- a/app/frontend/templates/calendar/filterAside.html +++ b/app/frontend/templates/calendar/filterAside.html @@ -1,7 +1,7 @@