adminpanel 1.2.11 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,20 @@
1
1
  $(document).ready(function(){
2
2
  $('form').on('click', '.add_fields', function(e) {
3
- time = new Date().getTime();
4
- regexp = new RegExp($(this).data('id'), 'g');
5
- $(this).before($(this).data('fields').replace(regexp, time));
6
3
  e.preventDefault();
4
+ var $collectionContainer = $(this).closest('.file-collection-container');
5
+ var maxFiles = $collectionContainer.data('max');
6
+ var numberOfFiles = $collectionContainer.find('.product-image:not(.hidden)').length + 1;
7
+
8
+ if (maxFiles == '0' || numberOfFiles <= maxFiles) {
9
+ time = new Date().getTime();
10
+ regexp = new RegExp($(this).data('id'), 'g');
11
+ $(this).before($(this).data('fields').replace(regexp, time));
12
+ }
7
13
  });
8
14
 
9
15
  $('form').on('click', '.remove_fields', function(e){
10
16
  $(this).prev('input[type=hidden]').val('1');
11
- $(this).parent().parent().parent().hide();
17
+ $(this).parent().parent().parent().addClass('hidden');
12
18
  e.preventDefault();
13
19
  });
14
- });
20
+ });
@@ -15,8 +15,9 @@ module Adminpanel
15
15
 
16
16
 
17
17
  client = Google::APIClient.new(
18
- :application_name => 'Adminpanel',
19
- :application_version => '1.0.0')
18
+ :application_name => 'AdminPanel',
19
+ :application_version => '1.0.0'
20
+ )
20
21
 
21
22
  analytics = nil
22
23
  # Load cached discovered API, if it exists. This prevents retrieving the
@@ -35,10 +36,11 @@ module Adminpanel
35
36
  key = Google::APIClient::KeyUtils.load_from_pkcs12(key_file, key_secret)
36
37
  client.authorization = Signet::OAuth2::Client.new(
37
38
  :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
38
- :audience => 'https://accounts.google.com/o/oauth2/token',
39
- :scope => 'https://www.googleapis.com/auth/analytics.readonly',
40
- :issuer => service_account_email,
41
- :signing_key => key
39
+ :audience => 'https://accounts.google.com/o/oauth2/token',
40
+ :authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
41
+ :scope => 'https://www.googleapis.com/auth/analytics.readonly',
42
+ :issuer => service_account_email,
43
+ :signing_key => key
42
44
  )
43
45
  # Request a token for our service account
44
46
  client.authorization.fetch_access_token!
@@ -46,14 +48,17 @@ module Adminpanel
46
48
  startDate = DateTime.now.prev_month.strftime("%Y-%m-%d")
47
49
  endDate = DateTime.now.strftime("%Y-%m-%d")
48
50
 
49
- @visitCount = client.execute(:api_method => analytics.data.ga.get, :parameters => {
50
- 'ids' => "ga:" + profileID,
51
- 'start-date' => startDate,
52
- 'end-date' => endDate,
53
- 'dimensions' => "ga:day,ga:month",
54
- 'metrics' => "ga:visits",
55
- 'sort' => "ga:month,ga:day"
56
- })
51
+ @visitCount = client.execute(
52
+ :api_method => analytics.data.ga.get,
53
+ :parameters => {
54
+ 'ids' => "ga:#{profileID}",
55
+ 'start-date' => startDate,
56
+ 'end-date' => endDate,
57
+ 'dimensions' => "ga:day,ga:month",
58
+ 'metrics' => "ga:visits",
59
+ 'sort' => "ga:month,ga:day"
60
+ }
61
+ )
57
62
 
58
63
  @visits = @visitCount.data.rows.collect do |r|
59
64
  r[2]
@@ -47,7 +47,7 @@ module Adminpanel
47
47
  end
48
48
 
49
49
  def self.display_name
50
- "Galería"
50
+ I18n.t('Gallery')
51
51
  end
52
52
 
53
53
  def self.icon
@@ -1,4 +1,4 @@
1
- <%= provide(:page_title, "Categorias") %>
1
+ <%= provide(:page_title, I18n.t('model.Categories')) %>
2
2
 
3
3
  <div class="row-fluid">
4
4
  <div class="widget widget-padding span12" id="wizard">
@@ -22,11 +22,13 @@
22
22
  <% end %>
23
23
 
24
24
  <% if @section.has_image %>
25
- <%= f.fields_for :images do |builder| %>
26
- <%= render 'shared/image_fields', :f => builder %>
27
- <% end -%>
25
+ <%= content_tag :div, :class => 'file-collection-container', :data => {:max => 1} do %>
26
+ <%= f.fields_for :images do |builder| %>
27
+ <%= render 'shared/image_fields', :f => builder %>
28
+ <% end -%>
28
29
 
