lolita-file-upload 0.5.0 → 0.6.0
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/VERSION +1 -1
- data/app/controllers/lolita/uploads_controller.rb +7 -2
- data/app/views/components/lolita/configuration/tab/files/_fields.html.haml +2 -0
- data/app/views/components/lolita/configuration/tab/files/_form.html.haml +27 -0
- data/app/views/components/lolita/configuration/tab/files/_language_switch.html.haml +3 -0
- data/app/views/components/lolita/configuration/tab/files/_translatable_fields.html.haml +10 -0
- data/app/views/components/lolita/configuration/tab/files/_upload_script.html.erb +1 -3
- data/config/locales/en.yml +4 -0
- data/config/locales/lv.yml +18 -0
- data/lib/lolita-file-upload.rb +5 -0
- data/lib/lolita-file-upload/configuration/tab/files.rb +22 -5
- data/lolita-file-upload.gemspec +6 -3
- data/vendor/assets/javascripts/lolita/upload/application_vendor.js +8 -9
- data/vendor/assets/stylesheets/lolita/upload/lolita_file_upload.css.scss +2 -0
- metadata +7 -4
- data/app/views/components/lolita/configuration/tab/files/_form.html.erb +0 -24
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -25,7 +25,8 @@ class Lolita::UploadsController < ApplicationController
|
|
25
25
|
|
26
26
|
def update
|
27
27
|
authorization_proxy.can?(:update,@file.class)
|
28
|
-
@file.update_attributes!(params[
|
28
|
+
@file.update_attributes!(params[resource_param_name])
|
29
|
+
flash[:notice] = ::I18n.t("lolita.uploads_controller.update.notice")
|
29
30
|
render_component *@tab.build("",:update,:file=>@file)
|
30
31
|
end
|
31
32
|
|
@@ -39,7 +40,7 @@ class Lolita::UploadsController < ApplicationController
|
|
39
40
|
|
40
41
|
def set_resource
|
41
42
|
association_id = params["#{lolita_mapping.singular}_id"] || params[:upload]["#{lolita_mapping.singular}_id"] || params[:upload]["#{@tab.association.options[:as]}_id"]
|
42
|
-
self.resource = resource_class.find_by_id(association_id)
|
43
|
+
self.resource = resource_class.find_by_id(association_id) || resource_class.new
|
43
44
|
end
|
44
45
|
|
45
46
|
def build_file
|
@@ -62,4 +63,8 @@ class Lolita::UploadsController < ApplicationController
|
|
62
63
|
def tab_by_association name
|
63
64
|
resource_class.lolita.tabs.detect{|tab| tab.type == :files && (tab.try(:association) && tab.association.name == name.to_sym)}
|
64
65
|
end
|
66
|
+
|
67
|
+
def resource_param_name
|
68
|
+
@file.class.to_s.underscore.gsub("/","_")
|
69
|
+
end
|
65
70
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
- old_current_form = self.current_form
|
2
|
+
= form_for file, :url => send(:"lolita_#{resource_class.model_name.singular}_upload_path", "#{resource_class.model_name.singular}_id" => (resource.nil? || resource.new_record?) ? 0 : resource.id, :association => tab.association.name, :id=>file.id), :html => {:method=>:put,:remote=>true,:id=>"edit_#{tab.association.name}_#{file.id}", :class => "edit-file-form"} do |f|
|
3
|
+
- self.current_form = f
|
4
|
+
.file-editor
|
5
|
+
- unless flash[:notice].blank?
|
6
|
+
%p.notice= flash[:notice]
|
7
|
+
- unless flash[:error].blank?
|
8
|
+
%p.error= flash[:error]
|
9
|
+
- url = file.send(tab.uploader).normalized.blank? ? file.send(tab.uploader).url : file.send(tab.uploader).normalized.url
|
10
|
+
= image_tag url, :class => "editable-image"
|
11
|
+
- if file.class.respond_to?(:translations_configuration)
|
12
|
+
= render_component :"/lolita/configuration/tab/files", :language_switch, :tab => tab
|
13
|
+
.fields
|
14
|
+
- if file.class.respond_to?(:translations_configuration)
|
15
|
+
= render_component :"/lolita/configuration/tab/files", :translatable_fields, :tab => tab, :file => file
|
16
|
+
- else
|
17
|
+
= render_component :"/lolita/configuration/tab/files", :fields, :tab => tab, :file => file
|
18
|
+
%br
|
19
|
+
.action-links
|
20
|
+
.navigation
|
21
|
+
= link_to t("lolita.tabs.images.back"), send(:"lolita_#{tab.dbi.klass.model_name.singular}_uploads_path"), :remote => true, :class => "back"
|
22
|
+
- #= link_to t("lolita.tabs.images.previous"), "#", :class => "previous"
|
23
|
+
- #= link_to t("lolita.tabs.images.next"), "#", :class => "next"
|
24
|
+
.actions
|
25
|
+
= link_to t("lolita.tabs.images.delete"), send(:"lolita_#{tab.dbi.klass.model_name.singular}_upload_path", "#{tab.dbi.klass.model_name.singular}_id" => (resource.nil? || resource.new_record?) ? 0 : resource.id, :association => tab.association.name, :id=>file.id),:method=>:delete,:remote=>true,:confirm=>"Are you sure?", :class => "delete"
|
26
|
+
= link_to t("lolita.tabs.images.save"), "#", :class => "save"
|
27
|
+
- self.current_form = old_current_form
|
@@ -0,0 +1,3 @@
|
|
1
|
+
%ul{:class => "tab-language-switch", :id => "#{tab.name}_language_switch"}
|
2
|
+
- resource.translations_configuration.locales.by_resource_locale(resource).each do |locale|
|
3
|
+
%li{ :class => resource.original_locale.to_s == locale.name.to_s && "active" || "", :"data-locale" => locale.short_name, :"data-tab" => "file_edit_form", :"data-container" => ".edit-file-form"}= locale.humanized_short_name
|
@@ -0,0 +1,10 @@
|
|
1
|
+
.language-wrap{ :id => "#{file.original_locale}_for_file_edit_form", :class => "active"}
|
2
|
+
- tab.editable_fields.each do |field|
|
3
|
+
= render_component "lolita/configuration/field", :display, :field => field
|
4
|
+
- nested_form = tab.build_translations_nested_form(file)
|
5
|
+
- main_form = self.current_form
|
6
|
+
= self.current_form.fields_for nested_form.name, file.send(nested_form.build_method) do |n_form|
|
7
|
+
- self.current_form = n_form
|
8
|
+
.language-wrap{ :id => "#{n_form.object.locale}_for_file_edit_form"}
|
9
|
+
= render_component nested_form, :fields
|
10
|
+
- self.current_form = main_form
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
<%= javascript_include_tag "lolita/upload/application_vendor.js" %>
|
3
|
-
<% unless ::I18n.locale.to_s.downcase=="en" %>
|
1
|
+
<% unless ::I18n.locale.to_s.downcase=="en" %>
|
4
2
|
<%= javascript_include_tag "lolita/upload/I18n/#{Lolita.locale}.js"%>
|
5
3
|
<% end %>
|
6
4
|
<script type="text/javascript">
|
data/config/locales/en.yml
CHANGED
data/config/locales/lv.yml
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
lv:
|
2
2
|
lolita:
|
3
|
+
uploads_controller:
|
4
|
+
update:
|
5
|
+
notice: "Faila informācija veiksmīgi saglabāta"
|
6
|
+
error: "Faila informācija netika saglabāta"
|
7
|
+
support:
|
8
|
+
bytes:
|
9
|
+
byte:
|
10
|
+
one: baits
|
11
|
+
other: baiti
|
12
|
+
kilobyte:
|
13
|
+
one: kilobaits
|
14
|
+
other: kilobaiti
|
15
|
+
megabyte:
|
16
|
+
one: megabaits
|
17
|
+
other: megabaiti
|
18
|
+
gigabyte:
|
19
|
+
one: gigabaits
|
20
|
+
other: gigabaiti
|
3
21
|
upload:
|
4
22
|
errors:
|
5
23
|
"file too big": "fails par lielu (maksimums %{value} %{unit})"
|
data/lib/lolita-file-upload.rb
CHANGED
@@ -48,6 +48,11 @@ if defined?(Rails)
|
|
48
48
|
require "lolita-file-upload/rails"
|
49
49
|
end
|
50
50
|
|
51
|
+
Lolita.after_setup do
|
52
|
+
Lolita.application.assets << "lolita/upload/application_vendor.css"
|
53
|
+
Lolita.application.assets << "lolita/upload/application_vendor.js"
|
54
|
+
end
|
55
|
+
|
51
56
|
# How to connect multimedia engine with lolita resources
|
52
57
|
# Detecting from tabs will not be very good idea because it will load many thing
|
53
58
|
# There should be the way to connect it on demand when realy multimedia tab is used for resource like
|
@@ -7,7 +7,7 @@ module Lolita
|
|
7
7
|
class Files < Lolita::Configuration::Tab::Base
|
8
8
|
|
9
9
|
lolita_accessor :extensions, :maxfilesize, :filters
|
10
|
-
attr_reader :association, :uploader, :association_type
|
10
|
+
attr_reader :association, :uploader, :association_type
|
11
11
|
|
12
12
|
# As any other Lolita::Configuration::Tab this should receive _dbi_ object.
|
13
13
|
# Additional _args_ that may represent methods, for details see Lolita::Configuration::Tab.
|
@@ -17,7 +17,6 @@ module Lolita
|
|
17
17
|
@dissociate = true
|
18
18
|
@filters=[]
|
19
19
|
@dbi=dbi
|
20
|
-
@editable_fields=[]
|
21
20
|
set_default_association
|
22
21
|
super
|
23
22
|
end
|
@@ -59,9 +58,27 @@ module Lolita
|
|
59
58
|
Lolita::DBI::Base.new self.association.klass
|
60
59
|
end
|
61
60
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
61
|
+
def field *args, &block
|
62
|
+
if association
|
63
|
+
field = Lolita::Configuration::Factory::Field.add(association_dbi,*args,&block)
|
64
|
+
@fields << field
|
65
|
+
field
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def default_fields
|
70
|
+
if association
|
71
|
+
association_dbi.fields.each{|db_field|
|
72
|
+
self.field(:name => db_field.name, :type => db_field.type, :dbi_field => db_field) if db_field.content?
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def editable_fields
|
78
|
+
if association
|
79
|
+
self.default_fields if self.fields.empty?
|
80
|
+
self.fields
|
81
|
+
end
|
65
82
|
end
|
66
83
|
|
67
84
|
def extension_white_list
|
data/lolita-file-upload.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "lolita-file-upload"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ITHouse", "Arturs Meisters"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-09-03"
|
13
13
|
s.description = "File upload gem for Lolita with with fulll integration - models, controller, views"
|
14
14
|
s.email = "support@ithouse.lv"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -40,14 +40,17 @@ Gem::Specification.new do |s|
|
|
40
40
|
"app/views/components/lolita/configuration/tab/files/_destroy.js.erb",
|
41
41
|
"app/views/components/lolita/configuration/tab/files/_display.html.erb",
|
42
42
|
"app/views/components/lolita/configuration/tab/files/_edit.js.erb",
|
43
|
+
"app/views/components/lolita/configuration/tab/files/_fields.html.haml",
|
43
44
|
"app/views/components/lolita/configuration/tab/files/_file.html.erb",
|
44
45
|
"app/views/components/lolita/configuration/tab/files/_fixed_gallery.html.haml",
|
45
|
-
"app/views/components/lolita/configuration/tab/files/_form.html.
|
46
|
+
"app/views/components/lolita/configuration/tab/files/_form.html.haml",
|
46
47
|
"app/views/components/lolita/configuration/tab/files/_image.html.erb",
|
48
|
+
"app/views/components/lolita/configuration/tab/files/_language_switch.html.haml",
|
47
49
|
"app/views/components/lolita/configuration/tab/files/_list.html.erb",
|
48
50
|
"app/views/components/lolita/configuration/tab/files/_list.js.erb",
|
49
51
|
"app/views/components/lolita/configuration/tab/files/_list_form.html.erb",
|
50
52
|
"app/views/components/lolita/configuration/tab/files/_row.html.erb",
|
53
|
+
"app/views/components/lolita/configuration/tab/files/_translatable_fields.html.haml",
|
51
54
|
"app/views/components/lolita/configuration/tab/files/_update.js.erb",
|
52
55
|
"app/views/components/lolita/configuration/tab/files/_upload_script.html.erb",
|
53
56
|
"config/locales/en.yml",
|
@@ -1,13 +1,12 @@
|
|
1
1
|
//= require jquery-ui
|
2
2
|
//= require lolita/upload/plupload.full
|
3
3
|
//= require lolita/upload/jquery.ui.plupload
|
4
|
-
//= require_self
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
alert(1)
|
6
|
+
$(document).ready(function(){
|
7
|
+
$(document).on("click", ".file-editor a.save", function(event) {
|
8
|
+
$(this).closest("form").submit();
|
9
|
+
return false;
|
10
|
+
});
|
11
|
+
});
|
12
|
+
|
@@ -41,6 +41,8 @@
|
|
41
41
|
-moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.25);
|
42
42
|
-webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.25);
|
43
43
|
}
|
44
|
+
#main #content .box .edit-file-form .file-editor .notice {text-align: right; margin-bottom: 10px; color: green}
|
45
|
+
#main #content .box .edit-file-form .file-editor .error {text-align: right; margin-bottom: 10px; color: red}
|
44
46
|
#main #content .box .edit-file-form .file-editor .editable-image {width: 35%; float: left;}
|
45
47
|
#main #content .box .edit-file-form .file-editor .fields {width: 60%; float: right;}
|
46
48
|
#main #content .box .edit-file-form .file-editor .fields label {width: 20%; display: inline-block;}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolita-file-upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: lolita
|
@@ -172,14 +172,17 @@ files:
|
|
172
172
|
- app/views/components/lolita/configuration/tab/files/_destroy.js.erb
|
173
173
|
- app/views/components/lolita/configuration/tab/files/_display.html.erb
|
174
174
|
- app/views/components/lolita/configuration/tab/files/_edit.js.erb
|
175
|
+
- app/views/components/lolita/configuration/tab/files/_fields.html.haml
|
175
176
|
- app/views/components/lolita/configuration/tab/files/_file.html.erb
|
176
177
|
- app/views/components/lolita/configuration/tab/files/_fixed_gallery.html.haml
|
177
|
-
- app/views/components/lolita/configuration/tab/files/_form.html.
|
178
|
+
- app/views/components/lolita/configuration/tab/files/_form.html.haml
|
178
179
|
- app/views/components/lolita/configuration/tab/files/_image.html.erb
|
180
|
+
- app/views/components/lolita/configuration/tab/files/_language_switch.html.haml
|
179
181
|
- app/views/components/lolita/configuration/tab/files/_list.html.erb
|
180
182
|
- app/views/components/lolita/configuration/tab/files/_list.js.erb
|
181
183
|
- app/views/components/lolita/configuration/tab/files/_list_form.html.erb
|
182
184
|
- app/views/components/lolita/configuration/tab/files/_row.html.erb
|
185
|
+
- app/views/components/lolita/configuration/tab/files/_translatable_fields.html.haml
|
183
186
|
- app/views/components/lolita/configuration/tab/files/_update.js.erb
|
184
187
|
- app/views/components/lolita/configuration/tab/files/_upload_script.html.erb
|
185
188
|
- config/locales/en.yml
|
@@ -262,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
265
|
version: '0'
|
263
266
|
segments:
|
264
267
|
- 0
|
265
|
-
hash:
|
268
|
+
hash: 843105153938331671
|
266
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
270
|
none: false
|
268
271
|
requirements:
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<%= form_tag send(:"lolita_#{resource_class.model_name.singular}_upload_path", "#{resource_class.model_name.singular}_id" => resource.id, :association => tab.association.name, :id=>file.id),:method=>:put,:remote=>true,:id=>"edit_#{tab.association.name}_#{file.id}", :class => "edit-file-form" do %>
|
2
|
-
<div class="file-editor">
|
3
|
-
<% url = file.send(tab.uploader).normalized.blank? ? file.send(tab.uploader).url : file.send(tab.uploader).normalized.url %>
|
4
|
-
<%= image_tag url, :class => "editable-image" %>
|
5
|
-
<div class="fields">
|
6
|
-
<% tab.editable_fields.each do |name| %>
|
7
|
-
<%= label_tag "file[#{name}]", file.class.human_attribute_name(name) %>
|
8
|
-
<%= text_field_tag "file[#{name}]",file.send(name) %>
|
9
|
-
<br />
|
10
|
-
<% end %>
|
11
|
-
</div>
|
12
|
-
<div class="action-links">
|
13
|
-
<div class="navigation">
|
14
|
-
<%= link_to t("lolita.tabs.images.back"), send(:"lolita_#{tab.dbi.klass.model_name.singular}_uploads_path"), :remote => true, :class => "back" %>
|
15
|
-
<%#= link_to t("lolita.tabs.images.previous"), "#", :class => "previous" %>
|
16
|
-
<%#= link_to t("lolita.tabs.images.next"), "#", :class => "next" %>
|
17
|
-
</div>
|
18
|
-
<div class="actions">
|
19
|
-
<%= link_to t("lolita.tabs.images.delete"), send(:"lolita_#{tab.dbi.klass.model_name.singular}_upload_path", "#{tab.dbi.klass.model_name.singular}_id" => (resource.nil? || resource.new_record?) ? 0 : resource.id, :association => tab.association.name, :id=>file.id),:method=>:delete,:remote=>true,:confirm=>"Are you sure?", :class => "delete" %>
|
20
|
-
<%= link_to t("lolita.tabs.images.save"), "#", :class => "save" %>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
<% end %>
|