diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 2f562a5ca..4ec0abb03 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -46,6 +46,8 @@ class RepositoriesController < ApplicationController def list results = @repositories results = results.name_like(params[:query]) if params[:query].present? + results = results.joins(:repository_rows).distinct if params[:non_empty].present? + render json: { data: results.map { |r| [r.id, r.name] } } end diff --git a/app/javascript/vue/storage_locations/container.vue b/app/javascript/vue/storage_locations/container.vue index 0cfa9cbbc..b4e88c92e 100644 --- a/app/javascript/vue/storage_locations/container.vue +++ b/app/javascript/vue/storage_locations/container.vue @@ -125,34 +125,43 @@ export default { }, columnDefs() { - const columns = [{ - field: 'position_formatted', - headerName: this.i18n.t('storage_locations.show.table.position'), - sortable: true, - cellClass: 'text-sn-blue cursor-pointer' - }, - { - field: 'reminders', - headerName: this.i18n.t('storage_locations.show.table.reminders'), - sortable: false, - cellRenderer: RemindersRender - }, - { - field: 'row_id', - headerName: this.i18n.t('storage_locations.show.table.row_id'), - sortable: true - }, - { - field: 'row_name', - headerName: this.i18n.t('storage_locations.show.table.row_name'), - sortable: true, - cellRenderer: ItemNameRenderer - }, - { - field: 'stock', - headerName: this.i18n.t('storage_locations.show.table.stock'), - sortable: false - }]; + let columns = []; + + if (this.withGrid) { + columns.push({ + field: 'position_formatted', + headerName: this.i18n.t('storage_locations.show.table.position'), + sortable: true, + cellClass: 'text-sn-blue cursor-pointer' + }); + } + + columns = columns.concat( + [ + { + field: 'reminders', + headerName: this.i18n.t('storage_locations.show.table.reminders'), + sortable: false, + cellRenderer: RemindersRender + }, + { + field: 'row_code', + headerName: this.i18n.t('storage_locations.show.table.row_id'), + sortable: true + }, + { + field: 'row_name', + headerName: this.i18n.t('storage_locations.show.table.row_name'), + sortable: true, + cellRenderer: ItemNameRenderer + }, + { + field: 'stock', + headerName: this.i18n.t('storage_locations.show.table.stock'), + sortable: false + } + ] + ); return columns; }, diff --git a/app/javascript/vue/storage_locations/modals/assign/row_selector.vue b/app/javascript/vue/storage_locations/modals/assign/row_selector.vue index 24411cd53..ac26f07ea 100644 --- a/app/javascript/vue/storage_locations/modals/assign/row_selector.vue +++ b/app/javascript/vue/storage_locations/modals/assign/row_selector.vue @@ -48,7 +48,7 @@ export default { }, computed: { repositoriesUrl() { - return list_team_repositories_path(this.teamId); + return list_team_repositories_path(this.teamId, { non_empty: true }); }, rowsUrl() { if (!this.selectedRepository) { diff --git a/app/serializers/lists/storage_location_repository_row_serializer.rb b/app/serializers/lists/storage_location_repository_row_serializer.rb index 00509d457..a4df12a4f 100644 --- a/app/serializers/lists/storage_location_repository_row_serializer.rb +++ b/app/serializers/lists/storage_location_repository_row_serializer.rb @@ -6,9 +6,13 @@ module Lists include Rails.application.routes.url_helpers attributes :created_by, :created_on, :position, :row_id, :row_name, :hidden, :position_formatted, :stock, - :have_reminders, :reminders_url, :row_url + :have_reminders, :reminders_url, :row_url, :row_code def row_id + object.repository_row.id + end + + def row_code object.repository_row.code end