oxen_printer 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3926f0dc3bad41ffe690545fb03beea76eb5482
4
- data.tar.gz: ed071ff53e49d90317bf37744b1bd9049cb05ec0
3
+ metadata.gz: caa611fe8eaed2c7561df42cd74a67972da98ffa
4
+ data.tar.gz: 74423e5f503c64fe31e2d5bb36218737a0ee1645
5
5
  SHA512:
6
- metadata.gz: 510a1ea5d4a260c6563a808778defa8da6eb6507191e34123c6e9669c62af4fb4be5515dd79ae795fe22890e388ff56fe9f2026a5ea5ef9c04b48105db0ee8d8
7
- data.tar.gz: efb4fc3b9c431b712bf426bd424aae5cf3088a2c93986204ceea360d05d240038f743ad07e50e599cdbc7b04a4c29ce30f311a6cff8d70ed7c1174fa993b8a9b
6
+ metadata.gz: 1de9ca3d0f5346ac03d81f38c2fecbd5037dae1ea935e753072aaa39dbd9b010805d9a481ae6cbb74bf843c99f15a919696f645ea467dd4f9acb1766abcf8af7
7
+ data.tar.gz: 5f2e118102f6faa21622243a95144540367a12d0ce0b365dfd0ec92f01ff050bbeb310cf4d9cf58f6810e76587a2ca7f9935362bb996cea7c26fb2ba20bc5b79
@@ -0,0 +1,342 @@
1
+ { div, form, input, textarea, select, option, label, h4, p, a } = React.DOM
2
+ #
3
+ #
4
+ # ARGS # first value is default
5
+ #
6
+ # collation # 'list' | 'record'
7
+ # paper # 'A4' | 'label' | ...
8
+ # template # '' | 'slip' | 'quote'
9
+ # cmd # '' | 'print_label' - a particular method on the printing_class
10
+ #
11
+ # PRINTPROMPT
12
+ # print[medium] # 'display' | 'email' | 'printer' | 'download'
13
+ # print[output_type] # 'html' | 'pdf' | 'text'
14
+ # print[printer] # what printer to send output to
15
+ # print[email_to] # email address
16
+ # print[message] # body of email
17
+ # print[range] # which pages should print
18
+ # print[copies] # number of copies
19
+ #
20
+ # PRINTJOB
21
+ # id,
22
+ # account_id, # what 'system' / customer
23
+ # printer_id, # on what printer
24
+ # printed_by_id, # what id has the printed_by entity
25
+ # printed_by_type, # what entity - like user
26
+ # view_template_path, # what template
27
+ # name, # label the job
28
+ # printing_class, # what entity provides the data
29
+ # print_driver, # what 'driver' - like :pdf, :cab, :zebra, :csv, :html, etc
30
+ # print_format, # data collation - like 'record', 'list'
31
+ # state, # record the progress
32
+ # paper, # what material - like 'label32x42', 'A4', etc
33
+ # copies, # number of identical prints
34
+ # print_sql, # how to find what will be printed
35
+ # created_at,
36
+ # updated_at
37
+ #
38
+ #
39
+
40
+ class @PrintPrompt extends React.Component
41
+ constructor: (props) ->
42
+ super props
43
+ @state =
44
+ url: props.url
45
+ collation: props.collation
46
+ template: props.template
47
+ paper: props.paper
48
+ user_id: props.user_id
49
+ user_email: props.user_email
50
+ shared: new App.Shared()
51
+ printers_url: "/admin/users/" + props.user_id + "/printers.json"
52
+ wurl: ""
53
+ args: ""
54
+
55
+ @propTypes =
56
+ url: React.PropTypes.string
57
+ template: React.PropTypes.string
58
+ paper: React.PropTypes.string
59
+ user_id: React.PropTypes.number
60
+ collation: React.PropTypes.string
61
+ user_email: React.PropTypes.string
62
+
63
+ @defaultProps =
64
+ url: ""
65
+ collation: "list"
66
+ template: ""
67
+ paper: "A4"
68
+ user_id: 1
69
+ user_email: ""
70
+
71
+ getPrinterList: (e) =>
72
+ jqxhr = $.ajax
73
+ url: @state.printers_url
74
+ method: 'GET'
75
+ .done (printers) ->
76
+ @obj=$("#user_suggested_printer_list")
77
+ for printer in printers
78
+ opt = document.createElement("option")
79
+ opt.value = printer.id
80
+ opt.text = printer.name
81
+ @obj.append opt
82
+ @obj.material_select()
83
+ .fail (data) ->
84
+ console.log 'fejl ' + @u
85
+
86
+ hidePrinterList: (e) =>
87
+ $('.select-wrapper.printer_list').hide()
88
+
89
+ showPrinterList: (e) =>
90
+ $('.select-wrapper.printer_list').show()
91
+
92
+ hideEmailForm: (e) =>
93
+ $('.emailForm').hide()
94
+
95
+ showEmailForm: (e) =>
96
+ $('.emailForm').show()
97
+
98
+ hideDisplayForm: (e) =>
99
+ $('.displayForm').hide()
100
+
101
+ showDisplayForm: (e) =>
102
+ $('.displayForm').show()
103
+
104
+ onDisplay: (e) =>
105
+ @hidePrinterList()
106
+ @hideEmailForm()
107
+ @showDisplayForm()
108
+
109
+ onEmail: (e) =>
110
+ @hidePrinterList()
111
+ @hideDisplayForm()
112
+ @showEmailForm()
113
+
114
+ onPrint: (e) =>
115
+ @showPrinterList()
116
+ @hideEmailForm()
117
+ @hideDisplayForm()
118
+
119
+ onDownload: (e)=>
120
+ @hidePrinterList()
121
+ @hideEmailForm()
122
+ @hideDisplayForm()
123
+
124
+ onHTML_PDF: (e) =>
125
+ if $(e.currentTarget).attr('id') == "display_file_as_pdf"
126
+ $("#display_file_as_html").prop 'checked', !$("#display_file_as_pdf").prop('checked')
127
+ else
128
+ $("#display_file_as_pdf").prop 'checked', !$("#display_file_as_html").prop('checked')
129
+
130
+ cancelModal: (e) =>
131
+ App.shared.spinWhileLoading()
132
+ $("#print-dialog").closeModal()
133
+
134
+ animatePrint: (e) =>
135
+ if e
136
+ $(".print-ok-button").html('<div class="la-square-loader"><div></div></div>')
137
+ else
138
+ $(".print-ok-button").html('Ok')
139
+
140
+ sendPrintRequest: (e) =>
141
+ @animatePrint(e)
142
+ wrl = @state.url
143
+ arg = @state.args
144
+ if wrl=='href'
145
+ wrl = window.location.href.replace( /#!$/, "")
146
+ if wrl.match /\?/
147
+ w = wrl.split("?")[0] + "/print"
148
+ arg = wrl.split("?")[1] + "&"
149
+ else
150
+ w = wrl + "/print"
151
+ arg = "&collation=#{@state.collation}&template=#{@state.template}&paper=#{@state.paper}"
152
+ @setState {wurl: w, args: arg}, () =>
153
+ @form = $('#print-dialog form')
154
+ jqxhr = $.ajax
155
+ url: @state.wurl
156
+ method: "GET"
157
+ data: @form.serialize() + '&' + @state.args
158
+ dataType: 'html'
159
+ .done (data) =>
160
+ console.log 'done'
161
+ @animatePrint()
162
+ $("#print-dialog").closeModal()
163
+ .fail (data) =>
164
+ console.log 'fail'
165
+ @animatePrint()
166
+ $("#print-dialog").closeModal()
167
+
168
+
169
+
170
+ componentDidMount: ->
171
+ $(document.body).on 'app:print-dialog:state:changed', (e) =>
172
+ @setState(e.state)
173
+ @getPrinterList()
174
+ @hidePrinterList()
175
+ @hideEmailForm()
176
+ $('#print_email_to').val @state.user_email
177
+
178
+
179
+ render: ->
180
+ div
181
+ className: "modal"
182
+ id: "print-dialog"
183
+ div
184
+ className: "modal-content"
185
+ div
186
+ className: "container"
187
+ div
188
+ className: "row"
189
+ div
190
+ className: "col s12 m12 l12"
191
+ h4
192
+ className: "h4"
193
+ "Se, sende eller udskrive?"
194
+ p
195
+ className: "p"
196
+ "Dette printjob har du mulighed for at se på flere måder - du kan udskrive det direkte på en printer, sende en email besked hvor du hæfter det ved, eller få det vist som PDF på skærmen. Valget er dit"
197
+ div
198
+ className: "row"
199
+ div
200
+ className: "col s12 m12 l12"
201
+ form
202
+ className: "print_form"
203
+ div
204
+ className: "row"
205
+ div
206
+ className: "col s12 m6 l6"
207
+ p
208
+ className: "p"
209
+ input
210
+ className: "with-gap"
211
+ id: "display"
212
+ type: "radio"
213
+ name: "print[medium]"
214
+ value: "display"
215
+ onClick: @onDisplay
216
+ label
217
+ className: "label"
218
+ htmlFor: "display"
219
+ "På skærmen"
220
+ p
221
+ className: "p"
222
+ input
223
+ className: "with-gap"
224
+ id: "email"
225
+ type: "radio"
226
+ name: "print[medium]"
227
+ value: "email"
228
+ onClick: @onEmail
229
+ label
230
+ className: "label"
231
+ htmlFor: "email"
232
+ "Vedhæftet en email"
233
+ p
234
+ className: "p"
235
+ input
236
+ className: "with-gap"
237
+ id: "printer"
238
+ type: "radio"
239
+ name: "print[medium]"
240
+ value: "printer"
241
+ onClick: @onPrint
242
+ label
243
+ className: "label"
244
+ htmlFor: "printer"
245
+ "til printer"
246
+ p
247
+ className: "p"
248
+ input
249
+ className: "with-gap"
250
+ id: "download"
251
+ type: "radio"
252
+ name: "print[medium]"
253
+ value: "download"
254
+ onClick: @onDownload
255
+ label
256
+ className: "label"
257
+ htmlFor: "download"
258
+ "som fil"
259
+
260
+ div
261
+ className: "col s12 m6 l6"
262
+ p
263
+ className: "p"
264
+ select
265
+ className: "printer_list"
266
+ name: "print[printer]"
267
+ id: "user_suggested_printer_list"
268
+ defaultValue: "0"
269
+ option
270
+ className: "printer_list_option"
271
+ value:"0"
272
+ disabled: "true"
273
+ "Vælg en printer"
274
+
275
+ label
276
+ className: "label"
277
+ "Printer"
278
+ p
279
+ className: "p displayForm"
280
+ input
281
+ className: "with-gap"
282
+ id: "display_file_as_html"
283
+ type: "checkbox"
284
+ name: "print[output_type]"
285
+ value: "html"
286
+ onClick: @onHTML_PDF
287
+ label
288
+ className: "label"
289
+ htmlFor: "display_file_as_html"
290
+ "HTML"
291
+ p
292
+ className: "p displayForm"
293
+ input
294
+ className: "with-gap"
295
+ id: "display_file_as_pdf"
296
+ type: "checkbox"
297
+ name: "print[output_type]"
298
+ value: "pdf"
299
+ onClick: @onHTML_PDF
300
+ label
301
+ className: "label"
302
+ htmlFor: "display_file_as_pdf"
303
+ "PDF"
304
+ p
305
+ className: "p emailForm"
306
+ label
307
+ className: 'label'
308
+ htmlFor: "print_email_to"
309
+ "Modtager:"
310
+ input
311
+ className: "text"
312
+ id: "print_email_to"
313
+ type: "text"
314
+ name: "print[email_to]"
315
+
316
+ div
317
+ className: "col s12 m12 l12"
318
+ p
319
+ className: "p emailForm"
320
+ label
321
+ className: 'label'
322
+ htmlFor: "print_message"
323
+ "Besked:"
324
+ textarea
325
+ className: "materialize-textarea"
326
+ id: "print_message"
327
+ name: "print[message]"
328
+
329
+
330
+
331
+ div
332
+ className: "modal-footer"
333
+ a
334
+ className: "print-ok-button green btn modal-action waves-effect waves-green"
335
+ href: "#!"
336
+ onClick: @sendPrintRequest
337
+ "Ok"
338
+ a
339
+ className: "orange btn modal-action waves-effect waves-orange"
340
+ href: "#!"
341
+ onClick: @cancelModal
342
+ "Fortryd"
@@ -0,0 +1 @@
1
+ //= require_tree ./components
@@ -0,0 +1,3 @@
1
+ %html
2
+ %body
3
+ = yield
@@ -0,0 +1,15 @@
1
+ class CreateTemplates < ActiveRecord::Migration
2
+ def change
3
+ create_table :templates do |t|
4
+ t.references :account, index: true, foreign_key: true
5
+ t.string :template_key
6
+ t.string :template_path
7
+ t.string :template_print_driver # use to identify if template only works with a particular driver, like the :zebra
8
+ t.string :template_paper # use to identify if template only works with a particular paper, like the :label10x32
9
+ t.text :template_content
10
+ t.integer :lock_version, default: 1
11
+
12
+ t.timestamps null: false
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module OxenPrinter
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxen_printer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walther H Diechmann
@@ -65,6 +65,8 @@ files:
65
65
  - LICENSE.txt
66
66
  - README.md
67
67
  - Rakefile
68
+ - app/assets/javascripts/components/print_prompt.js.jsx.coffee
69
+ - app/assets/javascripts/oxem_printer.js
68
70
  - app/controllers/oxen/print_jobs_controller.rb
69
71
  - app/controllers/oxen/printers_controller.rb
70
72
  - app/jobs/background_printer_job.rb
@@ -74,6 +76,7 @@ files:
74
76
  - app/models/ox_printer.rb
75
77
  - app/models/ox_template.rb
76
78
  - app/policies/oxen/print_job_policy.rb
79
+ - app/views/layouts/1mailer.html.haml
77
80
  - app/views/oxen/print_jobs/_form.html.haml
78
81
  - app/views/oxen/print_jobs/_print_job.html.haml
79
82
  - app/views/oxen/print_jobs/_print_jobs.html.haml
@@ -98,6 +101,7 @@ files:
98
101
  - lib/generators/printer/templates/print_job.rb
99
102
  - lib/generators/printer/templates/printable.rb
100
103
  - lib/generators/printer/templates/printer.rb
104
+ - lib/generators/printer/templates/template.rb
101
105
  - lib/java_pdf/LICENSE
102
106
  - lib/java_pdf/LICENSE-LGPL-2.1.txt
103
107
  - lib/java_pdf/LICENSE-W3C-TEST