lipsiadmin 5.1.6 → 5.1.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.
- data/lib/access_control/authentication.rb +20 -20
- data/lib/access_control/base.rb +40 -40
- data/lib/controller/ext.rb +27 -27
- data/lib/controller/lipsiadmin_controller.rb +3 -3
- data/lib/controller/pdf_builder.rb +33 -31
- data/lib/controller/rescue.rb +12 -12
- data/lib/controller/responds_to_parent.rb +5 -5
- data/lib/data_base/attachment.rb +60 -60
- data/lib/data_base/attachment/attach.rb +18 -18
- data/lib/data_base/attachment/geometry.rb +7 -7
- data/lib/data_base/attachment/iostream.rb +1 -1
- data/lib/data_base/attachment/processor.rb +2 -2
- data/lib/data_base/attachment/storage.rb +11 -11
- data/lib/data_base/attachment/thumbnail.rb +2 -2
- data/lib/data_base/attachment_table.rb +27 -27
- data/lib/data_base/translate_attributes.rb +9 -9
- data/lib/data_base/utility_scopes.rb +7 -7
- data/lib/data_base/without_table.rb +10 -10
- data/lib/generator.rb +4 -4
- data/lib/loops.rb +77 -77
- data/lib/loops/base.rb +2 -2
- data/lib/loops/daemonize.rb +5 -5
- data/lib/loops/process_manager.rb +3 -3
- data/lib/loops/worker.rb +1 -1
- data/lib/loops/worker_pool.rb +1 -1
- data/lib/mailer/exception_notifier.rb +5 -5
- data/lib/mailer/pdf_builder.rb +20 -18
- data/lib/utils/literal.rb +6 -6
- data/lib/utils/pdf_builder.rb +10 -10
- data/lib/version.rb +1 -1
- data/lib/view/helpers/backend_helper.rb +123 -123
- data/lib/view/helpers/ext/button.rb +7 -7
- data/lib/view/helpers/ext/column_model.rb +18 -18
- data/lib/view/helpers/ext/component.rb +50 -50
- data/lib/view/helpers/ext/configuration.rb +5 -5
- data/lib/view/helpers/ext/grid.rb +46 -46
- data/lib/view/helpers/ext/store.rb +14 -14
- data/lib/view/helpers/ext/tool_bar.rb +6 -6
- data/lib/view/helpers/ext_helper.rb +21 -21
- data/lib/view/helpers/frontend_helper.rb +5 -5
- data/lib/view/helpers/pdf_helper.rb +7 -7
- data/lib/view/helpers/view_helper.rb +28 -28
- data/lipsiadmin_generators/attachment/attachment_generator.rb +7 -7
- data/lipsiadmin_generators/attachment/templates/controller.rb +13 -13
- data/lipsiadmin_generators/attachment/templates/migration.rb +1 -1
- data/lipsiadmin_generators/backend/backend_generator.rb +9 -9
- data/lipsiadmin_generators/backend/templates/controllers/backend/accounts_controller.rb +10 -10
- data/lipsiadmin_generators/backend/templates/controllers/backend/sessions_controller.rb +2 -2
- data/lipsiadmin_generators/backend/templates/controllers/javascripts_controller.rb +2 -2
- data/lipsiadmin_generators/backend/templates/migrations/create_accounts.rb +5 -5
- data/lipsiadmin_generators/backend/templates/models/account.rb +16 -16
- data/lipsiadmin_generators/backend/templates/models/account_access.rb +11 -11
- data/lipsiadmin_generators/backend/templates/models/notifier.rb +2 -2
- data/lipsiadmin_generators/backend_page/backend_page_generator.rb +22 -22
- data/lipsiadmin_generators/backend_page/templates/controller.rb +9 -9
- data/lipsiadmin_generators/backend_page/templates/functional_test.rb +10 -10
- data/lipsiadmin_generators/frontend/frontend_generator.rb +5 -5
- data/lipsiadmin_generators/frontend/templates/controllers/frontend/sessions_controller.rb +3 -3
- data/lipsiadmin_generators/loops/loops_generator.rb +2 -2
- data/lipsiadmin_generators/pdf/pdf_generator.rb +7 -7
- data/lipsiadmin_generators/state_session/state_session_generator.rb +9 -9
- data/lipsiadmin_generators/state_session/templates/controller.rb +2 -2
- data/lipsiadmin_generators/state_session/templates/migration.rb +2 -2
- data/resources/rdoc/horo.rb +3 -3
- metadata +4 -4
data/lib/mailer/pdf_builder.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
module Lipsiadmin
|
2
2
|
module Mailer
|
3
3
|
# This module convert a string/controller to a pdf through Pd4ml java library (included in this plugin)
|
4
|
-
#
|
5
|
-
# PD4ML is a powerful PDF generating tool that uses HTML and CSS (Cascading Style Sheets) as page layout
|
6
|
-
# and content definition format. Written in 100% pure Java, it allows users to easily add PDF generation
|
4
|
+
#
|
5
|
+
# PD4ML is a powerful PDF generating tool that uses HTML and CSS (Cascading Style Sheets) as page layout
|
6
|
+
# and content definition format. Written in 100% pure Java, it allows users to easily add PDF generation
|
7
7
|
# functionality to end products.
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# For generate a pdf you can simply do
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# script/generate pdf invoice
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# then edit your template /app/views/pdf/invoice.html.haml
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# Then in any of your mailers add some like this:
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# def order_invoiced(order)
|
18
18
|
# recipients my@mail.com
|
19
19
|
# from my@server.com
|
@@ -25,31 +25,31 @@ module Lipsiadmin
|
|
25
25
|
#
|
26
26
|
# part "text/plain" do |a|
|
27
27
|
# a.body = render_message("order_invoiced", :order => order, :body_template => @body_template)
|
28
|
-
# end
|
28
|
+
# end
|
29
29
|
# end
|
30
30
|
#
|
31
|
-
# Lipsiadmin include a trial fully functional evaluation version, but if you want buy it,
|
31
|
+
# Lipsiadmin include a trial fully functional evaluation version, but if you want buy it,
|
32
32
|
# go here: http://pd4ml.com/buy.htm and then put your licensed jar in a directory in your
|
33
33
|
# project then simply calling this:
|
34
|
-
#
|
34
|
+
#
|
35
35
|
# Lipsiadmin::Utils::PdfBuilder.jars_path = "here/is/my/licensed/pd4ml"
|
36
36
|
# Lipsiadmin::Utils::PdfBuilder.view_path = "keep/template/in/other/path"
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# you can use your version without any problem.
|
39
39
|
#
|
40
40
|
# By default Lipsiadmin will look into your "vendor/pd4ml" and if:
|
41
|
-
#
|
41
|
+
#
|
42
42
|
# * pd4ml.jar
|
43
43
|
# * ss_css2.jar
|
44
|
-
#
|
44
|
+
#
|
45
45
|
# are present will use it
|
46
46
|
#
|
47
47
|
module PdfBuilder
|
48
48
|
include Lipsiadmin::Utils::HtmlEntities
|
49
|
-
|
49
|
+
|
50
50
|
# Convert a stream to pdf, the template must be located in app/view/pdf/yourtemplate.pdf.erb
|
51
51
|
def render_pdf(template, body)
|
52
|
-
|
52
|
+
|
53
53
|
# path to the pd4ml jarfile
|
54
54
|
jars_path = Lipsiadmin::Utils::PdfBuilder.jars_path
|
55
55
|
# path to our templates
|
@@ -72,7 +72,9 @@ module Lipsiadmin
|
|
72
72
|
input.gsub!('url(','url('+RAILS_ROOT+'/public')
|
73
73
|
|
74
74
|
# write our temp file
|
75
|
-
|
75
|
+
tmp = File.join(Rails.root, 'tmp')
|
76
|
+
Dir.mkdir(tmp) unless File.exist?(tmp)
|
77
|
+
t = Tempfile.new("pd4ml.html", tmp)
|
76
78
|
t.binmode
|
77
79
|
t.write(input)
|
78
80
|
t.flush
|
@@ -99,4 +101,4 @@ module Lipsiadmin
|
|
99
101
|
class PdfError < StandardError#:nodoc:
|
100
102
|
end
|
101
103
|
end
|
102
|
-
end
|
104
|
+
end
|
data/lib/utils/literal.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Lipsiadmin
|
2
2
|
module Utils
|
3
|
-
# Returns an object whose to_json evaluates to code.
|
3
|
+
# Returns an object whose to_json evaluates to code.
|
4
4
|
# Use this to pass a literal JavaScript expression as an argument to another JavaScriptGenerator method.
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# Examples:
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# "function() { alert('test') }".to_l
|
9
|
-
#
|
9
|
+
#
|
10
10
|
module Literal
|
11
|
-
# Returns an object whose <tt>to_json</tt> evaluates to +code+. Use this to pass a literal JavaScript
|
11
|
+
# Returns an object whose <tt>to_json</tt> evaluates to +code+. Use this to pass a literal JavaScript
|
12
12
|
# expression as an argument to another JavaScriptGenerator method.
|
13
13
|
#
|
14
14
|
def to_literal
|
@@ -17,4 +17,4 @@ module Lipsiadmin
|
|
17
17
|
alias_method :to_l, :to_literal
|
18
18
|
end
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
data/lib/utils/pdf_builder.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
module Lipsiadmin
|
2
2
|
module Utils
|
3
3
|
# This module help you, when you buy the default pdf builder.
|
4
|
-
#
|
5
|
-
# Lipsiadmin include a trial fully functional evaluation version, but if you want buy it,
|
4
|
+
#
|
5
|
+
# Lipsiadmin include a trial fully functional evaluation version, but if you want buy it,
|
6
6
|
# go here: http://pd4ml.com/buy.htm and then put your licensed jar in a directory in your
|
7
7
|
# project then simply calling this:
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# Lipsiadmin::Utils::PdfBuilder.jars_path = "here/is/my/licensed/pd4ml"
|
10
10
|
# Lipsiadmin::Utils::PdfBuilder.view_path = "keep/template/in/other/path"
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# you can use your version without any problem.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# By default Lipsiadmin will look into your "vendor/pd4ml" and if:
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# * pd4ml.jar
|
17
17
|
# * ss_css2.jar
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# are present will use it
|
20
20
|
#
|
21
21
|
class PdfBuilder
|
@@ -26,13 +26,13 @@ module Lipsiadmin
|
|
26
26
|
else
|
27
27
|
@@jars_path = "#{File.dirname(__FILE__)}/../../resources/pd4ml"
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
@@pd4ruby_path = "#{File.dirname(__FILE__)}/../../resources/pd4ml/ruby"
|
31
31
|
@@view_path = "#{RAILS_ROOT}/app/views/pdf"
|
32
|
-
|
32
|
+
|
33
33
|
cattr_accessor :jars_path
|
34
34
|
cattr_accessor :pd4ruby_path
|
35
35
|
cattr_accessor :view_path
|
36
36
|
end
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|
data/lib/version.rb
CHANGED
@@ -39,35 +39,35 @@ module Lipsiadmin
|
|
39
39
|
contents = ''
|
40
40
|
contents << content_tag(:p, message) unless message.blank?
|
41
41
|
contents << content_tag(:ul, error_messages, :class => :list)
|
42
|
-
|
42
|
+
|
43
43
|
content_tag(:script, "Ext.Msg.show({
|
44
44
|
title: '#{header_message}',
|
45
45
|
msg: '<ul>#{contents}</ul>',
|
46
46
|
buttons: Ext.Msg.OK,
|
47
|
-
minWidth: 400
|
47
|
+
minWidth: 400
|
48
48
|
});", :type => Mime::JS)
|
49
49
|
end
|
50
50
|
else
|
51
51
|
''
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
# This method add tab for in your view.
|
56
|
-
#
|
57
|
-
# First argument is the name and title of the tab, an interesting thing wose that this helper
|
56
|
+
#
|
57
|
+
# First argument is the name and title of the tab, an interesting thing wose that this helper
|
58
58
|
# try to translate itself to your current locale ex:
|
59
|
-
#
|
59
|
+
#
|
60
60
|
# # Look for: I18n.t("backend.tabs.settings", :default => "Settings")
|
61
61
|
# tab :settings do
|
62
62
|
# ...
|
63
|
-
#
|
63
|
+
#
|
64
64
|
# The second argument specify if is necessary 10px of padding inside the tab, default is +true+
|
65
|
-
#
|
65
|
+
#
|
66
66
|
# Third argument is an hash that accepts:
|
67
|
-
#
|
67
|
+
#
|
68
68
|
# <tt>:id</tt>:: The id of the tab
|
69
69
|
# <tt>:style</tt>:: Custom style of the tab
|
70
|
-
#
|
70
|
+
#
|
71
71
|
def tab(name, padding=true, options={}, &block)
|
72
72
|
options[:id] ||= name.to_s.downcase.gsub(/[^a-z0-9]+/, '_').gsub(/-+$/, '').gsub(/^-+$/, '')
|
73
73
|
options[:style] ||= "padding:10px;#{options[:style]}" if padding
|
@@ -77,85 +77,85 @@ module Lipsiadmin
|
|
77
77
|
container = content_tag(:div, capture(&block), :class => :full) # Is necessary for IE6+
|
78
78
|
concat content_tag(:div, container, options)
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
# Set the title of the page.
|
82
|
-
#
|
83
|
-
# An interesting thing wose that this helper
|
82
|
+
#
|
83
|
+
# An interesting thing wose that this helper
|
84
84
|
# try to translate itself to your current locale ex:
|
85
|
-
#
|
85
|
+
#
|
86
86
|
# # Look for: I18n.t("backend.titles.welcome_here", :default => "Welcome Here")
|
87
87
|
# title :welcome_here
|
88
|
-
#
|
88
|
+
#
|
89
89
|
def title(title)
|
90
90
|
title = I18n.t("backend.titles.#{title.gsub(/\./,"").to_s.downcase}", :default => title.to_s.humanize)
|
91
91
|
content_tag(:script, "Backend.app.setTitle(#{title.to_json})", :type => Mime::JS)
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
# Get the title for grids of the specified model based on your
|
95
95
|
# current locale.
|
96
|
-
#
|
96
|
+
#
|
97
97
|
# The locale file for this translation is located: config/locales/backend
|
98
|
-
#
|
98
|
+
#
|
99
99
|
# # Generate: List all Accounts
|
100
100
|
# list_title_for(Account)
|
101
|
-
#
|
101
|
+
#
|
102
102
|
# # Generate: List all My Accounts
|
103
103
|
# list_title_for("My Accounts")
|
104
|
-
#
|
104
|
+
#
|
105
105
|
def list_title_for(text)
|
106
106
|
I18n.t("backend.general.list", :model => text.is_a?(String) ? text : text.send(:human_name))
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
# Get the title for edit action of a form based on your current locale
|
110
|
-
#
|
110
|
+
#
|
111
111
|
# The locale file for this translation is located: config/locales/backend
|
112
|
-
#
|
112
|
+
#
|
113
113
|
# # Generate: Edit Account 18
|
114
114
|
# edit_title_for(Account, @account.id)
|
115
|
-
#
|
115
|
+
#
|
116
116
|
# # Generate: Edit My Account Foo Bar
|
117
117
|
# edit_title_for("My Account", @account.full_name)
|
118
|
-
#
|
118
|
+
#
|
119
119
|
def edit_title_for(text, value)
|
120
120
|
title I18n.t("backend.general.editForm", :model => text.is_a?(String) ? text : text.send(:human_name), :value => value)
|
121
121
|
end
|
122
122
|
|
123
123
|
# Get the title for new action of a form based on your current locale
|
124
|
-
#
|
124
|
+
#
|
125
125
|
# The locale file for this translation is located: config/locales/backend
|
126
|
-
#
|
126
|
+
#
|
127
127
|
# # Generate: New Account
|
128
128
|
# new_title_for(Account)
|
129
|
-
#
|
129
|
+
#
|
130
130
|
# # Generate: New My Account
|
131
131
|
# new_title_for("My Account")
|
132
|
-
#
|
132
|
+
#
|
133
133
|
def new_title_for(text)
|
134
134
|
title I18n.t("backend.general.newForm", :model => text.is_a?(String) ? text : text.send(:human_name))
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
# Try to translate the given word
|
138
|
-
#
|
138
|
+
#
|
139
139
|
# # Generate: I18n.t("backend.labels.add", :default => "Add")
|
140
140
|
# tl("Add")
|
141
|
-
#
|
141
|
+
#
|
142
142
|
def translate_label(text)
|
143
143
|
I18n.t("backend.labels.#{text.to_s.downcase.gsub(/\s/, "_")}", :default => text.to_s.humanize)
|
144
144
|
end
|
145
145
|
alias_method :tl, :translate_label
|
146
146
|
|
147
147
|
# Try to translate the given pharse
|
148
|
-
#
|
148
|
+
#
|
149
149
|
# # Generate: I18n.t("backend.labels.lipsiadmin_is_beautifull", :default => "Lipsiadmin is beautifull")
|
150
150
|
# tt("Lipsiadmin is beautifull")
|
151
|
-
#
|
151
|
+
#
|
152
152
|
def translate_text(text)
|
153
153
|
I18n.t("backend.texts.#{text.to_s.downcase.gsub(/\s/, "_")}", :default => text.to_s.humanize)
|
154
154
|
end
|
155
155
|
alias_method :tt, :translate_text
|
156
|
-
|
156
|
+
|
157
157
|
# Return the translated attribute based on your current locale
|
158
|
-
#
|
158
|
+
#
|
159
159
|
# # In config/locales/backend/models/en.yml
|
160
160
|
# en:
|
161
161
|
# activerecord:
|
@@ -164,8 +164,8 @@ module Lipsiadmin
|
|
164
164
|
# name: "Account Name"
|
165
165
|
# suranme: "Custom Title For Surname"
|
166
166
|
# role: "Im a"
|
167
|
-
#
|
168
|
-
# # Generates:
|
167
|
+
#
|
168
|
+
# # Generates:
|
169
169
|
# # Account Name
|
170
170
|
# # Custom Title For Surname
|
171
171
|
# # Im a
|
@@ -174,11 +174,11 @@ module Lipsiadmin
|
|
174
174
|
# human_name_for :account, :surname
|
175
175
|
# human_name_for :account, :role
|
176
176
|
# human_name_for :account, :attribute_not_translated
|
177
|
-
#
|
177
|
+
#
|
178
178
|
def human_name_for(instance, method)
|
179
179
|
I18n.t("activerecord.attributes.#{instance}.#{method}", :default => method.to_s.humanize)
|
180
180
|
end
|
181
|
-
|
181
|
+
|
182
182
|
# Generate the menu from the Lispiadmin::AccessControl
|
183
183
|
def backend_menu
|
184
184
|
config = AccountAccess.maps_for(current_account).collect(&:project_modules).flatten.uniq.collect(&:config)
|
@@ -187,38 +187,38 @@ module Lipsiadmin
|
|
187
187
|
end
|
188
188
|
|
189
189
|
# Returns html for upload one image or generic file.
|
190
|
-
#
|
190
|
+
#
|
191
191
|
# Options can be one of the following:
|
192
|
-
#
|
192
|
+
#
|
193
193
|
# <tt>:image</tt>:: Indicate if the attachments are ONLY images.
|
194
194
|
# <tt>:only_upload</tt>:: Indicate that is not necessary manage the old attachments.
|
195
|
-
#
|
195
|
+
#
|
196
196
|
# Examples:
|
197
|
-
#
|
197
|
+
#
|
198
198
|
# class Category < ActiveRecord::Base
|
199
199
|
# has_one_attachments :file, :dependent => :destroy
|
200
200
|
# ...
|
201
|
-
#
|
201
|
+
#
|
202
202
|
# Then in our view we can simply add this:
|
203
|
-
#
|
203
|
+
#
|
204
204
|
# attachments_tag(:category, :file)
|
205
|
-
#
|
205
|
+
#
|
206
206
|
# Remember that al labels can be translated. See Locales for Backend.
|
207
|
-
#
|
207
|
+
#
|
208
208
|
def attachment_tag(object_name, method, options={})
|
209
209
|
variable = instance_variable_get("@#{object_name}")
|
210
210
|
html = []
|
211
211
|
html << '<!-- Generated from Lipsiadmin -->'
|
212
|
-
|
212
|
+
|
213
213
|
unless options[:only_upload]
|
214
214
|
html << '<ul id="' + "#{method}-order" + '" class="label">'
|
215
|
-
|
215
|
+
|
216
216
|
if attachment = variable.send(method)
|
217
217
|
# Create first the remove link
|
218
|
-
remove_link = link_to_remote(tl(:remove), :url => "/backend/attachments/#{attachment.id}",
|
219
|
-
:method => :delete,
|
218
|
+
remove_link = link_to_remote(tl(:remove), :url => "/backend/attachments/#{attachment.id}",
|
219
|
+
:method => :delete,
|
220
220
|
:success => "$('#{method}_#{attachment.id}').remove();")
|
221
|
-
|
221
|
+
|
222
222
|
if options[:image]
|
223
223
|
fstyle = "float:left;margin:5px;margin-left:0px;"
|
224
224
|
fclass = "box-image"
|
@@ -237,12 +237,12 @@ module Lipsiadmin
|
|
237
237
|
ftag += '</div>'
|
238
238
|
ftag += '<br style="clear:both" />'
|
239
239
|
end
|
240
|
-
|
240
|
+
|
241
241
|
html << '<li id="' + "#{method}_#{attachment.id}" + '" class="' + fclass + '" style="' + fstyle + '">'
|
242
242
|
html << ' ' + ftag
|
243
243
|
html << '</li>'
|
244
244
|
end # End of Loop
|
245
|
-
|
245
|
+
|
246
246
|
html << '</ul>'
|
247
247
|
html << '<br style="clear:both" />'
|
248
248
|
end
|
@@ -258,41 +258,41 @@ module Lipsiadmin
|
|
258
258
|
html << '</table>'
|
259
259
|
html.join("\n")
|
260
260
|
end
|
261
|
-
|
261
|
+
|
262
262
|
# Returns html for upload multiple images or generic files.
|
263
|
-
#
|
263
|
+
#
|
264
264
|
# Options can be one of the following:
|
265
|
-
#
|
265
|
+
#
|
266
266
|
# <tt>:image</tt>:: Indicate if the attachments are ONLY images.
|
267
267
|
# <tt>:only_upload</tt>:: Indicate that is not necessary manage the old attachments.
|
268
268
|
# <tt>:order</tt>:: Indicate if user can order files.
|
269
|
-
#
|
269
|
+
#
|
270
270
|
# Examples:
|
271
|
-
#
|
271
|
+
#
|
272
272
|
# class Category < ActiveRecord::Base
|
273
273
|
# has_many_attachments :images, :dependent => :destroy
|
274
274
|
# validates_attachment_content_type_for :images, /^image/
|
275
275
|
# ...
|
276
|
-
#
|
276
|
+
#
|
277
277
|
# Then in our view we can simply add this:
|
278
|
-
#
|
278
|
+
#
|
279
279
|
# attachments_tag(:category, :images, :image => true, :order => true)
|
280
|
-
#
|
280
|
+
#
|
281
281
|
# Remember that al labels can be translated. See Locales for Backend.
|
282
|
-
#
|
282
|
+
#
|
283
283
|
def attachments_tag(object_name, method, options={})
|
284
284
|
variable = instance_variable_get("@#{object_name}")
|
285
285
|
html = []
|
286
286
|
html << '<!-- Generated from Lipsiadmin -->'
|
287
287
|
unless options[:only_upload]
|
288
288
|
html << '<ul id="' + "#{method}-order" + '" class="label">'
|
289
|
-
|
289
|
+
|
290
290
|
for attachment in variable.send(method).all(:order => :position)
|
291
291
|
# Create first the remove link
|
292
|
-
remove_link = link_to_remote(tl(:remove), :url => "/backend/attachments/#{attachment.id}",
|
293
|
-
:method => :delete,
|
292
|
+
remove_link = link_to_remote(tl(:remove), :url => "/backend/attachments/#{attachment.id}",
|
293
|
+
:method => :delete,
|
294
294
|
:success => "$('#{method}_#{attachment.id}').remove();")
|
295
|
-
|
295
|
+
|
296
296
|
if options[:image]
|
297
297
|
fstyle = "float:left;margin:5px;margin-left:0px;"
|
298
298
|
fstyle += "cursor:move;" if options[:order]
|
@@ -313,15 +313,15 @@ module Lipsiadmin
|
|
313
313
|
ftag += '</div>'
|
314
314
|
ftag += '<br style="clear:both" />'
|
315
315
|
end
|
316
|
-
|
316
|
+
|
317
317
|
html << '<li id="' + "#{method}_#{attachment.id}" + '" class="' + fclass + '" style="' + fstyle + '">'
|
318
318
|
html << ' ' + ftag
|
319
319
|
html << '</li>'
|
320
320
|
end # End of Loop
|
321
|
-
|
321
|
+
|
322
322
|
html << '</ul>'
|
323
323
|
html << '<br style="clear:both" />'
|
324
|
-
|
324
|
+
|
325
325
|
|
326
326
|
if options[:order]
|
327
327
|
constraint = options[:image] ? "horizontal" : "vertical"
|
@@ -330,7 +330,7 @@ module Lipsiadmin
|
|
330
330
|
:complete => visual_effect(:highlight, "#{method}-message", :duration => 0.5))
|
331
331
|
end
|
332
332
|
end
|
333
|
-
|
333
|
+
|
334
334
|
flbl = options[:image] ? :upload_images : :upload_files
|
335
335
|
html << '<div class="label-title">'+ tl(flbl) +'</div>'
|
336
336
|
html << '<table>'
|
@@ -351,26 +351,26 @@ module Lipsiadmin
|
|
351
351
|
end
|
352
352
|
|
353
353
|
# Build a new windows that can contain an existent grid
|
354
|
-
#
|
354
|
+
#
|
355
355
|
# The first argument name is used as the link text.
|
356
|
-
#
|
356
|
+
#
|
357
357
|
# The second argument is the url where js of grid are stored.
|
358
|
-
#
|
358
|
+
#
|
359
359
|
# The third argument is the name of the gird var usually gridPanel or editorGridPanel.
|
360
|
-
#
|
360
|
+
#
|
361
361
|
# The four argument are callbacks that may be specified:
|
362
|
-
#
|
362
|
+
#
|
363
363
|
# <tt>:before</tt>:: Called before request is initiated.
|
364
364
|
# <tt>:update</tt>:: Called after user press +select+ button.
|
365
365
|
# This call are performed in an handler where
|
366
366
|
# you have access to two variables:
|
367
367
|
# <tt>:win</tt>:: Backend.window
|
368
368
|
# <tt>:selections</tt>:: Records selected in the grid
|
369
|
-
#
|
370
|
-
# # Generates: <a onclick="
|
371
|
-
# # new Backend.window({
|
372
|
-
# # url: '/backend/categories.js',
|
373
|
-
# # grid: 'gridPanel',
|
369
|
+
#
|
370
|
+
# # Generates: <a onclick="
|
371
|
+
# # new Backend.window({
|
372
|
+
# # url: '/backend/categories.js',
|
373
|
+
# # grid: 'gridPanel',
|
374
374
|
# # listeners: {
|
375
375
|
# # selected: function(win, selections){
|
376
376
|
# # $('post_category_ids').value = selections.collect(function(s) { return s.id }).join(',');
|
@@ -382,14 +382,14 @@ module Lipsiadmin
|
|
382
382
|
# build_grid "Select a Category", "/backend/categories.js", "gridPanel",
|
383
383
|
# :update => "$('post_category_ids').value = selections.collect(function(s) { return s.id }).join(',');" +
|
384
384
|
# "$('category_names').innerHTML = selections.collect(function(s) { return s.data['categories.name'] }).join(', ');"
|
385
|
-
#
|
385
|
+
#
|
386
386
|
def build_grid(text, url, grid, options={})
|
387
387
|
options[:before] = options[:before] + ";" if options[:before]
|
388
388
|
javascript = <<-JAVASCRIPT
|
389
389
|
#{options[:before]}
|
390
|
-
new Backend.window({
|
391
|
-
url: '#{url}',
|
392
|
-
grid: '#{grid}',
|
390
|
+
new Backend.window({
|
391
|
+
url: '#{url}',
|
392
|
+
grid: '#{grid}',
|
393
393
|
listeners: {
|
394
394
|
selected: function(win, selections){
|
395
395
|
#{options[:update]}
|
@@ -402,23 +402,23 @@ module Lipsiadmin
|
|
402
402
|
alias_method :open_grid, :build_grid
|
403
403
|
|
404
404
|
# Open a Standard window that can contain a standard existent grid
|
405
|
-
#
|
405
|
+
#
|
406
406
|
# Options can be one of the following:
|
407
|
-
#
|
407
|
+
#
|
408
408
|
# <tt>:grid</tt>:: The name of the grid var. Default "gridPanel"
|
409
409
|
# <tt>:url</tt>:: The url where the grid is stored. Default is autogenerated.
|
410
410
|
# <tt>:name</tt>:: The name of the link that open the window grid. Default a image.
|
411
|
-
#
|
411
|
+
#
|
412
412
|
# # Generates: <a onclick="
|
413
|
-
# # new Backend.window({
|
414
|
-
# # url: '/backend/suppliers.js',
|
415
|
-
# # grid: 'gridPanel',
|
416
|
-
# # listeners: {
|
417
|
-
# # selected: function(win, selections){
|
418
|
-
# # $('warehouse_supplier_id').value = selections.first().id;
|
419
|
-
# # $('warehouse_supplier_name').innerHTML = selections.first().data['suppliers.name']
|
420
|
-
# # }
|
421
|
-
# # }
|
413
|
+
# # new Backend.window({
|
414
|
+
# # url: '/backend/suppliers.js',
|
415
|
+
# # grid: 'gridPanel',
|
416
|
+
# # listeners: {
|
417
|
+
# # selected: function(win, selections){
|
418
|
+
# # $('warehouse_supplier_id').value = selections.first().id;
|
419
|
+
# # $('warehouse_supplier_name').innerHTML = selections.first().data['suppliers.name']
|
420
|
+
# # }
|
421
|
+
# # }
|
422
422
|
# # }).show(); return false;">
|
423
423
|
# # <img alt="New" src="/images/backend/new.gif?1242655402" style="vertical-align:bottom" /></a>
|
424
424
|
# # <input id="warehouse_supplier_id" name="warehouse[supplier_id]" type="hidden" value="16" />
|
@@ -430,7 +430,7 @@ module Lipsiadmin
|
|
430
430
|
options[:grid] ||= "gridPanel"
|
431
431
|
options[:url] ||= "/backend/#{ext_object.to_s.pluralize}.js"
|
432
432
|
options[:name] ||= image_tag("backend/new.gif", :style => "vertical-align:bottom")
|
433
|
-
update_function = "$('#{object_name}_#{ext_object}_#{value}').value = selections.first().#{value_field}; " +
|
433
|
+
update_function = "$('#{object_name}_#{ext_object}_#{value}').value = selections.first().#{value_field}; " +
|
434
434
|
"$('#{object_name}_#{ext_object}_#{display}').innerHTML = selections.first().data['#{ext_object.to_s.pluralize}.#{display}']"
|
435
435
|
|
436
436
|
content_tag(:span, current_value, :id => "#{object_name}_#{ext_object}_#{display}" ) + ' ' +
|
@@ -439,23 +439,23 @@ module Lipsiadmin
|
|
439
439
|
end
|
440
440
|
|
441
441
|
# Open a new windows that can contain a form that you can reuse
|
442
|
-
#
|
442
|
+
#
|
443
443
|
# The first argument name is used as the link text.
|
444
|
-
#
|
444
|
+
#
|
445
445
|
# The second argument is the url where html of form are stored.
|
446
|
-
#
|
446
|
+
#
|
447
447
|
# The third argument are callbacks that may be specified:
|
448
|
-
#
|
448
|
+
#
|
449
449
|
# <tt>:before</tt>:: Called before request is initiated.
|
450
450
|
# <tt>:after</tt>:: Called after request is initiated.
|
451
451
|
# <tt>:on_save</tt>:: Called after user press +save+ button.
|
452
452
|
# This call are performed in an handler where
|
453
453
|
# you have access to one variables:
|
454
454
|
# <tt>:win</tt>:: Backend.window
|
455
|
-
#
|
456
|
-
# # Generates: <a onclick="
|
457
|
-
# # new Backend.window({
|
458
|
-
# # url: '/backend/posts/'+$('comment_post_id').value+'/edit',
|
455
|
+
#
|
456
|
+
# # Generates: <a onclick="
|
457
|
+
# # new Backend.window({
|
458
|
+
# # url: '/backend/posts/'+$('comment_post_id').value+'/edit',
|
459
459
|
# # form: true,
|
460
460
|
# # listeners: {
|
461
461
|
# # saved: function(win){
|
@@ -465,13 +465,13 @@ module Lipsiadmin
|
|
465
465
|
# # }).show();
|
466
466
|
# # return false;" href="#">Edit Post</a>
|
467
467
|
# open_form "Edit Post", "/backend/posts/'+$('comment_post_id').value+'/edit", :update => "someFn(win);"
|
468
|
-
#
|
468
|
+
#
|
469
469
|
def open_form(text, url, options={})
|
470
470
|
options[:before] = options[:before] + ";" if options[:before]
|
471
471
|
javascript = <<-JAVASCRIPT
|
472
472
|
#{options[:before]}
|
473
|
-
new Backend.window({
|
474
|
-
url: '#{url}',
|
473
|
+
new Backend.window({
|
474
|
+
url: '#{url}',
|
475
475
|
form: true,
|
476
476
|
listeners: {
|
477
477
|
saved: function(win){ #{options[:on_save]} },
|
@@ -481,15 +481,15 @@ module Lipsiadmin
|
|
481
481
|
JAVASCRIPT
|
482
482
|
link_to_function(text, javascript.gsub(/\n/, " "))
|
483
483
|
end
|
484
|
-
|
485
|
-
# This method call a remote_function and in the same time do a
|
486
|
-
#
|
484
|
+
|
485
|
+
# This method call a remote_function and in the same time do a
|
486
|
+
#
|
487
487
|
# Backend.app.mask()
|
488
488
|
#
|
489
|
-
# and when the function is complete
|
490
|
-
#
|
489
|
+
# and when the function is complete
|
490
|
+
#
|
491
491
|
# Backend.app.unmask()
|
492
|
-
#
|
492
|
+
#
|
493
493
|
def link_to_remote_with_wait(name, options={}, html_options={})
|
494
494
|
options[:complete] = "Backend.app.unmask();"
|
495
495
|
options[:before] = "Backend.app.mask('#{I18n.t('backend.javascripts.messages.wait.message')}')";
|
@@ -497,18 +497,18 @@ module Lipsiadmin
|
|
497
497
|
end
|
498
498
|
|
499
499
|
# This method generates a new ExtJs BoxComponent.
|
500
|
-
#
|
500
|
+
#
|
501
501
|
# Examples:
|
502
|
-
#
|
502
|
+
#
|
503
503
|
# -box "My Title", "My Subtitle", :submit => true, :collapsible => true, :style => "padding:none", :start => :close do
|
504
504
|
# my content
|
505
|
-
#
|
505
|
+
#
|
506
506
|
# Defaults:
|
507
|
-
#
|
507
|
+
#
|
508
508
|
# * :submit => false
|
509
509
|
# * :collapsible => false
|
510
510
|
# * :start => :close
|
511
|
-
#
|
511
|
+
#
|
512
512
|
def box(title=nil, subtitle=nil, options={}, &block)
|
513
513
|
options[:style] ||= "width:100%;"
|
514
514
|
options[:start] ||= :open
|
@@ -544,8 +544,8 @@ module Lipsiadmin
|
|
544
544
|
</div>
|
545
545
|
HTML
|
546
546
|
end
|
547
|
-
|
547
|
+
|
548
548
|
end
|
549
549
|
end
|
550
550
|
end
|
551
|
-
end
|
551
|
+
end
|