abstracted 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cf82f9a78eb2b9157a9c7e43d1c4dca96c50feb
4
- data.tar.gz: 289aeb77bdfbdb6e8119b84dc3e7fb79ffc6049e
3
+ metadata.gz: c055ab045bed2013b335f344091d2a575ac8ab2e
4
+ data.tar.gz: 117bad3453bc31008e31968da646d9ba37386d11
5
5
  SHA512:
6
- metadata.gz: 1ee14facdc1a14a5a62f02ea2eeb45cd6da86b791c88f4bdfee2a976aa149017561077d06e6cd27bda199ea2555c4a5fb48898a5f35f7de62e0fda9b13fa0d67
7
- data.tar.gz: 074c79200d18fc75ead0c0d3af7218f13f3f0e929ab464c1f0b90b84dbe761f9f26e3017b2f57ffce08747656c601504a80f7bb5c903c1999fa775d8812bb9ed
6
+ metadata.gz: dbc4574aa24d86adfd3fd778f0138f6f60b77490b0f470c5235b4a8012a97ddb51c577517454d31a643c0d496305639baf0fe56c5ef964fd1a162ebeaf9ddf15
7
+ data.tar.gz: a01485bc0301f39f5c587c362c4e9aed66a8235cdbd582aefa867cde994324b419945e20ad508633f256bf0a23b38acfede6d523de5f81d1c679479aaa0be9ad
@@ -5,7 +5,7 @@ require "parent_control"
5
5
 
6
6
  class AbstractResourcesController < ApplicationController
7
7
  self.responder = ::AbstractedResponder
8
- respond_to :html, :xml, :js, :json
8
+ respond_to :html, :xml, :js, :json #, :xlsx
9
9
 
10
10
  before_action :authenticate_user!
11
11
 
@@ -129,7 +129,12 @@ class AbstractResourcesController < ApplicationController
129
129
 
130
130
  def index
131
131
  authorize resource_class, :index?
132
- respond_with resources
132
+ respond_with resources do |format|
133
+ # format.xlsx {
134
+ # # response.headers['Content-Disposition'] = 'attachment; filename="current_tyre_stock.xlsx"'
135
+ # render xlsx: 'stock_items/index', template: 'current_tyre_stock', filename: "current_tyre_stock.xlsx", disposition: 'inline', xlsx_created_at: Time.now, xlsx_author: "http://wheelstore.space"
136
+ # }
137
+ end
133
138
  rescue Exception => e
134
139
  scoop_from_error e
135
140
  end
@@ -3,6 +3,19 @@ require 'exceptions'
3
3
  #
4
4
  class ApplicationController < ActionController::Base
5
5
 
6
+ #
7
+ # if you need a beta of some views - but with production data
8
+ #
9
+ # before_filter :setup_beta
10
+ #
11
+ # def setup_beta
12
+ # if request.subdomain == "beta"
13
+ # prepend_view_path "app/views/beta"
14
+ # # other beta setup
15
+ # end
16
+ # end
17
+
18
+
6
19
  # Prevent CSRF attacks by raising an exception.
7
20
  # For APIs, you may want to use :null_session instead.
8
21
  protect_from_forgery with: :exception
@@ -1,7 +1,8 @@
1
1
  require 'active_support/concern'
2
2
  #
3
3
  #
4
- # ARGS # first value is default
4
+ # ARGS # <a href="..?print[collation]=xx&print[paper]=yy.."
5
+ # # first value is default
5
6
  #
6
7
  # collation # 'list' | 'record'
7
8
  # paper # 'A4' | 'label' | ...
@@ -38,7 +39,7 @@ require 'active_support/concern'
38
39
  # TEMPLATE
39
40
  # id
40
41
  # account_id, # what 'system' / customer
41
- # template_key, # a key to search the template by
42
+ # template_key, # a key to search the template by - provided by ARGS[template]
42
43
  # template_path, # where the template is stored - like stock_items/print/zebra.html.haml
43
44
  # template_content, # or what the template contains - all HTML, CSS etc.
44
45
  # template_print_driver # identification of a particular driver -if necessary - like the :zebra
@@ -46,6 +47,16 @@ require 'active_support/concern'
46
47
  # created_at
47
48
  # updated_at
48
49
 
50
+ #
51
+ # PrintControl#print ->
52
+ # resource_class#print_list | resource#print | resource#send params[:print][:cmd] -> (PrintEngine)
53
+ # PrintJob#create ->
54
+ # BackgroundPrinterJob#perform_later pj ->
55
+ # PrintDrivers#print_with PrintDrivers#rendered_on | PrintDrivers#send_with PrintDrivers#rendered_on ->
56
+ # [Pdf|Html|Cab|Csv|Label]Printer#do_render -> ActionPrinter#do_render
57
+ # [Pdf|Html|Cab|Csv|Label]Printer#do_print ->
58
+
59
+
49
60
 
50
61
  module PrintControl
51
62
  extend ActiveSupport::Concern
@@ -75,6 +86,7 @@ module PrintControl
75
86
  def print
76
87
  authorize resource, :print?
77
88
  if resources.any?
89
+ params[:context] = self
78
90
  params[:printed_by] = current_user || User.first
79
91
  params[:print] ||= {}
80
92
  params[:print][:collation] ||= 'list'
