bhf 0.2.7 → 0.2.8
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/app/helpers/bhf/entries_helper.rb +7 -0
- data/app/views/bhf/application/index.haml +1 -1
- data/app/views/bhf/entries/form/column/_file.haml +16 -5
- data/app/views/bhf/pages/_search.haml +0 -1
- data/app/views/layouts/bhf/application.haml +1 -1
- data/config/locales/de.yml +3 -1
- data/config/locales/en.yml +2 -0
- data/lib/bhf/active_record/active_record.rb +41 -0
- data/lib/bhf/active_record/upload.rb +45 -0
- data/lib/bhf/pagination.rb +1 -1
- data/lib/bhf.rb +2 -2
- data/public/images/bhf/ajax_loader.gif +0 -0
- data/public/images/bhf/icon_delete.png +0 -0
- data/public/images/bhf/icon_delete_a.png +0 -0
- data/public/images/bhf/icon_delete_h.png +0 -0
- data/public/images/bhf/icon_drag.png +0 -0
- data/public/images/bhf/icon_drag_a.png +0 -0
- data/public/images/bhf/icon_drag_h.png +0 -0
- data/public/images/bhf/icon_edit.png +0 -0
- data/public/images/bhf/icon_edit_a.png +0 -0
- data/public/images/bhf/icon_edit_h.png +0 -0
- data/public/images/bhf/small_ajax_loader.gif +0 -0
- data/public/images/bhf/small_ajax_loader_h.gif +0 -0
- data/public/javascripts/bhf.js +106 -105
- data/public/stylesheets/bhf.css +1 -1
- metadata +12 -5
- data/lib/bhf/active_record.rb +0 -40
@@ -1,5 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
=
|
5
|
-
|
1
|
+
- # no file upload on ajax submit :(
|
2
|
+
- unless @quick_edit
|
3
|
+
= node f, field do
|
4
|
+
= f.fields_for field.name do |f_file|
|
5
|
+
- file = f.object.send(field.name)
|
6
|
+
- if file.is_a?(String)
|
7
|
+
- if is_image?(file)
|
8
|
+
= image_tag file, :class => 'uploaded_image'
|
9
|
+
- else
|
10
|
+
= link_to file, file, :class => 'uploaded_file'
|
11
|
+
- unless file.blank?
|
12
|
+
.file_delete
|
13
|
+
= f_file.check_box :delete
|
14
|
+
= f_file.label :delete, t('bhf.helpers.file.delete')
|
15
|
+
|
16
|
+
= f_file.file_field :file
|
@@ -7,7 +7,7 @@
|
|
7
7
|
%link{:href => '/favicon.ico', :rel => 'icon', :type => 'image/x-icon'}
|
8
8
|
= stylesheet_link_tag(['bhf'] + Bhf::Engine.config.css.to_a)
|
9
9
|
= javascript_include_tag 'bhf'
|
10
|
-
=# javascript_include_tag 'bhf/mootools-core-1.3.
|
10
|
+
=# javascript_include_tag 'bhf/mootools-core-1.3.2-full-compat-yc.js', 'bhf/mootools-more-1.3.2.1.js', 'bhf/mootools_rails_driver-0.4.1.js', 'bhf/class/BrowserUpdate', 'bhf/class/Ajaxify', 'bhf/class/AjaxEdit', 'bhf/class/MooEditable', 'bhf/class/Datepicker', 'bhf/class/MultipleFields', 'bhf/bhf_application'
|
11
11
|
%body
|
12
12
|
%header
|
13
13
|
%h1= link_to image_tag('logo_bhf.png'), root_url
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Bhf
|
2
|
+
module ActiveRecord
|
3
|
+
module Object
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def to_bhf_s
|
7
|
+
return title if self.respond_to? :title
|
8
|
+
return name if self.respond_to? :name
|
9
|
+
|
10
|
+
if self.respond_to? :attributes
|
11
|
+
return title if attributes['title']
|
12
|
+
return name if attributes['name']
|
13
|
+
return "#{self.class.to_s.humanize} ID: #{send(self.class.primary_key)}" if attributes[self.class.primary_key]
|
14
|
+
end
|
15
|
+
|
16
|
+
self.to_s.humanize
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
def bhf_default_search(search_params)
|
21
|
+
return if (search_term = search_params[:text]).blank?
|
22
|
+
where_statement = []
|
23
|
+
columns_hash.each_pair do |name, props|
|
24
|
+
is_number = search_term.to_i.to_s == search_term || search_term.to_f.to_s == search_term
|
25
|
+
|
26
|
+
if props.type == :string || props.type == :text
|
27
|
+
where_statement << "#{name} LIKE '%#{search_term}%'"
|
28
|
+
elsif props.type == :integer && is_number
|
29
|
+
where_statement << "#{name} = #{search_term.to_i}"
|
30
|
+
elsif props.type == :float && is_number
|
31
|
+
where_statement << "#{name} = #{search_term.to_f}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
where_statement.join(' OR ')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Bhf
|
2
|
+
module ActiveRecord
|
3
|
+
module Upload
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
before_save :bhf_upload
|
8
|
+
cattr_accessor :bhf_upload_settings
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def setup_upload(settings)
|
13
|
+
self.bhf_upload_settings = settings.each_with_object([]) do |s, obj|
|
14
|
+
obj << {:path => '', :name => :file}.merge(s)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def bhf_upload
|
20
|
+
self.class.bhf_upload_settings.each do |settings|
|
21
|
+
name_was = send("#{settings[:name]}_was")
|
22
|
+
param_name = read_attribute(settings[:name])
|
23
|
+
file_string = if param_name && param_name[:delete].to_i != 0
|
24
|
+
# File.delete(settings[:path] + name_was.to_s) if File.exist?(settings[:path] + name_was.to_s)
|
25
|
+
nil
|
26
|
+
else
|
27
|
+
file = param_name && param_name[:file]
|
28
|
+
if file.is_a? ActionDispatch::Http::UploadedFile
|
29
|
+
# File.delete(settings[:path] + name_was.to_s) if File.exist?(settings[:path] + name_was.to_s)
|
30
|
+
|
31
|
+
filename = Time.now.to_i.to_s+'_'+file.original_filename.downcase.sub(/[^\w\.\-]/,'_')
|
32
|
+
path = File.join(settings[:path], filename)
|
33
|
+
File.open(path, 'w') { |f| f.write(file.read) }
|
34
|
+
filename
|
35
|
+
else
|
36
|
+
name_was
|
37
|
+
end
|
38
|
+
end
|
39
|
+
write_attribute settings[:name], file_string
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/bhf/pagination.rb
CHANGED
data/lib/bhf.rb
CHANGED
@@ -4,7 +4,8 @@ end
|
|
4
4
|
|
5
5
|
require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
6
6
|
require 'bhf/i18n'
|
7
|
-
require 'bhf/active_record'
|
7
|
+
require 'bhf/active_record/active_record'
|
8
|
+
require 'bhf/active_record/upload'
|
8
9
|
require 'bhf/view_helpers'
|
9
10
|
require 'bhf/data'
|
10
11
|
require 'bhf/platform'
|
@@ -15,6 +16,5 @@ require 'bhf/form'
|
|
15
16
|
::I18n.send :include, Bhf::I18nTranslationFallbackHelper
|
16
17
|
|
17
18
|
::ActiveRecord::Base.send :include, Bhf::ActiveRecord::Object
|
18
|
-
::ActiveRecord::Base.send :extend, Bhf::ActiveRecord::Self
|
19
19
|
|
20
20
|
::ActionView::Base.send :include, Bhf::ViewHelpers::ActionView
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|