adminpanel 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/README.md +9 -6
- data/Rakefile +1 -1
- data/app/helpers/adminpanel/application_helper.rb +2 -2
- data/app/helpers/adminpanel/custom_form_builder.rb +45 -9
- data/app/helpers/adminpanel/shared_pages_helper.rb +10 -3
- data/app/models/adminpanel/gallery.rb +6 -0
- data/app/models/adminpanel/image.rb +3 -8
- data/app/models/adminpanel/section.rb +16 -6
- data/app/uploaders/adminpanel/image_uploader.rb +2 -2
- data/app/views/adminpanel/categories/_categories_table.html.erb +1 -1
- data/app/views/adminpanel/categories/index.html.erb +9 -8
- data/app/views/adminpanel/galleries/edit.html.erb +3 -10
- data/app/views/adminpanel/galleries/index.html.erb +2 -2
- data/app/views/adminpanel/galleries/new.html.erb +3 -3
- data/app/views/adminpanel/sections/edit.html.erb +11 -15
- data/app/views/shared/_form_fields.html.erb +16 -9
- data/app/views/shared/_image_fields.html.erb +2 -23
- data/app/views/shared/_init_editor.html.erb +12 -12
- data/app/views/shared/show.html.erb +4 -3
- data/config/locales/es.yml +3 -0
- data/lib/adminpanel.rb +1 -1
- data/lib/adminpanel/active_record/adminpanel_extension.rb +142 -0
- data/lib/adminpanel/version.rb +1 -1
- data/lib/generators/adminpanel/gallery/gallery_generator.rb +41 -0
- data/lib/generators/adminpanel/gallery/templates/gallery_migration.rb +11 -0
- data/lib/generators/adminpanel/gallery/templates/gallery_template.rb +8 -0
- data/lib/generators/adminpanel/gallery/templates/uploader.rb +86 -0
- data/lib/generators/adminpanel/initialize/initialize_generator.rb +22 -12
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb +1 -1
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb +3 -4
- data/lib/generators/adminpanel/initialize/templates/section_uploader.rb +86 -0
- data/lib/generators/adminpanel/resource/resource_generator.rb +72 -22
- data/lib/tasks/adminpanel/adminpanel.rake +1 -1
- data/spec/dummy/.gitignore +2 -1
- data/spec/dummy/app/controllers/adminpanel/categories_controller.rb +2 -2
- data/spec/dummy/app/controllers/adminpanel/products_controller.rb +3 -3
- data/spec/dummy/app/models/adminpanel/categorization.rb +17 -17
- data/spec/dummy/app/models/adminpanel/photo.rb +8 -0
- data/spec/dummy/app/models/adminpanel/product.rb +49 -26
- data/spec/dummy/app/uploader/adminpanel/photo_uploader.rb +86 -0
- data/spec/dummy/app/uploader/adminpanel/section_uploader.rb +86 -0
- data/spec/features/section_pages_spec.rb +4 -4
- data/spec/features/shared_pages_spec.rb +15 -15
- data/spec/generators/gallery_generator_spec.rb +53 -0
- data/spec/generators/initialize_generator_spec.rb +19 -12
- data/spec/generators/resource_generator_spec.rb +44 -37
- data/spec/support/define_factory_models.rb +3 -5
- data/spec/support/test_database.rb +8 -3
- data/spec/tasks/adminpanel_rake_spec.rb +5 -5
- metadata +18 -7
- data/app/helpers/adminpanel/class_definitions_helper.rb +0 -10
- data/app/views/adminpanel/sections/_image_fields.html.erb +0 -24
- data/lib/adminpanel/active_record_extension.rb +0 -123
@@ -14,8 +14,7 @@ ActiveRecord::Migration.create_table :adminpanel_galleries do |t|
|
|
14
14
|
end
|
15
15
|
ActiveRecord::Migration.create_table :adminpanel_images do |t|
|
16
16
|
t.string :file
|
17
|
-
t.string :
|
18
|
-
t.string :model
|
17
|
+
t.string :section_id
|
19
18
|
t.datetime :created_at, :null => false
|
20
19
|
t.datetime :updated_at, :null => false
|
21
20
|
end
|
@@ -26,6 +25,12 @@ ActiveRecord::Migration.create_table :adminpanel_products do |t|
|
|
26
25
|
t.datetime :created_at, :null => false
|
27
26
|
t.datetime :updated_at, :null => false
|
28
27
|
end
|
28
|
+
ActiveRecord::Migration.create_table :adminpanel_photos do |t|
|
29
|
+
t.string :file
|
30
|
+
t.text :product_id
|
31
|
+
t.datetime :created_at, :null => false
|
32
|
+
t.datetime :updated_at, :null => false
|
33
|
+
end
|
29
34
|
ActiveRecord::Migration.create_table :adminpanel_categories do |t|
|
30
35
|
t.string :name
|
31
36
|
t.datetime :created_at, :null => false
|
@@ -61,4 +66,4 @@ RSpec.configure do |config|
|
|
61
66
|
raise ActiveRecord::Rollback
|
62
67
|
end
|
63
68
|
end
|
64
|
-
end
|
69
|
+
end
|
@@ -7,16 +7,16 @@ describe "adminpanel rake task" do
|
|
7
7
|
Rake::Task.define_task(:environment)
|
8
8
|
end
|
9
9
|
|
10
|
-
describe "adminpanel:populate[
|
10
|
+
describe "adminpanel:populate[10, product, name:name description:lorem price:number]" do
|
11
11
|
|
12
12
|
let(:has_nil_attribute) { false }
|
13
13
|
before do
|
14
|
-
Rake.application.invoke_task "adminpanel:populate[
|
14
|
+
Rake.application.invoke_task "adminpanel:populate[10, product, name:name description:lorem price:number]"
|
15
15
|
end
|
16
16
|
|
17
17
|
|
18
|
-
it "should generate
|
19
|
-
Adminpanel::Product.all.count.should eq
|
18
|
+
it "should generate 10 product records" do
|
19
|
+
Adminpanel::Product.all.count.should eq 10
|
20
20
|
end
|
21
21
|
|
22
22
|
it "attributes shouldn't be nil" do
|
@@ -40,7 +40,7 @@ describe "adminpanel rake task" do
|
|
40
40
|
(Adminpanel::Section.last.name.should eq("Mission")) &&
|
41
41
|
(Adminpanel::Section.last.page.should eq("about")) &&
|
42
42
|
(Adminpanel::Section.last.key.should eq("mission")) &&
|
43
|
-
(Adminpanel::Section.last.has_description.should
|
43
|
+
(Adminpanel::Section.last.has_description.should be_false) &&
|
44
44
|
(Adminpanel::Section.last.has_image.should be_false)
|
45
45
|
)
|
46
46
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adminpanel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 6
|
10
|
+
version: 1.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jose Ramon Camacho
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2014-03-
|
19
|
+
date: 2014-03-20 00:00:00 -06:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -420,7 +420,6 @@ files:
|
|
420
420
|
- app/controllers/adminpanel/users_controller.rb
|
421
421
|
- app/helpers/adminpanel/application_helper.rb
|
422
422
|
- app/helpers/adminpanel/breadcrumbs_helper.rb
|
423
|
-
- app/helpers/adminpanel/class_definitions_helper.rb
|
424
423
|
- app/helpers/adminpanel/custom_form_builder.rb
|
425
424
|
- app/helpers/adminpanel/pluralizations_helper.rb
|
426
425
|
- app/helpers/adminpanel/rest_actions_helper.rb
|
@@ -450,7 +449,6 @@ files:
|
|
450
449
|
- app/views/adminpanel/galleries/show.html.erb
|
451
450
|
- app/views/adminpanel/galleries/update.html.erb
|
452
451
|
- app/views/adminpanel/pages/index.html.erb
|
453
|
-
- app/views/adminpanel/sections/_image_fields.html.erb
|
454
452
|
- app/views/adminpanel/sections/_sections_table.html.erb
|
455
453
|
- app/views/adminpanel/sections/edit.html.erb
|
456
454
|
- app/views/adminpanel/sections/index.html.erb
|
@@ -473,14 +471,19 @@ files:
|
|
473
471
|
- config/locales/es.yml
|
474
472
|
- config/routes.rb
|
475
473
|
- lib/adminpanel.rb
|
476
|
-
- lib/adminpanel/
|
474
|
+
- lib/adminpanel/active_record/adminpanel_extension.rb
|
477
475
|
- lib/adminpanel/engine.rb
|
478
476
|
- lib/adminpanel/version.rb
|
477
|
+
- lib/generators/adminpanel/gallery/gallery_generator.rb
|
478
|
+
- lib/generators/adminpanel/gallery/templates/gallery_migration.rb
|
479
|
+
- lib/generators/adminpanel/gallery/templates/gallery_template.rb
|
480
|
+
- lib/generators/adminpanel/gallery/templates/uploader.rb
|
479
481
|
- lib/generators/adminpanel/initialize/initialize_generator.rb
|
480
482
|
- lib/generators/adminpanel/initialize/templates/adminpanel_setup.rb
|
481
483
|
- lib/generators/adminpanel/initialize/templates/category_template.rb
|
482
484
|
- lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb
|
483
485
|
- lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb
|
486
|
+
- lib/generators/adminpanel/initialize/templates/section_uploader.rb
|
484
487
|
- lib/generators/adminpanel/resource/resource_generator.rb
|
485
488
|
- lib/generators/adminpanel/resource/templates/controller.rb
|
486
489
|
- lib/generators/adminpanel/resource/templates/migration.rb
|
@@ -502,7 +505,10 @@ files:
|
|
502
505
|
- spec/dummy/app/models/.gitkeep
|
503
506
|
- spec/dummy/app/models/adminpanel/categorization.rb
|
504
507
|
- spec/dummy/app/models/adminpanel/category.rb
|
508
|
+
- spec/dummy/app/models/adminpanel/photo.rb
|
505
509
|
- spec/dummy/app/models/adminpanel/product.rb
|
510
|
+
- spec/dummy/app/uploader/adminpanel/photo_uploader.rb
|
511
|
+
- spec/dummy/app/uploader/adminpanel/section_uploader.rb
|
506
512
|
- spec/dummy/app/views/layouts/application.html.erb
|
507
513
|
- spec/dummy/config.ru
|
508
514
|
- spec/dummy/config/application.rb
|
@@ -535,6 +541,7 @@ files:
|
|
535
541
|
- spec/features/galleries_pages_spec.rb
|
536
542
|
- spec/features/section_pages_spec.rb
|
537
543
|
- spec/features/shared_pages_spec.rb
|
544
|
+
- spec/generators/gallery_generator_spec.rb
|
538
545
|
- spec/generators/initialize_generator_spec.rb
|
539
546
|
- spec/generators/resource_generator_spec.rb
|
540
547
|
- spec/models/gallery_spec.rb
|
@@ -601,7 +608,10 @@ test_files:
|
|
601
608
|
- spec/dummy/app/models/.gitkeep
|
602
609
|
- spec/dummy/app/models/adminpanel/categorization.rb
|
603
610
|
- spec/dummy/app/models/adminpanel/category.rb
|
611
|
+
- spec/dummy/app/models/adminpanel/photo.rb
|
604
612
|
- spec/dummy/app/models/adminpanel/product.rb
|
613
|
+
- spec/dummy/app/uploader/adminpanel/photo_uploader.rb
|
614
|
+
- spec/dummy/app/uploader/adminpanel/section_uploader.rb
|
605
615
|
- spec/dummy/app/views/layouts/application.html.erb
|
606
616
|
- spec/dummy/config.ru
|
607
617
|
- spec/dummy/config/application.rb
|
@@ -634,6 +644,7 @@ test_files:
|
|
634
644
|
- spec/features/galleries_pages_spec.rb
|
635
645
|
- spec/features/section_pages_spec.rb
|
636
646
|
- spec/features/shared_pages_spec.rb
|
647
|
+
- spec/generators/gallery_generator_spec.rb
|
637
648
|
- spec/generators/initialize_generator_spec.rb
|
638
649
|
- spec/generators/resource_generator_spec.rb
|
639
650
|
- spec/models/gallery_spec.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<div class="product-image">
|
2
|
-
<% unless f.object.new_record? %>
|
3
|
-
<div class="control-group">
|
4
|
-
<div class="controls">
|
5
|
-
<%= image_tag f.object.file_url(:thumb) %>
|
6
|
-
</div>
|
7
|
-
</div>
|
8
|
-
<% end %>
|
9
|
-
<div class="control-group">
|
10
|
-
<%= f.label t("model.Adminpanel::Image"), :class => "control-label" %>
|
11
|
-
<div class="controls">
|
12
|
-
<%= f.file_field :file %>
|
13
|
-
<%= f.hidden_field :model, :value => model_name %>
|
14
|
-
<%= f.hidden_field :_destroy %>
|
15
|
-
<%=
|
16
|
-
content_tag(
|
17
|
-
:button,
|
18
|
-
t("action.delete"),
|
19
|
-
:class => "btn btn-danger remove_fields"
|
20
|
-
)
|
21
|
-
%>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
</div>
|
@@ -1,123 +0,0 @@
|
|
1
|
-
module ActiveRecordExtension
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
#instance methods
|
4
|
-
# def foo
|
5
|
-
|
6
|
-
# end
|
7
|
-
|
8
|
-
# static(class) methods
|
9
|
-
module ClassMethods
|
10
|
-
def form_attributes
|
11
|
-
[{
|
12
|
-
"name" => {
|
13
|
-
"type" => "text_field",
|
14
|
-
"name" => "name"
|
15
|
-
}
|
16
|
-
}]
|
17
|
-
end
|
18
|
-
|
19
|
-
def display_name
|
20
|
-
"display_name"
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_attribute_name(field)
|
24
|
-
form_attributes.each do |attribute|
|
25
|
-
attribute.each do |name, properties|
|
26
|
-
if name == field
|
27
|
-
return properties["name"]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
return ":("
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def get_attribute_name(field)
|
36
|
-
form_attributes.each do |attribute|
|
37
|
-
attribute.each do |name, properties|
|
38
|
-
if name == field
|
39
|
-
return properties["name"]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
return ":("
|
44
|
-
end
|
45
|
-
|
46
|
-
def get_attribute_label(field)
|
47
|
-
form_attributes.each do |attribute|
|
48
|
-
attribute.each do |name, properties|
|
49
|
-
if name == field
|
50
|
-
return properties["label"]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
return ":("
|
55
|
-
end
|
56
|
-
|
57
|
-
def get_attribute_placeholder(field)
|
58
|
-
form_attributes.each do |attribute|
|
59
|
-
attribute.each do |name, properties|
|
60
|
-
if name == field
|
61
|
-
return properties["placeholder"]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
return ":("
|
66
|
-
end
|
67
|
-
|
68
|
-
def display_attributes
|
69
|
-
display_attributes = []
|
70
|
-
form_attributes.each do |attribute|
|
71
|
-
attribute.each do |name, properties|
|
72
|
-
if properties["show"].nil? || properties["show"] == "true"
|
73
|
-
display_attributes << attribute
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
return display_attributes
|
79
|
-
end
|
80
|
-
|
81
|
-
def has_images?
|
82
|
-
form_attributes.each do |fields|
|
83
|
-
fields.each do |attribute, properties|
|
84
|
-
if properties["type"] == "adminpanel_file_field"
|
85
|
-
return true
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
return false
|
90
|
-
end
|
91
|
-
|
92
|
-
def belongs_to_relationships
|
93
|
-
belongs_to_classes = []
|
94
|
-
form_attributes.each do |fields|
|
95
|
-
fields.each do |attribute, properties|
|
96
|
-
if properties["type"] == "belongs_to"
|
97
|
-
belongs_to_classes << properties["model"].classify.constantize
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
return belongs_to_classes
|
102
|
-
end
|
103
|
-
|
104
|
-
def has_many_relationships
|
105
|
-
has_many_classes = []
|
106
|
-
form_attributes.each do |fields|
|
107
|
-
fields.each do |attribute, properties|
|
108
|
-
if properties["type"] == "has_many"
|
109
|
-
has_many_classes << properties["model"].classify.constantize
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
return has_many_classes
|
114
|
-
end
|
115
|
-
|
116
|
-
def icon
|
117
|
-
"icon-truck"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# include the extension
|
123
|
-
ActiveRecord::Base.send(:include, ActiveRecordExtension)
|