From 213c752941835030bbae585680ff63f55ac9a10c Mon Sep 17 00:00:00 2001 From: wandji20 Date: Tue, 26 Sep 2023 15:20:18 +0100 Subject: [PATCH] Improve UI for for exports in inventory with stock enabled [SCI-9225] --- app/assets/stylesheets/repositories.scss | 36 +++++++++ .../vue/components/action_toolbar.vue | 74 +++++++++++++++---- .../toolbars/repository_rows_service.rb | 15 +++- config/locales/en.yml | 6 +- 4 files changed, 110 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/repositories.scss b/app/assets/stylesheets/repositories.scss index c99ce21c4..8ea425b8a 100644 --- a/app/assets/stylesheets/repositories.scss +++ b/app/assets/stylesheets/repositories.scss @@ -1,5 +1,6 @@ // scss-lint:disable SelectorDepth SelectorFormat QualifyingElement // scss-lint:disable NestingDepth ImportantRule +// scss-lint:disable IdSelector .repository-show { margin: 0; @@ -100,6 +101,41 @@ } } + #actionToolbar { + #exportDropdown { + background-color: var(--sn-white); + color: var(--sn-blue); + height: 36px; + + &:hover { + background-color: var(--sn-blue); + color: var(--sn-white); + } + } + + .sci-dropdown { + &.open { + [data-toggle="dropdown"] { + border-color: transparent; + border-radius: .25rem; + } + } + + .dropdown-menu { + padding: .5rem; + + li > a { + color: var(--sn-blue); + padding: .375rem .625rem; + + &:hover { + background-color: $color-concrete; + } + } + } + } + } + .dataTables_scroll { display: flex; flex-direction: column; diff --git a/app/javascript/vue/components/action_toolbar.vue b/app/javascript/vue/components/action_toolbar.vue index 6b57d05a2..3b1249a5e 100644 --- a/app/javascript/vue/components/action_toolbar.vue +++ b/app/javascript/vue/components/action_toolbar.vue @@ -11,22 +11,62 @@ {{ i18n.t('action_toolbar.no_actions') }}
- - - {{ action.label }} - +
+ + +
+ + + {{ action.group_label }} + + + + {{ action.label }} + +
- @@ -151,6 +191,10 @@ }); break; } + }, + closeExportDropdown(event) { + event.preventDefault(); + $(event.target).closest('.export-actions-dropdown').removeClass('open') } } } diff --git a/app/services/toolbars/repository_rows_service.rb b/app/services/toolbars/repository_rows_service.rb index 927daded2..cc1f36426 100644 --- a/app/services/toolbars/repository_rows_service.rb +++ b/app/services/toolbars/repository_rows_service.rb @@ -32,8 +32,7 @@ module Toolbars edit_action, assign_action, duplicate_action, - export_items_action, - export_consumption_action, + export_actions, print_label_action, archive_action, delete_action @@ -107,7 +106,7 @@ module Toolbars { name: 'export_records', - label: I18n.t('repositories.export_records'), + label: I18n.t('repositories.exports.records'), icon: 'sn-icon sn-icon-export', button_class: 'export-repository-row-btn', button_id: 'exportRepositoryRowsButton', @@ -120,7 +119,7 @@ module Toolbars { name: 'export_consumption', - label: I18n.t('repositories.export_stock_consumption'), + label: I18n.t('repositories.exports.stock_consumption'), icon: 'sn-icon sn-icon-reports', button_class: 'export-repository-stock-consumption-btn', button_id: 'exportStockConsumptionButton', @@ -128,6 +127,14 @@ module Toolbars } end + def export_actions + { + type: :group, + group_label: I18n.t('repositories.exports.export'), + actions: [export_items_action, export_consumption_action].compact + } + end + def print_label_action return unless can_read_repository?(@repository) diff --git a/config/locales/en.yml b/config/locales/en.yml index ab3a878e6..8bdedd73a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2107,8 +2107,10 @@ en: archive_record: "Archive" restore_record: "Restore" print_label: "Print label" - export_records: "Export items" - export_stock_consumption: "Export consumption" + exports: + export: "Export" + records: "Items" + stock_consumption: "Consumption" save_record: "Save" cancel_save: "Cancel" hide_reminders: "Clear all reminders"