mirror of
https://github.com/rickbarrette/redmine_qbo_labels.git
synced 2026-11-17 17:50:36 -05:00
Print label in the sidebar, filled in from the page
A Labels section in the sidebar of every page: Print label fills the label in from the page's customer (their name), estimate, invoice, appointment (its customer and estimate) or work order, or opens a blank label anywhere else. When there's a customer, the PO number field offers their latest estimates, invoices and open work orders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e29f14f76
commit
98a9bcc1bf
11 files changed
+239
-18
No files matched your search
@@ -8,7 +8,8 @@
|
||||
#
|
||||
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# The Print label dialog: opened from an issue, estimate or invoice (new), sends the label to a printer's
|
||||
# The Print label dialog: opened from an issue, estimate, invoice, customer or appointment, or blank from the
|
||||
# sidebar (new), sends the label to a printer's
|
||||
# queue (create), and follows it until it's printed (show, polled by the dialog). The dialog asks for show's
|
||||
# JSON with an Accept header, not a .json URL: Redmine treats .json as the REST API, without the session.
|
||||
class LabelJobsController < ApplicationController
|
||||
@@ -27,7 +28,7 @@ class LabelJobsController < ApplicationController
|
||||
@copies = params[:copies].to_i.clamp(1, LabelJob::MAX_COPIES)
|
||||
printer = @printers.find { |p| p.id == params[:printer_id].to_i } || @printers.first
|
||||
@job = LabelJob.new(label_printer: printer, user: User.current, lines: @lines, copies: @copies,
|
||||
source_type: @source.type, source_id: @source.id.to_s)
|
||||
source_type: @source.type, source_id: @source.id&.to_s)
|
||||
@job.save if printer
|
||||
respond_to { |format| format.js }
|
||||
end
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<%# The sidebar's Labels section (every page): Print label for what the page shows, or a blank label %>
|
||||
<h3><%= l(:label_qbo_labels_sidebar) %></h3>
|
||||
<p class="qbo-label-sidebar">
|
||||
<%= link_to sprite_icon('qbo-label-print', l(:button_qbo_labels_print), plugin: 'redmine_qbo_labels'),
|
||||
new_label_job_path({ source_type: source_type, source_id: source_id }.compact),
|
||||
remote: true, class: 'icon icon-qbo-label-print' %>
|
||||
<% if title %><br><span class="qbo-label-muted"><%= l(:text_qbo_labels_sidebar_for, title: title) %></span><% end %>
|
||||
</p>
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="qbo-label-preview-wrap">
|
||||
<canvas class="qbo-label-preview" width="1" height="1" aria-label="<%= l(:label_qbo_labels_preview) %>"></canvas>
|
||||
<div class="qbo-label-size"></div>
|
||||
<% if @source.title %><div class="qbo-label-for"><%= @source.title %></div><% end %>
|
||||
</div>
|
||||
|
||||
<div class="tabular">
|
||||
@@ -31,8 +32,17 @@
|
||||
</p>
|
||||
<p>
|
||||
<label for="qbo_label_line_1"><%= l(:field_qbo_labels_po_number) %></label>
|
||||
<% suggestions = @source.po_suggestions %>
|
||||
<%= text_field_tag 'lines[]', @lines[1], id: 'qbo_label_line_1', class: 'qbo-label-line',
|
||||
maxlength: LabelJob::MAX_LINE_LENGTH, autocomplete: 'off' %>
|
||||
maxlength: LabelJob::MAX_LINE_LENGTH, autocomplete: 'off',
|
||||
list: ('qbo_label_po_numbers' if suggestions.any?),
|
||||
placeholder: ('E1234, I1234, W1234' if @lines[1].blank?) %>
|
||||
<% if suggestions.any? %>
|
||||
<datalist id="qbo_label_po_numbers">
|
||||
<% suggestions.each do |number, description| %><option value="<%= number %>"><%= description %></option><% end %>
|
||||
</datalist>
|
||||
<em class="info"><%= l(:text_qbo_labels_po_suggestions) %></em>
|
||||
<% end %>
|
||||
</p>
|
||||
<p>
|
||||
<label for="qbo_label_copies"><%= l(:field_qbo_labels_copies) %></label>
|
||||
|
||||
Reference in new issue
Block a user