From 47e20d1b27a4752f084eb4025f5beff085803e57 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 5 Sep 2022 12:37:03 +0200 Subject: [PATCH] Add ability to disable zebra printers [SCI-7148] --- .../javascripts/repositories/repository_datatable.js | 9 +++++---- app/controllers/repository_rows_controller.rb | 2 +- app/models/label_printer.rb | 6 ++++++ app/views/repositories/_repository_table.html.erb | 2 ++ config/application.rb | 2 ++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/repositories/repository_datatable.js b/app/assets/javascripts/repositories/repository_datatable.js index 599b502c1..51a2cd087 100644 --- a/app/assets/javascripts/repositories/repository_datatable.js +++ b/app/assets/javascripts/repositories/repository_datatable.js @@ -15,7 +15,7 @@ var RepositoryDatatable = (function(global) { var TABLE_WRAPPER_ID = '.repository-table'; var TABLE = null; var EDITABLE = false; - var SELECT_ALL_SELECTOR = '#checkbox > input[name=select_all]'; + var SELECT_ALL_SELECTOR = '#checkbox input[name=select_all]'; const STATUS_POLLING_INTERVAL = 10000; var rowsSelected = []; @@ -156,7 +156,6 @@ var RepositoryDatatable = (function(global) { var $chkboxAll = $('.repository-row-selector', $table); var $chkboxChecked = $('.repository-row-selector:checked', $table); var chkboxSelectAll = $(SELECT_ALL_SELECTOR, $header).get(0); - // If none of the checkboxes are checked if ($chkboxChecked.length === 0) { chkboxSelectAll.checked = false; @@ -442,8 +441,10 @@ var RepositoryDatatable = (function(global) { className: 'dt-body-center', sWidth: '1%', render: function(data, type, row) { - return ` - `; + return `
+ + +
`; } }, { // Assigned column is not searchable diff --git a/app/controllers/repository_rows_controller.rb b/app/controllers/repository_rows_controller.rb index 09fa2757e..6c8b12ece 100644 --- a/app/controllers/repository_rows_controller.rb +++ b/app/controllers/repository_rows_controller.rb @@ -81,7 +81,7 @@ class RepositoryRowsController < ApplicationController def print_modal @repository_rows = @repository.repository_rows.where(id: params[:rows]) - @printers = LabelPrinter.all + @printers = LabelPrinter.available_printers @label_templates = LabelTemplate.where(team_id: current_team).order(:name) respond_to do |format| format.json do diff --git a/app/models/label_printer.rb b/app/models/label_printer.rb index 58aef02b8..aa32d1780 100644 --- a/app/models/label_printer.rb +++ b/app/models/label_printer.rb @@ -19,6 +19,12 @@ class LabelPrinter < ApplicationRecord validates :type_of, presence: true validates :language_type, presence: true + def self.available_printers + printers = all + printers = printers.where.not(type_of: :zebra) unless Rails.configuration.x.zebra_print_enabled + printers + end + def display_name "#{name} • #{description}" end diff --git a/app/views/repositories/_repository_table.html.erb b/app/views/repositories/_repository_table.html.erb index 8de022268..317999cbb 100644 --- a/app/views/repositories/_repository_table.html.erb +++ b/app/views/repositories/_repository_table.html.erb @@ -29,8 +29,10 @@ +
+
<%= t("repositories.table.assigned") %> <% if @repository.is_a?(LinkedRepository) %> diff --git a/config/application.rb b/config/application.rb index 3502399c5..a876d8dba 100644 --- a/config/application.rb +++ b/config/application.rb @@ -57,6 +57,8 @@ module Scinote config.x.webhooks_enabled = ENV['ENABLE_WEBHOOKS'] == 'true' + config.x.zebra_print_enabled = ENV['ENABLE_ZEBRA_PRINTERS'] == 'true' + # Logging config.log_formatter = proc do |severity, datetime, progname, msg| "[#{datetime}] #{severity}: #{msg}\n"