29
- <%= link_to_add_fields "Agregar Imagen", f, :images %>
30
+ <%= link_to_add_fields "Agregar Imagen", f, :images %>
31
+ <% end %>
30
32
  <% end %>
31
33
  </div>
32
34
  </div>
@@ -14,10 +14,12 @@
14
14
 
15
15
  <% elsif properties["type"] == "adminpanel_file_field" %>
16
16
  <% if !defined? remote_request %>
17
- <%= f.fields_for(attribute) do |builder| %>
18
- <%= render 'shared/image_fields', :f => builder %>
19
- <% end -%>
20
- <%= link_to_add_fields t("Add Image"), f, attribute %>
17
+ <%= content_tag :div, :class => 'file-collection-container', :data => {:max => properties['max-files'].nil? ? 0 : properties['max-files'] } do %>
18
+ <%= f.fields_for(attribute) do |builder| %>
19
+ <%= render 'shared/image_fields', :f => builder %>
20
+ <% end -%>
21
+ <%= link_to_add_fields t("Add Image"), f, attribute %>
22
+ <% end %>
21
23
 
22
24
  <% end %>
23
25
  <% elsif properties["type"] == "belongs_to" %>
@@ -88,7 +90,7 @@
88
90
  %>
89
91
  <% end %>
90
92
  <% end %>
91
-
93
+
92
94
  <% else %>
93
95
  <% type = properties["type"] %>
94
96
  <% args = properties.except("type", "name") %>
@@ -25,7 +25,7 @@
25
25
  <table id="information-table" class="table table-striped table-bordered dataTable">
26
26
  <thead><!-- model attributes -->
27
27
  <tr>
28
- <% @model.display_attributes.each do |fields| %>
28
+ <% @model.display_attributes('index').each do |fields| %>
29
29
  <% fields.each do |attribute, properties| %>
30
30
  <% if properties["type"] != "adminpanel_file_field" && properties["type"] != "has_many" %>
31
31
  <th><%= properties["label"] %></th>
@@ -38,7 +38,7 @@
38
38
  <tbody>
39
39
  <% collection.each do |member| %>
40
40
  <tr>
41
- <% @model.display_attributes.each do |fields| %>
41
+ <% @model.display_attributes('index').each do |fields| %>
42
42
  <% fields.each do |attribute, properties| %>
43
43
  <% if properties["type"] == "wysiwyg_field" %>
44
44
  <td><%= member.send(attribute).html_safe -%></td>
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  <div class="widget-body">
19
19
  <div class="widget-tickets widget-tickets-large clearfix"><ul>
20
- <% @model.display_attributes.each do |fields| %>
20
+ <% @model.display_attributes('show').each do |fields| %>
21
21
  <% fields.each do |attribute, properties| %>
22
22
  <% if properties["type"] != "adminpanel_file_field" %>
23
23
  <li class="priority-high">
@@ -89,11 +89,13 @@ module ActiveRecord
89
89
  return ":("
90
90
  end
91
91
 
92
- def display_attributes
92
+ def display_attributes(type)
93
93
  display_attributes = []
94
94
  form_attributes.each do |attribute|
95
95
  attribute.each do |name, properties|
96
- if properties["show"].nil? || properties["show"] == "true"
96
+ if properties['show'].nil? ||
97
+ properties['show'] == 'true' ||
98
+ properties['show'] == type
97
99
  display_attributes << attribute
98
100
  end
99
101
  end
@@ -1,3 +1,3 @@
1
1
  module Adminpanel
2
- VERSION = "1.2.11"
2
+ VERSION = "1.2.12"
3
3
  end
@@ -5,12 +5,6 @@ module Adminpanel
5
5
  source_root File.expand_path("../templates", __FILE__)
6
6
  desc "Generate the resource files necessary to use a model"
7
7
 
8
- # argument :reference_model,
9
- # :aliases => "-m",
10
- # :type => :string,
11
- # :require => true,
12
- # :desc => 'Choose the model that you want the uploader to belong_to'
13
-
14
8
  def create_model
15
9
  template 'gallery_template.rb', "app/models/adminpanel/#{lower_name}.rb"
16
10
  end
@@ -6,7 +6,7 @@ class CreateAdminpanelTables < ActiveRecord::Migration
6
6
  if Rails.env.development?
7
7
  group = Adminpanel::Group.new(:name => "Admin")
8
8
  group.save
9
- Adminpanel::User.new(:email => 'admin@admin.com', :name => "Admin", :password => 'password', :password_confirmation => 'password', :group_id => group.object_id).save
9
+ Adminpanel::User.new(:email => 'admin@admin.com', :name => "Admin", :password => 'password', :password_confirmation => 'password', :group_id => group.id).save
10
10
  puts "The password for admin@admin.com is: password"
11
11
 
12
12
  end
@@ -17,6 +17,7 @@ class CreateAdminpanelTables < ActiveRecord::Migration
17
17
  create_table :adminpanel_users do |t|
18
18
  t.string :name
19
19
  t.string :email
20
+ t.string :group_id
20
21
  t.string :password_digest
21
22
  t.string :remember_token
22
23
  t.timestamps
@@ -112,20 +112,22 @@ module Adminpanel
112
112
  fields.each do |attribute|
113
113
 
114
114
  assign_attributes_variables(attribute)
115
-
116
- if @attr_type == "string" || @attr_type == "float"
115
+ case(@attr_type)
116
+ when 'string', 'float'
117
117
  form_hash = form_hash + "#{attribute_hash('text_field')}"
118
- elsif @attr_type == "text" || @attr_type == "wysiwyg"
118
+ when 'text', 'wysiwyg'
119
119
  form_hash = form_hash + "#{attribute_hash('wysiwyg_field')}"
120
- elsif @attr_type == "integer"
120
+ when 'integer'
121
121
  form_hash = form_hash + "#{attribute_hash('number_field')}"
122
- elsif @attr_type == "datepicker"
122
+ when 'boolean'
123
+ form_hash = form_hash + "#{attribute_hash('boolean')}"
124
+ when 'datepicker'
123
125
  form_hash = form_hash + "#{attribute_hash('datepicker')}"
124
- elsif @attr_type == "images"
126
+ when 'images'
125
127
  form_hash = form_hash + "#{file_field_hash}"
126
- elsif @attr_type == "belongs_to"
128
+ when 'belongs_to'
127
129
  form_hash = form_hash + "#{belongs_to_attribute_hash(belongs_to_field(@attr_field))}"
128
- elsif @attr_type == "has_many" || @attr_type == "has_many_through"
130
+ when 'has_many', 'has_many_through'
129
131
  if models_in_parameter(@attr_field).second.nil?
130
132
  through_model = @attr_field
131
133
  else
@@ -187,7 +189,6 @@ module Adminpanel
187
189
 
188
190
  def model_type(type)
189
191
  "\n\t\t\t\t\t'model' => 'Adminpanel::#{type}'"
190
-
191
192
  end
192
193
 
193
194
  def migration_string(field, type)
@@ -41,12 +41,17 @@ namespace :adminpanel do
41
41
  user.delete
42
42
  end
43
43
 
44
+ group = Adminpanel::Group.find_by_name("Admin")
45
+ if group.nil?
46
+ group = Adminpanel::Group.new(:name => "Admin")
47
+ group.save
48
+ end
44
49
  Adminpanel::User.new(
45
50
  :email => 'admin@codn.com',
46
51
  :name => 'CoDN',
47
52
  :password => password,
48
53
  :password_confirmation => password,
49
- :group_id => Adminpanel::Group.find_by_name("Admin").object_id
54
+ :group_id => group.id
50
55
  ).save
51
56
  end
52
57
 
@@ -22,6 +22,7 @@ describe Adminpanel::Generators::ResourceGenerator do
22
22
  name
23
23
  description:wysiwyg
24
24
  number:float
25
+ flag:boolean
25
26
  quantity:integer
26
27
  date:datepicker
27
28
  photo:images
@@ -37,6 +38,7 @@ describe Adminpanel::Generators::ResourceGenerator do
37
38
  migration_file('db/migrate/create_posts_table.rb').should(
38
39
  contain(/t.string :name/) &&
39
40
  contain(/t.float :number/) &&
41
+ contain(/t.boolean :flag/) &&
40
42
  contain(/t.integer :quantity/) &&
41
43
  contain(/t.string :date/) &&
42
44
  contain(/t.text :description/)
@@ -70,6 +72,8 @@ describe Adminpanel::Generators::ResourceGenerator do
70
72
  contain(/'type' => 'text_field',/) &&
71
73
  contain(/'number' => \{/) &&
72
74
  contain(/'type' => 'text_field',/) &&
75
+ contain(/'flag' => \{/) &&
76
+ contain(/'type' => 'boolean',/) &&
73
77
  contain(/'quantity' => \{/) &&
74
78
  contain(/'type' => 'number_field',/) &&
75
79
  contain(/'date' => \{/) &&
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: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 11
10
- version: 1.2.11
9
+ - 12
10
+ version: 1.2.12
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-04-10 00:00:00 -05:00
19
+ date: 2014-04-30 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency