fullstack-admin 0.1.17 → 0.1.18

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 CHANGED
@@ -1 +1 @@
1
- 0.1.17
1
+ 0.1.18
@@ -33,3 +33,7 @@
33
33
  .tab-content {
34
34
  overflow: visible;
35
35
  }
36
+
37
+ .tabs-left .nav-list.nav-tabs {
38
+ padding-right: 0;
39
+ }
@@ -5,10 +5,6 @@ module AdminFormHelper
5
5
  @target = decorated
6
6
  end
7
7
 
8
- def errors(*args)
9
- @target.template.form_errors(@target, *args)
10
- end
11
-
12
8
  def method_missing(method, *args, &block)
13
9
  @target.send(method, *args, &block)
14
10
  end
@@ -22,42 +18,32 @@ module AdminFormHelper
22
18
  end
23
19
 
24
20
  def form_errors(options = {:exclude => [:slug]})
25
- f = this
21
+ f = @target
26
22
  unless f.object.errors.empty?
27
- content_tag :div, :class => "alert alert-block" do
28
- link_to "×", :class => "close", :data => {:dismiss => "alert"}
29
- content_tag(:h4, t('fullstack.admin.form.correct_these_errors_and_retry', :default => "Correct these errors and retry"), :class => "alert-heading")
23
+ @target.template.content_tag :div, :class => "alert alert-block" do
24
+ @target.template.link_to "×", :class => "close", :data => {:dismiss => "alert"}
25
+ @target.template.content_tag(:h4, I18n.t('fullstack.admin.form.correct_these_errors_and_retry', :default => "Correct these errors and retry"), :class => "alert-heading")
30
26
  f.semantic_errors *(f.object.errors.keys - (options[:exclude] || []))
31
27
  end
32
28
  end
33
29
  end
30
+ alias :errors :form_errors
34
31
 
35
32
  def action(method, options = {})
36
33
  default_label = I18n.t("fullstack.admin_form.labels.#{method}", :default => "#{method}".humanize)
37
34
  options[:type] ||= !!options[:primary] ? :primary : nil
38
35
  @target.template.button((options.delete(:label) || default_label), options)
39
36
  end
40
-
41
- end
42
-
43
- def after_current_form(key = :default, options = {:replace => false})
44
- reset_after_current_form_hash! if @after_current_form.nil?
45
- if options[:replace]
46
- @after_current_form[key] = ""
47
- end
48
37
 
49
- @after_current_form[key]
50
38
  end
51
-
52
- def reset_after_current_form_hash!
53
- @after_current_form = ActiveSupport::OrderedHash.new
54
- @after_current_form[:default] = ""
55
- end
56
-
39
+
57
40
  def admin_form_for(record_or_name_or_array, *args)
58
- semantic_form_for(record_or_name_or_array, *args) do |f|
59
- yield(FormBuilderDecorator.new(f)) << @after_current_form.map { |k, v| v }.join().html_safe
60
- end
41
+ options = args.extract_options!
42
+ options[:builder] ||= FormtasticBootstrap::FormBuilder
43
+
44
+ semantic_form_for(record_or_name_or_array, *(args << options)) do |f|
45
+ yield(FormBuilderDecorator.new(f))
46
+ end
61
47
  end
62
48
 
63
49
  end
@@ -0,0 +1,21 @@
1
+ module ResourcesHelper
2
+
3
+ def singular_name
4
+ controller_name.singularize
5
+ end
6
+ alias :resource_name :singular_name
7
+
8
+ def plural_name
9
+ controller_name
10
+ end
11
+ alias :collection_name :plural_name
12
+
13
+ def current_resource
14
+ instance_variable_get("@#{resource_name}")
15
+ end
16
+
17
+ def current_collection
18
+ instance_variable_get("@#{collection_name}")
19
+ end
20
+
21
+ end
@@ -1,7 +1,7 @@
1
1
  <% if content_for? :title -%>
2
2
  <div class="page-header"><h1><%= yield :title %></h1></div>
3
3
  <% else -%>
4
- <div class="page-header"><h1><%= t('fullstack.admin.edit', :default => "Edit") %> `<%= title_for(resource) %>`</h1></div>
4
+ <div class="page-header"><h1><%= t('fullstack.admin.edit', :default => "Edit") %> `<%= title_for(current_resource) %>`</h1></div>
5
5
  <% end -%>