@@ -97,8 +109,8 @@ module PrintControl
97
109
  end
98
110
  render :print, layout: false, status: status and return
99
111
 
100
- rescue Exception => e
101
- scoop_from_error e
112
+ # rescue Exception => e
113
+ # scoop_from_error e
102
114
  end
103
115
 
104
116
  #
@@ -109,7 +121,7 @@ module PrintControl
109
121
  case params[:print][:output_type].downcase
110
122
  # when 'html'; render params[:print][:view_template_path], layout: 'print'
111
123
  when 'html'; render "stock_items/print/_stock_items_list", layout: 'print'
112
- when 'pdf'; render action: :new, status: :unprocessable_entity
124
+ when 'pdf'; download_print_result
113
125
  end
114
126
  end
115
127
 
@@ -118,6 +130,8 @@ module PrintControl
118
130
  #
119
131
  def download_print_result
120
132
  params[:print][:output_type] ||= 'pdf'
133
+ params[:print][:medium]="download"
134
+ print_resources
121
135
  end
122
136
 
123
137
  #
@@ -129,6 +143,7 @@ module PrintControl
129
143
  flash[:error] = t('output.email.email_address_missing')
130
144
  return 301
131
145
  else
146
+ print_resources
132
147
  flash[:info] = t('output.email.email_sent')
133
148
  return 200
134
149
  end
@@ -169,7 +184,7 @@ module PrintControl
169
184
  when 'record'
170
185
  if params[:print][:cmd].blank?
171
186
  resources.each do |res|
172
- return PRINTRECERROR unless res.print_record params.merge context: self
187
+ return PRINTRECERROR unless res.print_record params
173
188
  end
174
189
  else
175
190
  resources.each do |res|
@@ -123,7 +123,7 @@ module AbstractResourcesHelper
123
123
  #
124
124
  # lnk = parent? ? (parent_url + "/#{resource_name}") : "/#{resource_name}"
125
125
  # lnk += options.empty? ? "" : "?" + options.collect{ |k,v| "#{k}=#{v}" }.join("&")
126
- options = resources if resources.class == Hash
126
+ options = resources if resources.class == Hash
127
127
  opt = {}
128
128
  opt.merge!(options) if options.class==Hash
129
129
  opt[:controller] ||= resource_class.table_name
@@ -307,8 +307,8 @@ module AbstractResourcesHelper
307
307
 
308
308
  def set_toasts
309
309
  toast_messages = []
310
- flash.each do |type, message|
311
- message_arr = message.size < 61 ? [message] : divide_text( message, [60,60,60,60] )
310
+ flash.each do |type, msg|
311
+ message_arr = msg.size < 61 ? [msg] : divide_text( msg, [60,60,60,60] )
312
312
  message_arr.each do |message|
313
313
  case type
314
314
  when 'error','danger','alert'; toast_messages << "Materialize.toast('#{message}',8000, 'red darken-4');"
@@ -557,7 +557,7 @@ module AbstractResourcesHelper
557
557
  end
558
558
  options[:data][:field] = (options.delete :field) || field
559
559
  options[:data][:direction] = (options.delete :direction) || @sorting_direction
560
- txt = []
560
+ # txt = []
561
561
  content_tag :th, options do
562
562
  if options[:role] && options[:role]=="sort"
563
563
  mark_sorted options[:data][:field], I18n.translate( "tables.headers.#{field}.label")
@@ -1,3 +1,4 @@
1
+ require 'pundit'
1
2
  # config/initializers/pundit.rb
2
3
  # Extends the ApplicationController to add Pundit for authorization.
3
4
  # Modify this file to change the behavior of a 'not authorized' error.
@@ -1,3 +1,3 @@
1
1
  module Abstracted
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -26,6 +26,7 @@ module Exceptions
26
26
  end
27
27
  end
28
28
 
29
+ class NoContextFound < OxenStandardError; end
29
30
  class NoPreferredPrintersFound < OxenStandardError; end
30
31
  class WhatAnError < OxenStandardError; end
31
32
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstracted
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walther H Diechmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -371,11 +371,9 @@ files:
371
371
  - spec/dummy/config/secrets.yml
372
372
  - spec/dummy/db/development.sqlite3
373
373
  - spec/dummy/db/schema.rb
374
- - spec/dummy/db/test.sqlite3
375
374
  - spec/dummy/lib/assets/.keep
376
375
  - spec/dummy/log/.keep
377
376
  - spec/dummy/log/development.log
378
- - spec/dummy/log/test.log
379
377
  - spec/dummy/public/404.html
380
378
  - spec/dummy/public/422.html
381
379
  - spec/dummy/public/500.html
@@ -627,11 +625,9 @@ test_files:
627
625
  - spec/dummy/config/secrets.yml
628
626
  - spec/dummy/db/development.sqlite3
629
627
  - spec/dummy/db/schema.rb
630
- - spec/dummy/db/test.sqlite3
631
628
  - spec/dummy/lib/assets/.keep
632
629
  - spec/dummy/log/.keep
633
630
  - spec/dummy/log/development.log
634
- - spec/dummy/log/test.log
635
631
  - spec/dummy/public/404.html
636
632
  - spec/dummy/public/422.html
637
633
  - spec/dummy/public/500.html