adminpanel 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -2
- data/.ruby-version +1 -0
- data/.travis.yml +8 -8
- data/Gemfile +26 -24
- data/README.md +57 -57
- data/adminpanel.gemspec +41 -39
- data/app/assets/fonts/fontawesome-webfont.svg +254 -254
- data/app/assets/javascripts/adminpanel/bootstrap-datepicker.js +1159 -1159
- data/app/assets/javascripts/adminpanel/bootstrap-timepicker.js +803 -803
- data/app/assets/javascripts/adminpanel/bootstrap.js +2170 -2170
- data/app/assets/javascripts/adminpanel/{products.js → images_form.js} +13 -13
- data/app/assets/javascripts/adminpanel/imagesloaded.js +12 -12
- data/app/assets/javascripts/adminpanel/jquery.dataTables.min.js +155 -155
- data/app/assets/javascripts/adminpanel/jquery.facybox.js +395 -395
- data/app/assets/javascripts/adminpanel/jquery.masonry.min.js +9 -9
- data/app/assets/javascripts/adminpanel/jquery.slimscroll.min.js +13 -13
- data/app/assets/javascripts/adminpanel/medium-editor.js +702 -702
- data/app/assets/javascripts/adminpanel/realm.js +87 -87
- data/app/assets/javascripts/adminpanel/tables.js +126 -126
- data/app/assets/javascripts/application-admin.js +15 -15
- data/app/assets/stylesheets/adminpanel/_clearfix.css.scss +7 -7
- data/app/assets/stylesheets/adminpanel/alertify.css +241 -241
- data/app/assets/stylesheets/adminpanel/bootstrap.css +6103 -6103
- data/app/assets/stylesheets/adminpanel/colorpicker.css +6 -6
- data/app/assets/stylesheets/adminpanel/datepicker.css +9 -9
- data/app/assets/stylesheets/adminpanel/elfinder.min.css +59 -59
- data/app/assets/stylesheets/adminpanel/facybox.css +146 -146
- data/app/assets/stylesheets/adminpanel/font-awesome.min.css +33 -33
- data/app/assets/stylesheets/adminpanel/fullcalendar.css +618 -618
- data/app/assets/stylesheets/adminpanel/fullcalendar.print.css +61 -61
- data/app/assets/stylesheets/adminpanel/select2.css +524 -524
- data/app/assets/stylesheets/adminpanel/theme.css +1571 -1571
- data/app/assets/stylesheets/adminpanel/timepicker.css +82 -82
- data/app/assets/stylesheets/application-admin.css +13 -13
- data/app/controllers/adminpanel/application_controller.rb +32 -17
- data/app/controllers/adminpanel/galleries_controller.rb +80 -80
- data/app/controllers/adminpanel/sections_controller.rb +45 -45
- data/app/controllers/adminpanel/sessions_controller.rb +26 -26
- data/app/controllers/adminpanel/users_controller.rb +84 -84
- data/app/helpers/adminpanel/application_helper.rb +41 -51
- data/app/helpers/adminpanel/breadcrumbs_helper.rb +16 -0
- data/app/helpers/adminpanel/custom_form_builder.rb +248 -0
- data/app/helpers/adminpanel/images_helper.rb +9 -9
- data/app/helpers/adminpanel/rest_actions_helper.rb +47 -0
- data/app/helpers/adminpanel/router_helper.rb +33 -0
- data/app/helpers/adminpanel/sessions_helper.rb +25 -25
- data/app/models/adminpanel/gallery.rb +60 -60
- data/app/models/adminpanel/image.rb +14 -14
- data/app/models/adminpanel/section.rb +22 -22
- data/app/models/adminpanel/user.rb +35 -35
- data/app/uploaders/adminpanel/gallery_uploader.rb +55 -55
- data/app/uploaders/adminpanel/image_uploader.rb +57 -57
- data/app/views/adminpanel/galleries/_galleries_table.html.erb +14 -14
- data/app/views/adminpanel/galleries/create.html.erb +2 -2
- data/app/views/adminpanel/galleries/delete.html.erb +2 -2
- data/app/views/adminpanel/galleries/edit.html.erb +25 -25
- data/app/views/adminpanel/galleries/index.html.erb +51 -51
- data/app/views/adminpanel/galleries/new.html.erb +17 -17
- data/app/views/adminpanel/galleries/show.html.erb +17 -17
- data/app/views/adminpanel/galleries/update.html.erb +2 -2
- data/app/views/adminpanel/sections/_image_fields.html.erb +23 -23
- data/app/views/adminpanel/sections/_sections_table.html.erb +16 -16
- data/app/views/adminpanel/sections/create.html.erb +2 -2
- data/app/views/adminpanel/sections/destroy.html.erb +2 -2
- data/app/views/adminpanel/sections/edit.html.erb +41 -41
- data/app/views/adminpanel/sections/index.html.erb +44 -44
- data/app/views/adminpanel/sections/new.html.erb +26 -26
- data/app/views/adminpanel/sections/show.html.erb +30 -30
- data/app/views/adminpanel/sections/update.html.erb +2 -2
- data/app/views/adminpanel/sessions/new.html.erb +25 -25
- data/app/views/adminpanel/users/_user_form.html.erb +20 -20
- data/app/views/adminpanel/users/edit.html.erb +5 -5
- data/app/views/adminpanel/users/index.html.erb +49 -49
- data/app/views/adminpanel/users/new.html.erb +5 -5
- data/app/views/adminpanel/users/show.html.erb +20 -20
- data/app/views/layouts/_shim.html.erb +3 -3
- data/app/views/layouts/_side_menu.html.erb +49 -43
- data/app/views/layouts/_top_bar.html.erb +43 -43
- data/app/views/layouts/admin-login.html.erb +28 -28
- data/app/views/layouts/admin.html.erb +41 -39
- data/app/views/shared/_breadcrumb.html.erb +6 -6
- data/app/views/shared/_error_messages.html.erb +16 -16
- data/app/views/shared/_form_fields.html.erb +25 -0
- data/app/views/{adminpanel/products → shared}/_image_fields.html.erb +23 -23
- data/app/views/shared/_init_editor.html.erb +24 -0
- data/app/views/shared/edit.html.erb +28 -0
- data/app/views/shared/index.html.erb +94 -0
- data/app/views/shared/new.html.erb +28 -0
- data/app/views/shared/show.html.erb +63 -0
- data/config/locales/en.yml +5 -5
- data/config/locales/es.yml +127 -129
- data/config/routes.rb +24 -16
- data/lib/adminpanel.rb +9 -7
- data/lib/adminpanel/active_record_extension.rb +38 -0
- data/lib/adminpanel/engine.rb +5 -5
- data/lib/adminpanel/version.rb +3 -3
- data/lib/generators/adminpanel/initialize/initialize_generator.rb +17 -0
- data/lib/generators/adminpanel/{install/templates/migrations → initialize/templates}/create_adminpanel_tables.rb +45 -64
- data/lib/generators/adminpanel/resource/resource_generator.rb +105 -0
- data/lib/generators/adminpanel/resource/templates/controller.rb +4 -0
- data/lib/generators/adminpanel/resource/templates/migration.rb +9 -0
- data/lib/generators/adminpanel/resource/templates/resource.rb +19 -0
- data/spec/dummy/.gitignore +17 -17
- data/spec/dummy/README.rdoc +261 -261
- data/spec/dummy/Rakefile +7 -7
- data/{app/views/adminpanel/categories/show.html.erb → spec/dummy/app/adminpanel/products.rb} +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -13
- data/spec/dummy/app/assets/stylesheets/application.css +13 -13
- data/spec/dummy/app/controllers/adminpanel/.gitkeep +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -11
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/views/layouts/application.html.erb +14 -14
- data/spec/dummy/config.ru +4 -4
- data/spec/dummy/config/application.rb +62 -62
- data/spec/dummy/config/boot.rb +9 -9
- data/spec/dummy/config/carrierwve.rb +5 -5
- data/spec/dummy/config/database.yml +24 -24
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +41 -41
- data/spec/dummy/config/environments/production.rb +72 -72
- data/spec/dummy/config/environments/test.rb +41 -41
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/inflections.rb +15 -15
- data/spec/dummy/config/initializers/mime_types.rb +5 -5
- data/spec/dummy/config/initializers/secret_token.rb +8 -8
- data/spec/dummy/config/initializers/session_store.rb +8 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +5 -5
- data/spec/dummy/config/routes.rb +4 -4
- data/spec/dummy/db/schema.rb +15 -15
- data/spec/dummy/public/404.html +26 -26
- data/spec/dummy/public/422.html +26 -26
- data/spec/dummy/public/500.html +25 -25
- data/spec/dummy/public/uploads/gallery/file/1/hipster.jpg +0 -0
- data/spec/dummy/public/uploads/gallery/file/1/thumb_hipster.jpg +0 -0
- data/spec/dummy/script/rails +6 -6
- data/spec/features/authentication_pages_spec.rb +43 -43
- data/spec/features/galleries_pages_spec.rb +124 -124
- data/spec/features/section_pages_spec.rb +37 -37
- data/spec/features/user_pages_spec.rb +48 -48
- data/spec/generators/initialize_spec.rb +9 -0
- data/spec/generators/resource_spec.rb +122 -0
- data/spec/models/gallery_spec.rb +21 -21
- data/spec/models/section_spec.rb +66 -66
- data/spec/models/user_spec.rb +105 -105
- data/spec/spec_helper.rb +32 -31
- data/spec/support/define_factory_models.rb +25 -36
- data/spec/support/helper_methods.rb +26 -26
- data/spec/support/submit_forms_without_button.rb +16 -16
- data/spec/support/test_database.rb +45 -58
- data/spec/uploaders/gallery_uploader_spec.rb +36 -30
- data/spec/uploaders/image_uploader_spec.rb +30 -29
- metadata +208 -64
- checksums.yaml +0 -7
- data/app/assets/javascripts/adminpanel/init_editor.js +0 -28
- data/app/controllers/adminpanel/categories_controller.rb +0 -41
- data/app/controllers/adminpanel/products_controller.rb +0 -88
- data/app/helpers/custom_form_builder.rb +0 -219
- data/app/models/adminpanel/category.rb +0 -7
- data/app/models/adminpanel/product.rb +0 -24
- data/app/views/adminpanel/categories/edit.html.erb +0 -18
- data/app/views/adminpanel/categories/index.html.erb +0 -55
- data/app/views/adminpanel/categories/new.html.erb +0 -18
- data/app/views/adminpanel/products/.DS_Store +0 -0
- data/app/views/adminpanel/products/_product_form.html.erb +0 -31
- data/app/views/adminpanel/products/edit.html.erb +0 -10
- data/app/views/adminpanel/products/index.html.erb +0 -51
- data/app/views/adminpanel/products/new.html.erb +0 -10
- data/app/views/adminpanel/products/show.html.erb +0 -61
- data/config/database.yml +0 -24
- data/lib/generators/adminpanel/install/install_generator.rb +0 -12
- data/spec/features/categories_pages_spec.rb +0 -44
- data/spec/features/product_pages_spec.rb +0 -64
- data/spec/models/category_spec.rb +0 -58
- data/spec/models/product_spec.rb +0 -51
@@ -1,27 +1,27 @@
|
|
1
|
-
module Adminpanel
|
2
|
-
class SessionsController < Adminpanel::ApplicationController
|
3
|
-
|
4
|
-
layout "admin-login"
|
5
|
-
skip_before_filter :signed_in_user
|
6
|
-
|
7
|
-
def new
|
8
|
-
end
|
9
|
-
|
10
|
-
def create
|
11
|
-
user = User.find_by_email(params[:session][:email].downcase)
|
12
|
-
if user && user.authenticate(params[:session][:password])
|
13
|
-
sign_in user
|
14
|
-
flash[:success] = t("authentication.signin success")
|
15
|
-
redirect_to root_url
|
16
|
-
else
|
17
|
-
flash.now[:error] = t("authentication.signin error")
|
18
|
-
render 'new'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def destroy
|
23
|
-
sign_out
|
24
|
-
redirect_to signin_path
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Adminpanel
|
2
|
+
class SessionsController < Adminpanel::ApplicationController
|
3
|
+
|
4
|
+
layout "admin-login"
|
5
|
+
skip_before_filter :signed_in_user, :set_model
|
6
|
+
|
7
|
+
def new
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
user = User.find_by_email(params[:session][:email].downcase)
|
12
|
+
if user && user.authenticate(params[:session][:password])
|
13
|
+
sign_in user
|
14
|
+
flash[:success] = t("authentication.signin success")
|
15
|
+
redirect_to root_url
|
16
|
+
else
|
17
|
+
flash.now[:error] = t("authentication.signin error")
|
18
|
+
render 'new'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def destroy
|
23
|
+
sign_out
|
24
|
+
redirect_to signin_path
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
@@ -1,85 +1,85 @@
|
|
1
|
-
module Adminpanel
|
2
|
-
class UsersController < Adminpanel::ApplicationController
|
3
|
-
# GET /admin/users
|
4
|
-
# GET /admin/users.json
|
5
|
-
def index
|
6
|
-
@users = User.all
|
7
|
-
|
8
|
-
respond_to do |format|
|
9
|
-
format.html # index.html.erb
|
10
|
-
format.json { render :json => @users }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# GET /admin/users/1
|
15
|
-
# GET /admin/users/1.json
|
16
|
-
def show
|
17
|
-
@user = User.find(params[:id])
|
18
|
-
|
19
|
-
respond_to do |format|
|
20
|
-
format.html # show.html.erb
|
21
|
-
format.json { render :json => @user }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# GET /admin/users/new
|
26
|
-
# GET /admin/users/new.json
|
27
|
-
def new
|
28
|
-
@user = User.new
|
29
|
-
|
30
|
-
respond_to do |format|
|
31
|
-
format.html # new.html.erb
|
32
|
-
format.json { render :json => @user }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# GET /admin/users/1/edit
|
37
|
-
def edit
|
38
|
-
@user = User.find(params[:id])
|
39
|
-
end
|
40
|
-
|
41
|
-
# POST /admin/users
|
42
|
-
# POST /admin/users.json
|
43
|
-
def create
|
44
|
-
@user = User.new(params[:user])
|
45
|
-
|
46
|
-
respond_to do |format|
|
47
|
-
if @user.save
|
48
|
-
format.html { redirect_to @user, :notice => t("user.success") }
|
49
|
-
format.json { render :json => @user, :status => :created, :location => @user }
|
50
|
-
else
|
51
|
-
format.html { render :action => "new" }
|
52
|
-
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# PUT /admin/users/1
|
58
|
-
# PUT /admin/users/1.json
|
59
|
-
def update
|
60
|
-
@user = User.find(params[:id])
|
61
|
-
|
62
|
-
respond_to do |format|
|
63
|
-
if @user.update_attributes(params[:user])
|
64
|
-
format.html { redirect_to @user, :notice => 'Se ha actualizado con exito.' }
|
65
|
-
format.json { head :no_content }
|
66
|
-
else
|
67
|
-
format.html { render :action => "edit" }
|
68
|
-
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# DELETE /admin/users/1
|
74
|
-
# DELETE /admin/users/1.json
|
75
|
-
def destroy
|
76
|
-
@user = User.find(params[:id])
|
77
|
-
@user.destroy
|
78
|
-
|
79
|
-
respond_to do |format|
|
80
|
-
format.html { redirect_to users_url }
|
81
|
-
format.json { head :no_content }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
1
|
+
module Adminpanel
|
2
|
+
class UsersController < Adminpanel::ApplicationController
|
3
|
+
# GET /admin/users
|
4
|
+
# GET /admin/users.json
|
5
|
+
def index
|
6
|
+
@users = User.all
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html # index.html.erb
|
10
|
+
format.json { render :json => @users }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /admin/users/1
|
15
|
+
# GET /admin/users/1.json
|
16
|
+
def show
|
17
|
+
@user = User.find(params[:id])
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
format.json { render :json => @user }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /admin/users/new
|
26
|
+
# GET /admin/users/new.json
|
27
|
+
def new
|
28
|
+
@user = User.new
|
29
|
+
|
30
|
+
respond_to do |format|
|
31
|
+
format.html # new.html.erb
|
32
|
+
format.json { render :json => @user }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET /admin/users/1/edit
|
37
|
+
def edit
|
38
|
+
@user = User.find(params[:id])
|
39
|
+
end
|
40
|
+
|
41
|
+
# POST /admin/users
|
42
|
+
# POST /admin/users.json
|
43
|
+
def create
|
44
|
+
@user = User.new(params[:user])
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
if @user.save
|
48
|
+
format.html { redirect_to @user, :notice => t("user.success") }
|
49
|
+
format.json { render :json => @user, :status => :created, :location => @user }
|
50
|
+
else
|
51
|
+
format.html { render :action => "new" }
|
52
|
+
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# PUT /admin/users/1
|
58
|
+
# PUT /admin/users/1.json
|
59
|
+
def update
|
60
|
+
@user = User.find(params[:id])
|
61
|
+
|
62
|
+
respond_to do |format|
|
63
|
+
if @user.update_attributes(params[:user])
|
64
|
+
format.html { redirect_to @user, :notice => 'Se ha actualizado con exito.' }
|
65
|
+
format.json { head :no_content }
|
66
|
+
else
|
67
|
+
format.html { render :action => "edit" }
|
68
|
+
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# DELETE /admin/users/1
|
74
|
+
# DELETE /admin/users/1.json
|
75
|
+
def destroy
|
76
|
+
@user = User.find(params[:id])
|
77
|
+
@user.destroy
|
78
|
+
|
79
|
+
respond_to do |format|
|
80
|
+
format.html { redirect_to users_url }
|
81
|
+
format.json { head :no_content }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
85
|
end
|
@@ -1,52 +1,42 @@
|
|
1
|
-
module Adminpanel
|
2
|
-
module ApplicationHelper
|
3
|
-
include SessionsHelper
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def breadcrumb_add(title, url)
|
45
|
-
initialize_breadcrumb << { :title => title, :url => url }
|
46
|
-
end
|
47
|
-
|
48
|
-
def render_breadcrumb(divider)
|
49
|
-
render :partial => 'shared/breadcrumb', :locals => { :nav => initialize_breadcrumb, :divider => divider }
|
50
|
-
end
|
51
|
-
end
|
1
|
+
module Adminpanel
|
2
|
+
module ApplicationHelper
|
3
|
+
include SessionsHelper
|
4
|
+
include BreadcrumbsHelper
|
5
|
+
|
6
|
+
def custom_form_for(name, *args, &block)
|
7
|
+
options = args.extract_options!
|
8
|
+
options.reverse_merge! :builder => Adminpanel::CustomFormBuilder, :html => { :class => "form-horizontal" }
|
9
|
+
|
10
|
+
form_for(name, *(args << options), &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_title(page_title)
|
14
|
+
base_title = t("Panel title")
|
15
|
+
if page_title.empty?
|
16
|
+
base_title
|
17
|
+
else
|
18
|
+
"#{page_title} | #{base_title}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def is_current_section?(*controller)
|
23
|
+
controller.include?(params[:controller]) ? 'active' : nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def section_is_login(section_name)
|
27
|
+
section_name.downcase == 'login'
|
28
|
+
end
|
29
|
+
|
30
|
+
def link_to_add_fields(name, f, association, model_name)
|
31
|
+
new_object = f.object.send(association).klass.new
|
32
|
+
id = new_object.object_id
|
33
|
+
fields = f.fields_for(association, new_object, :child_index => id) do |builder|
|
34
|
+
render("shared/" + association.to_s.singularize + "_fields", :f => builder, :model_name => model_name)
|
35
|
+
end
|
36
|
+
link_to(content_tag(:div, content_tag(:button,
|
37
|
+
content_tag(:h6, name, :id => "add-image-button"),
|
38
|
+
:class => "btn btn-success btn-mini"), :class => "mws-form-row"),
|
39
|
+
'#', :class => "add_fields", :data => {:id => id, :fields => fields.gsub("\n", "")})
|
40
|
+
end
|
41
|
+
end
|
52
42
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Adminpanel
|
2
|
+
module BreadcrumbsHelper
|
3
|
+
|
4
|
+
def initialize_breadcrumb
|
5
|
+
@breadcrumb ||= [:title => 'Inicio', :url => root_url]
|
6
|
+
end
|
7
|
+
|
8
|
+
def breadcrumb_add(title, url)
|
9
|
+
initialize_breadcrumb << { :title => title, :url => url }
|
10
|
+
end
|
11
|
+
|
12
|
+
def render_breadcrumb(divider)
|
13
|
+
render :partial => 'shared/breadcrumb', :locals => { :nav => initialize_breadcrumb, :divider => divider }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,248 @@
|
|
1
|
+
module Adminpanel
|
2
|
+
class CustomFormBuilder < ActionView::Helpers::FormBuilder
|
3
|
+
|
4
|
+
alias_method :text_field_original, :text_field
|
5
|
+
alias_method :radio_button_original, :radio_button
|
6
|
+
alias_method :checkbox_original, :check_box
|
7
|
+
|
8
|
+
def text_field(name, *args)
|
9
|
+
options = args.extract_options!
|
10
|
+
|
11
|
+
options.reverse_merge! :class => "span7"
|
12
|
+
options.reverse_merge! :label => name
|
13
|
+
label = options[:label]
|
14
|
+
options.delete(:label)
|
15
|
+
|
16
|
+
@template.content_tag :div, :class => "control-group" do
|
17
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
18
|
+
@template.content_tag(:div, super(name, *args << options), :class => "controls")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def adminpanel_file_field(name, *args)
|
23
|
+
options = args.extract_options!
|
24
|
+
|
25
|
+
options.reverse_merge! :class => "span7"
|
26
|
+
options.reverse_merge! :label => name
|
27
|
+
label = options[:label]
|
28
|
+
options.delete(:label)
|
29
|
+
|
30
|
+
@template.content_tag :div, :class => "control-group" do
|
31
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
32
|
+
@template.content_tag(:div, file_field(name, *args << options), :class => "controls")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def wysiwyg_field(name, *args)
|
37
|
+
options = args.extract_options!
|
38
|
+
label = options["label"]
|
39
|
+
options.delete("label")
|
40
|
+
|
41
|
+
@template.content_tag(:div, :class => "control-group") do
|
42
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
43
|
+
@template.content_tag(:div, :class => "controls") do
|
44
|
+
if self.object.send(name).nil?
|
45
|
+
@template.content_tag(
|
46
|
+
:div,
|
47
|
+
self.object.send(name),
|
48
|
+
:id => name,
|
49
|
+
"data-placeholder" => I18n.t("Write description here")
|
50
|
+
)
|
51
|
+
else
|
52
|
+
@template.content_tag(
|
53
|
+
:div,
|
54
|
+
self.object.send(name).html_safe,
|
55
|
+
:id => name,
|
56
|
+
"data-placeholder" => I18n.t("Write description here")
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def radio_button_group(name, buttons, options)
|
64
|
+
|
65
|
+
options.reverse_merge! :label => name
|
66
|
+
options.reverse_merge! :html => {}
|
67
|
+
output = ""
|
68
|
+
|
69
|
+
buttons.each do |b|
|
70
|
+
output += @template.content_tag(:label, radio_button_original(name, b, options[:html]) + b.capitalize, :class => "radio")
|
71
|
+
end
|
72
|
+
|
73
|
+
@template.content_tag :div, :class => "control-group" do
|
74
|
+
@template.content_tag(:label, options[:label], :class => "control-label") +
|
75
|
+
@template.content_tag(:div, output, { :class => "controls"}, false)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def check_box(name, *args)
|
80
|
+
options = args.extract_options!
|
81
|
+
|
82
|
+
options.reverse_merge! :class => "span7"
|
83
|
+
options.reverse_merge! :label => name
|
84
|
+
options.reverse_merge! :include_blank => "(Seleccione por favor)";
|
85
|
+
label = options[:label]
|
86
|
+
options.delete(:label)
|
87
|
+
|
88
|
+
@template.content_tag(:label, super(name, *args) + label, :class => "checkbox")
|
89
|
+
end
|
90
|
+
|
91
|
+
def select(name, select_options, *args)
|
92
|
+
options = args.extract_options!
|
93
|
+
|
94
|
+
options.reverse_merge! :class => "span7"
|
95
|
+
options.reverse_merge! :label => name
|
96
|
+
options.reverse_merge! :include_blank => "(Seleccione por favor)";
|
97
|
+
label = options[:label]
|
98
|
+
options.delete(:label)
|
99
|
+
|
100
|
+
@template.content_tag :div, :class => "control-group" do
|
101
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
102
|
+
@template.content_tag(:div, super(name, select_options, *args << options), :class => "controls")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def number_field(name, *args)
|
107
|
+
options = args.extract_options!
|
108
|
+
|
109
|
+
options.reverse_merge! :class => "span5"
|
110
|
+
options.reverse_merge! :label => name
|
111
|
+
label = options[:label]
|
112
|
+
options.delete(:label)
|
113
|
+
|
114
|
+
@template.content_tag :div, :class => "control-group" do
|
115
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
116
|
+
@template.content_tag(:div, super(name, *args << options), :class => "controls")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def password_field(name, *args)
|
121
|
+
options = args.extract_options!
|
122
|
+
|
123
|
+
options.reverse_merge! :class => "span7"
|
124
|
+
options.reverse_merge! :label => name
|
125
|
+
label = options[:label]
|
126
|
+
options.delete(:label)
|
127
|
+
|
128
|
+
@template.content_tag :div, :class => "control-group" do
|
129
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
130
|
+
@template.content_tag(:div, super(name, *args << options), :class => "controls")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def text_area(name, *args)
|
135
|
+
options = args.extract_options!
|
136
|
+
|
137
|
+
options.reverse_merge! :class => "span7"
|
138
|
+
options.reverse_merge! :rows => "10"
|
139
|
+
options.reverse_merge! :label => name
|
140
|
+
label = options[:label]
|
141
|
+
options.delete(:label)
|
142
|
+
|
143
|
+
@template.content_tag :div, :class => "control-group" do
|
144
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
145
|
+
@template.content_tag(:div, super(name, *args << options), :class => "controls")
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def submit(name, *args)
|
150
|
+
options = args.extract_options!
|
151
|
+
|
152
|
+
options.reverse_merge! :class => "btn btn-primary"
|
153
|
+
super(name, *args << options)
|
154
|
+
end
|
155
|
+
|
156
|
+
def datepicker(name, *args)
|
157
|
+
|
158
|
+
options = args.extract_options!
|
159
|
+
|
160
|
+
options.reverse_merge! :value => Time.now.strftime("%d-%m-%Y")
|
161
|
+
options.reverse_merge! :label => name
|
162
|
+
label = options[:label]
|
163
|
+
options.delete(:label)
|
164
|
+
|
165
|
+
@template.content_tag :div, :class => "control-group" do
|
166
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
167
|
+
@template.content_tag(
|
168
|
+
:div,
|
169
|
+
@template.content_tag(
|
170
|
+
:div,
|
171
|
+
text_field_original(name, *args << options) +
|
172
|
+
@template.content_tag(
|
173
|
+
:span,
|
174
|
+
@template.content_tag(
|
175
|
+
:i,
|
176
|
+
nil,
|
177
|
+
:class => "icon-th"
|
178
|
+
),
|
179
|
+
:class => "add-on"
|
180
|
+
),
|
181
|
+
{
|
182
|
+
:class => "input-append date span5 datepicker datepicker-basic",
|
183
|
+
:data => {
|
184
|
+
:date_format => "dd-mm-yyyy",
|
185
|
+
:date => options[:value]
|
186
|
+
}
|
187
|
+
}
|
188
|
+
),
|
189
|
+
:class => "controls"
|
190
|
+
)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def prepend_field(name, *args)
|
195
|
+
|
196
|
+
options = args.extract_options!
|
197
|
+
|
198
|
+
options.reverse_merge! :label => name
|
199
|
+
label = options[:label]
|
200
|
+
options.delete(:label)
|
201
|
+
|
202
|
+
options.reverse_merge! :symbol => "#"
|
203
|
+
symbol = options[:symbol]
|
204
|
+
options.delete(:symbol)
|
205
|
+
|
206
|
+
@template.content_tag :div, :class => "control-group" do
|
207
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
208
|
+
@template.content_tag(
|
209
|
+
:div,
|
210
|
+
@template.content_tag(
|
211
|
+
:div,
|
212
|
+
@template.content_tag(:span, symbol, :class => "add-on") +
|
213
|
+
text_field_original(name, *args << options),
|
214
|
+
:class => "input-prepend"
|
215
|
+
),
|
216
|
+
:class => "controls"
|
217
|
+
)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def append_field(name, *args)
|
222
|
+
|
223
|
+
options = args.extract_options!
|
224
|
+
|
225
|
+
options.reverse_merge! :label => name
|
226
|
+
label = options[:label]
|
227
|
+
options.delete(:label)
|
228
|
+
|
229
|
+
options.reverse_merge! :symbol => "#"
|
230
|
+
symbol = options[:symbol]
|
231
|
+
options.delete(:symbol)
|
232
|
+
|
233
|
+
@template.content_tag :div, :class => "control-group" do
|
234
|
+
@template.content_tag(:label, label, :class => "control-label") +
|
235
|
+
@template.content_tag(
|
236
|
+
:div,
|
237
|
+
@template.content_tag(
|
238
|
+
:div,
|
239
|
+
text_field_original(name, *args << options) +
|
240
|
+
@template.content_tag(:span, symbol, :class => "add-on"),
|
241
|
+
:class => "input-append"
|
242
|
+
),
|
243
|
+
:class => "controls"
|
244
|
+
)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|