Add ability to disable zebra printers [SCI-7148]

This commit is contained in:
Anton 2022-09-05 12:37:03 +02:00
parent a5fc66a6f3
commit 47e20d1b27
5 changed files with 16 additions and 5 deletions

View file

@ -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 `<input class='repository-row-selector sci-checkbox' type='checkbox' data-editable="${row.recordEditable}">
<span class='sci-checkbox-label'></span>`;
return `<div class="sci-checkbox-container">
<input class='repository-row-selector sci-checkbox' type='checkbox' data-editable="${row.recordEditable}">
<span class='sci-checkbox-label'></span>
</div>`;
}
}, {
// Assigned column is not searchable

View file

@ -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

View file

@ -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

View file

@ -29,8 +29,10 @@
<thead>
<tr>
<th id="checkbox" data-unmanageable="true">
<div class="sci-checkbox-container">
<input name="select_all" value="1" type="checkbox" class="sci-checkbox">
<span class="sci-checkbox-label"></span>
</div>
</th>
<th id="assigned" data-unmanageable="true"><%= t("repositories.table.assigned") %></th>
<% if @repository.is_a?(LinkedRepository) %>

View file

@ -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"