6
6
 
7
7
  <%= render :partial => 'form' %>
@@ -1,26 +1,28 @@
1
1
  <% if content_for? :title -%>
2
2
  <div class="page-header"><h1><%= yield :title %></h1></div>
3
3
  <% else -%>
4
- <div class="page-header"><h1><%= t(plural_name, :scope => "active_record.plurals") %></h1></div>
4
+ <div class="page-header"><h1><%= t(plural_name, :scope => "activerecord.models") %></h1></div>
5
5
  <% end -%>
6
6
 
7
7
  <% if partial?('collection') %>
8
- <%= render :partial => "collection", :locals => {:collection => instance_variable_get("@#{controller_name}"), :"#{controller_name}" => instance_variable_get("@#{controller_name}")} %>
8
+ <%= render :partial => "collection",
9
+ :locals => {
10
+ :collection => instance_variable_get("@#{controller_name}"),
11
+ :"#{controller_name}" => instance_variable_get("@#{controller_name}")
12
+ }
13
+ %>
9
14
  <% else %>
10
15
 
11
-
12
-
13
16
  <div class="mb1">
14
17
  <% if subject.can_create?(controller_name) && controller.action_methods.include?("new") %>
15
- <%= link_to send("new_admin_#{controller_name.singularize}_path"), :class => "btn btn-primary" do %>
16
- <i class="icon icon-plus icon-white"></i> <%= _("New") %>
17
- <% end -%>
18
+ <%= button t('fullstack.admin.new', :default => "New"),
19
+ send("new_admin_#{controller_name.singularize}_path"),
20
+ :type => :primary, :icon => :plus, :icon_color => :white %>
18
21
  <% end %>
19
-
20
- <%= link_to 'javascript:void(0)', :class => "btn toggle-delete" do %>
21
- <i class="icon icon-trash"></i> <%= _("Delete") %>
22
- <% end -%>
23
22
 
23
+ <%= button t('fullstack.admin.delete', :default => "Delete"),
24
+ 'javascript:void(0)', :class => "toggle-delete",
25
+ :icon => :trash %>
24
26
  </div>
25
27
 
26
28
 
@@ -31,14 +33,13 @@
31
33
  </tr>
32
34
  </thead>
33
35
  <tbody>
34
- <% instance_variable_get("@#{controller_name}").each do |item| -%>
36
+ <% current_collection.each do |item| -%>
35
37
  <tr>
36
- <%= render :partial => 'index', :locals => {:thead => false, :tbody => true, :content => item} %>
38
+ <%= render :partial => 'index', :locals => {:thead => false, :tbody => true, :content => item} %>
37
39
  </tr>
38
40
  <% end -%>
39
41
  </tbody>
40
- <%= paginate instance_variable_get("@#{controller_name}"), :window => 4, :outer_window => 3 %>
41
-
42
+ <%= paginate current_collection, :window => 4, :outer_window => 3 %>
42
43
  </table>
43
44
 
44
45
  <% end %>
@@ -48,12 +49,12 @@
48
49
  <% if partial?('filter') %>
49
50
  <div class="well">
50
51
  <div class="mb1">
51
- <h4>Filtra</h4>
52
+ <h4><%= t('fullstack.admin.filter', :default => "Filter") %></h4>
52
53
  </div>
53
54
  <%= admin_form_for @search, :url => self.send("admin_#{collection_name}_path") , :html => {:method => :get} do |f| %>
54
55
  <%= render :partial => "filter", :locals => {:f => f} %>
55
56
  <%= f.buttons do %>
56
- <%= f.commit_button _("Filter") %>
57
+ <%= f.commit_button t('fullstack.admin.filter', :default => "Filter") %>
57
58
  <% end %>
58
59
  <% end %>
59
60
  </div>
@@ -1,7 +1,7 @@
1
1
  <% if content_for? :title -%>
2
2
  <div class="page-header"><h1><%= yield :title %></h1></div>
3
3
  <% else -%>
4
- <div class="page-header"><h1><%= _("New") %> <%= t(singular_name, :scope => "active_record.models") %></h1></div>
4
+ <div class="page-header"><h1><%= t('fullstack.admin.new', :default => "New") %> <%= t(singular_name, :scope => "activerecord.models") %></h1></div>
5
5
  <% end -%>
6
6
 
7
7
  <%= render :partial => 'form' %>
@@ -11,14 +11,14 @@
11
11
  <body>
12
12
  <%= render :partial => 'admin/shared/nav' %>
13
13
 
14
- <%= navbar :fixed => :top do %>
14
+ <%= navbar :fluid => true, :fixed => :top do %>
15
15
  <%= brand "#{app_name} Admin", admin_root_path %>
16
16
  <%= yield :menu %>
17
17
  <% end %>
18
18
 
19
19
  <%= yield :crumbs %>
20
20
 
21
- <%= container :fluid, :class => "main" do %>
21
+ <%= container :fluid => true, :class => "main" do %>
22
22
  <%= row do %>
23
23
 
24
24
  <%= span(2, :id => "left-aside") do %>
@@ -31,7 +31,7 @@
31
31
 
32
32
  <% if content_for?(:aside) %>
33
33
  <%= span(4, :id => "left-aside") do %>
34
- <%= yield :nav %>
34
+ <%= yield :aside %>
35
35
  <% end %>
36
36
  <% end %>
37
37
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fullstack-admin"
8
- s.version = "0.1.17"
8
+ s.version = "0.1.18"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcasimir"]
@@ -949,6 +949,7 @@ Gem::Specification.new do |s|
949
949
  "app/controllers/admin/base_controller.rb",
950
950
  "app/controllers/admin/responder.rb",
951
951
  "app/helpers/admin_form_helper.rb",
952
+ "app/helpers/resources_helper.rb",
952
953
  "app/helpers/scaffold_helper.rb",
953
954
  "app/inputs/boolean_input.rb",
954
955
  "app/inputs/checkbox_input.rb",
@@ -997,6 +998,10 @@ Gem::Specification.new do |s|
997
998
  "lib/generators/fullstack/admin/templates/root/app/views/admin/shared/_nav.html.erb",
998
999
  "lib/generators/fullstack/admin/templates/root/db/migrate/%migration_timestamp%_create_ckeditor_assets.rb",
999
1000
  "lib/generators/fullstack/admin/templates/root/lib/support/user_subject.rb",
1001
+ "lib/generators/fullstack/admin/templates/scaffold/controller.rb",
1002
+ "lib/generators/fullstack/admin/templates/scaffold/views/_filter.html.erb.tt",
1003
+ "lib/generators/fullstack/admin/templates/scaffold/views/_form.html.erb.tt",
1004
+ "lib/generators/fullstack/admin/templates/scaffold/views/_index.html.erb.tt",
1000
1005
  "locales/en.yml",
1001
1006
  "locales/it.yml",
1002
1007
  "vendor/assets/javascripts/ajax-chosen.js",
@@ -1,5 +1,6 @@
1
1
  require 'rails'
2
2
  require "ckeditor"
3
+ require 'fullstack'
3
4
 
4
5
  module Fullstack
5
6
  module Admin
@@ -14,8 +15,12 @@ module Fullstack
14
15
  require "ckeditor/orm/active_record"
15
16
  end
16
17
 
17
- Ckeditor::ApplicationController.class_eval do
18
- authorize(:scope => :admin)
18
+ if Object.const_defined?("UserSubject")
19
+
20
+ Ckeditor::ApplicationController.class_eval do
21
+ authorize(:scope => :admin)
22
+ end
23
+
19
24
  end
20
25
  end
21
26
 
@@ -30,18 +30,6 @@ eos
30
30
  end
31
31
  end
32
32
 
33
- def append_routes
34
- src = <<-eos
35
-
36
- namespace :admin do
37
- root :to => "dashboard#show"
38
- end
39
-
40
- eos
41
- route(src)
42
-
43
- route("\n devise_for :users\n")
44
- end
45
33
 
46
34
  def users
47
35
  generate "migration:from user"
@@ -68,6 +56,20 @@ eos
68
56
  generate "fullstack:admin:locale en"
69
57
  end
70
58
 
59
+
60
+ def append_routes
61
+ src = <<-eos
62
+
63
+ namespace :admin do
64
+ root :to => "dashboard#show"
65
+ end
66
+
67
+ eos
68
+ route(src)
69
+
70
+ route("\n devise_for :users\n")
71
+ end
72
+
71
73
  protected
72
74
 
73
75
  def migration_timestamp
@@ -48,7 +48,7 @@ module Fullstack
48
48
  placeholder_text = "FULLSTACK_PLACEHOLDER"
49
49
  gsub_file(Rails.root.join('app', 'views', scope, "shared", "_nav.html.erb"), /\<\!-- #{placeholder_text} --\>\n/) do
50
50
  <<-str
51
- <%= nav_item _("#{controller_class_name}"), #{scope}_#{plural_name}_path %>
51
+ <%= nav_item t('active_record.models.#{plural_name}', :default => "#{controller_class_name}"), #{scope}_#{plural_name}_path %>
52
52
  <!-- #{placeholder_text} -->
53
53
 
54
54
  str
@@ -57,6 +57,10 @@ str
57
57
 
58
58
  protected
59
59
 
60
+ def class_name
61
+ name.singularize.camelize
62
+ end
63
+
60
64
  def scope
61
65
  @scope ||= "admin"
62
66
  end
@@ -14,9 +14,9 @@
14
14
  <% end -%>
15
15
 
16
16
  <% content_for :nav do -%>
17
-
18
- <div class="well">
19
- <%= nav_list do %>
17
+
18
+ <div class="tabbable tabs-left float right">
19
+ <%= nav_list :class => "nav-tabs" do %>
20
20
  <!-- FULLSTACK_PLACEHOLDER -->
21
21
 
22
22
  <!-- Please do not delete the comment above.
@@ -26,5 +26,4 @@
26
26
  <% end %>
27
27
  </div>
28
28
 
29
-
30
29
  <% end -%>
@@ -0,0 +1,43 @@
1
+ class <%= scope_class %>::<%= controller_class_name %>Controller < <%= scope_class %>::BaseController
2
+ respond_to :html, :js
3
+
4
+ def index
5
+ @search = <%= resource_class_name %>.search(params[:search])
6
+ @<%= collection_name %> = @search.page(params[:page] || 1)
7
+ end
8
+
9
+ def new
10
+ <%- if content? -%>
11
+ @<%= resource_name %> = <%= resource_class_name %>.new(:author_id => current_user._id)
12
+ <%- else -%>
13
+ @<%= resource_name %> = <%= resource_class_name %>.new
14
+ <%- end -%>
15
+ end
16
+
17
+ def edit
18
+ end
19
+
20
+ def create
21
+ @<%= resource_name %> = <%= resource_class_name %>.new(params[:<%= resource_name %>])
22
+
23
+ if @<%= resource_name %>.respond_to?(:author)
24
+ @<%= resource_name %>.author ||= current_user
25
+ end
26
+
27
+ @<%= resource_name %>.save
28
+ respond_with(@<%= resource_name %>)
29
+ end
30
+
31
+ def update
32
+ @<%= resource_name %>.attributes = params[:<%= resource_name %>]
33
+ @<%= resource_name %>.save
34
+ respond_with(@<%= resource_name %>)
35
+ end
36
+
37
+ def destroy
38
+ @<%= resource_name %>.destroy
39
+ respond_with(@<%= resource_name %>)
40
+ end
41
+ end
42
+
43
+
@@ -0,0 +1,14 @@
1
+ <!-- https://github.com/ernie/meta_search -->
2
+ <!--
3
+ f.input :title_contains
4
+ f.input :created_at, :as => :daterange
5
+ -->
6
+
7
+ <% if title_column %>
8
+ <%%= f.input :<%= title_column %>_contains %>
9
+ <% end %>
10
+
11
+ <% if has_timestamps? %>
12
+ <%%= f.input :created_at, :as => :daterange %>
13
+ <% end %>
14
+
@@ -0,0 +1,16 @@
1
+ <%%= admin_form_for [:"<%= scope %>", current_resource], :html => {:multipart => true} do |f| -%>
2
+
3
+ <%%= f.errors %>
4
+
5
+ <%%= f.inputs do %>
6
+
7
+ <%% end -%>
8
+
9
+ <%%= form_actions do %>
10
+ <%%= button (current_resource.persisted? ? t('fullstack.admin.update', :default => "Update") : t('fullstack.admin.create', :default => "Create")),
11
+ :type => :primary,
12
+ :size => :large %>
13
+ <%% end %>
14
+
15
+
16
+ <%% end -%>
@@ -0,0 +1,18 @@
1
+ <%% if thead -%>
2
+ <th><%%= sort_link title_method_for(current_collection.klass) %></th>
3
+ <% if has_timestamps? %>
4
+ <th><%%= sort_link :created_at %></th>
5
+ <% end %>
6
+
7
+ <th><%%= t('fullstack.admin.actions', :default => "Actions") %></th>
8
+ <%% end -%>
9
+
10
+ <%% if tbody -%>
11
+ <td><%%= link_to title_for(content), [:edit, :<%= scope %>, content] %></td>
12
+
13
+ <% if has_timestamps? %>
14
+ <td><%%= l content.created_at.to_date, :format => :long %></td>
15
+ <% end %>
16
+
17
+ <td><%%= default_collection_actions_for(content) %></td>
18
+ <%% end -%>
data/locales/en.yml CHANGED
@@ -1,9 +1,17 @@
1
1
  en:
2
2
  fullstack:
3
3
  admin:
4
+ homepage: "Homepage"
5
+ account: "Account"
6
+ dashboard: "Dashboard"
7
+ logout: "Logout"
8
+ new: "New"
4
9
  show: "Show"
5
10
  edit: "Edit"
6
11
  delete: "Delete"
12
+ create: "Create"
13
+ filter: "Filter"
14
+ actions: "Actions"
7
15
  are_you_sure: "Are you sure?"
8
16
 
9
17
  form:
data/locales/it.yml CHANGED
@@ -1,10 +1,20 @@
1
1
  it:
2
2
  fullstack:
3
3
  admin:
4
+ homepage: "Homepage"
5
+ account: "Account"
6
+ dashboard: "Dashboard"
7
+ logout: "Logout"
8
+ new: "Crea"
4
9
  show: "Visualizza"
5
10
  edit: "Modifica"
6
11
  delete: "Elimina"
12
+ filter: "Filtra"
13
+ create: "Crea"
14
+ actions: "Azioni"
15
+
7
16
  are_you_sure: "Sei sicuro?"
17
+
8
18
  form:
9
19
  correct_these_errors_and_retry: "Correggi questi errori e riprova"
10
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fullstack-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -1175,6 +1175,7 @@ files:
1175
1175
  - app/controllers/admin/base_controller.rb
1176
1176
  - app/controllers/admin/responder.rb
1177
1177
  - app/helpers/admin_form_helper.rb
1178
+ - app/helpers/resources_helper.rb
1178
1179
  - app/helpers/scaffold_helper.rb
1179
1180
  - app/inputs/boolean_input.rb
1180
1181
  - app/inputs/checkbox_input.rb
@@ -1223,6 +1224,10 @@ files:
1223
1224
  - lib/generators/fullstack/admin/templates/root/app/views/admin/shared/_nav.html.erb
1224
1225
  - lib/generators/fullstack/admin/templates/root/db/migrate/%migration_timestamp%_create_ckeditor_assets.rb
1225
1226
  - lib/generators/fullstack/admin/templates/root/lib/support/user_subject.rb
1227
+ - lib/generators/fullstack/admin/templates/scaffold/controller.rb
1228
+ - lib/generators/fullstack/admin/templates/scaffold/views/_filter.html.erb.tt
1229
+ - lib/generators/fullstack/admin/templates/scaffold/views/_form.html.erb.tt
1230
+ - lib/generators/fullstack/admin/templates/scaffold/views/_index.html.erb.tt
1226
1231
  - locales/en.yml
1227
1232
  - locales/it.yml
1228
1233
  - vendor/assets/javascripts/ajax-chosen.js
@@ -1261,7 +1266,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1261
1266
  version: '0'
1262
1267
  segments:
1263
1268
  - 0
1264
- hash: 2814705488529212827
1269
+ hash: 2117914633197908610
1265
1270
  required_rubygems_version: !ruby/object:Gem::Requirement
1266
1271
  none: false
1267
1272
  requirements: