bhf 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e11f1b3a941a6246b9913a969711d7e8cb35af0
4
- data.tar.gz: c1ee24fe0023ab269a5aca72136a99f887477da5
3
+ metadata.gz: 56e1533c1a02d076775f99d6a4486f6c53bb656e
4
+ data.tar.gz: d6f2464941ec7dfc1e72105d40245491ea7e53be
5
5
  SHA512:
6
- metadata.gz: 6c4108e0e03a28f8de09660a3140d3bced156331c35090165e5e4bf450b5fa73d7a7e1ae685f5d6898069f2df0ae77c927c990091b651385d18e8f387dc86311
7
- data.tar.gz: e71e10d4b7e53fd92e5324ac6629092b0fc6e0dd2722ff69d31f3f20d88ad81e18bd91e4ae3a8b0f9b51d49aca278ba88aa2fd830cd5bd437474d20562afdf85
6
+ metadata.gz: 5751ca1838daa57380d1dcf7c63673b679194555cb2303522a45c6e513a49b16f31b0ca91ccf0bd691ef61c0e9cadd7de86dcddc76ab827a11be81a630ac92cf
7
+ data.tar.gz: ec360eef6e1ab6524d6f8eabaf6357cbc9c0bc6ed8e13f6c4a7ac72c7a4dbee238a7fa8e0eeb0db416d577863b7cc34e81b4069994bd55b12aad64370fdae666
data/README.md CHANGED
@@ -9,7 +9,6 @@
9
9
  * Fork the project.
10
10
  * Start a feature/bugfix branch.
11
11
  * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
12
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
13
 
15
14
 
data/Rakefile CHANGED
@@ -16,8 +16,8 @@ Jeweler::Tasks.new do |gem|
16
16
  gem.name = 'bhf'
17
17
  gem.homepage = 'http://antpaw.github.io/bhf'
18
18
  gem.licenses = 'MIT'
19
- gem.summary = 'Agnostic Rails backend'
20
- gem.description = 'Gets you there on time'
19
+ gem.summary = 'A simple to use Rails-Engine-Gem that offers an admin interface for trusted user.'
20
+ gem.description = 'A simple to use Rails-Engine-Gem that offers an admin interface for trusted user. Easy integratable and highly configurable and agnostic. Works with ActiveRecord and Mongoid.'
21
21
  gem.email = 'anton.pawlik@gmail.com'
22
22
  gem.authors = ['Anton Pawlik']
23
23
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
@@ -2,6 +2,7 @@
2
2
  //= require ./mootools-core-1.5.0-full-compat.js
3
3
  //= require ./mootools-more-1.5.0.js
4
4
  //= require ./mootools_ujs
5
+ //= require_tree ./locales/
5
6
  //= require_tree ./classes/
6
7
 
7
8
  // Turbolinks bugs out on popState if you add own pushState events, so we cancel it
@@ -9,8 +10,9 @@ Turbolinks.pagesCached(0);
9
10
 
10
11
  (function(){
11
12
  var stackIndexCounter = 0;
12
- var lang = document.html.get('lang');
13
- Locale.use(lang = (lang === 'en') ? 'en-US' : lang = lang+'-'+lang.toUpperCase());
13
+ var lang = document.html.get('lang').split('-')[0];
14
+ lang = (lang === 'en') ? 'en-US' : lang.toLowerCase()+'-'+lang.toUpperCase()
15
+ Locale.use(lang);
14
16
 
15
17
  var ajaxNote = new Ajaxify();
16
18
  document.addEventListener('page:fetch', function(){
@@ -340,6 +342,10 @@ Turbolinks.pagesCached(0);
340
342
  parent.getElement('.h_text').set('text', newText);
341
343
  });
342
344
 
345
+ mainScope.getElements('.js_submit_form_on_change').addEvent('change', function(e){
346
+ e.target.getParent('form').submit();
347
+ });
348
+
343
349
  ajaxNote.success();
344
350
  });
345
351
 
@@ -8,6 +8,6 @@ Locale.define('en-US', 'DatePicker', {
8
8
  });
9
9
 
10
10
 
11
- Locale.define('de-DE', 'Notifications', {
11
+ Locale.define('en-US', 'Notifications', {
12
12
  failure: 'Something went wrong!'
13
13
  });
@@ -0,0 +1,13 @@
1
+ Locale.define('pt-PT', 'DatePicker', {
2
+ select_a_time: 'Selecione um horário',
3
+ use_mouse_wheel: 'Use o scroll do mouse para rapidamente alterar valores',
4
+ time_confirm_button: 'OK',
5
+ apply_range: 'Aplicar',
6
+ cancel: 'Cancelar',
7
+ week: 'Sm'
8
+ });
9
+
10
+
11
+ Locale.define('pt-PT', 'Notifications', {
12
+ failure: 'Algo deu errado!'
13
+ });
@@ -111,7 +111,7 @@ class Bhf::EntriesController < Bhf::ApplicationController
111
111
  column_value = @object.send(column.name)
112
112
  unless column.macro == :column && column_value.blank?
113
113
  p = "bhf/table/#{column.macro}/#{column.display_type}"
114
- hash[column.name] = render_to_string partial: p, locals: {object: @object, column_value: column_value}
114
+ hash[column.name] = render_to_string partial: p, locals: {object: @object, column_value: column_value, link: false, add_quick_link: false}
115
115
  end
116
116
  end
117
117
  end
@@ -6,8 +6,6 @@
6
6
 
7
7
  - @platform.fields.each do |field|
8
8
  - unless field.form_type == :hidden
9
- - if !field.form_type
10
- = d field
11
9
  = render partial: "bhf/form/#{field.macro}/#{field.form_type}", locals: {f: f, field: field}
12
10
 
13
11
  - unless @quick_edit
@@ -42,11 +42,12 @@
42
42
  %span.handle.icon &nbsp;
43
43
  - platform.columns.each do |column|
44
44
  - css_classes = [column.macro, column.display_type]
45
- - column_value = object.send(column.name)
45
+ - respond_to_column = object.respond_to?(column.name)
46
+ - column_value = object.send(column.name) if respond_to_column
46
47
  - if column.display_type == :primary_key && column_value.to_s.length > 6
47
48
  - css_classes << :key_long
48
49
  %td{class: css_classes}
49
- - partial_name = if column.display_type != :boolean && column_value.blank?
50
+ - partial_name = if respond_to_column && column.display_type != :boolean && column_value.blank?
50
51
  - 'column/empty'
51
52
  - else
52
53
  - "#{column.macro}/#{column.display_type}"
@@ -1,6 +1,10 @@
1
1
  = form_for platform.name, html: {method: :get, class: :search} do |f|
2
2
  - p = params[platform.name]
3
3
  = f.fields_for :search do |s|
4
+
5
+ - if platform.scopes
6
+ = f.select :scope, options_from_collection_for_select(platform.scopes, :value, :name, (p && p[:scope])), {}, class: 'js_submit_form_on_change'
7
+
4
8
  - if platform.search_field?
5
9
  = s.text_field :text, value: get_value([:search, :text], p), placeholder: t('bhf.helpers.searchform.placeholder')
6
10
 
@@ -14,3 +18,5 @@
14
18
  = f.hidden_field :per_page, value: get_value(:per_page, p)
15
19
  = f.hidden_field :order, value: get_value(:order, p)
16
20
  = f.hidden_field :direction, value: get_value(:direction, p)
21
+
22
+
@@ -1,2 +1,5 @@
1
1
  = content_tag link ? :a : :span, class: ('quick_edit' if add_quick_link), href: (link if link) do
2
- = column_value[0..5].join(', ')
2
+ - if column_value.is_a?(String)
3
+ = column_value
4
+ - else
5
+ = column_value[0..5].join(', ')
data/bhf.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: bhf 0.9.2 ruby lib
5
+ # stub: bhf 0.9.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "bhf"
9
- s.version = "0.9.2"
9
+ s.version = "0.9.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Anton Pawlik"]
14
- s.date = "2014-07-09"
15
- s.description = "Gets you there on time"
14
+ s.date = "2014-07-11"
15
+ s.description = "A simple to use Rails-Engine-Gem that offers an admin interface for trusted user. Easy integratable and highly configurable and agnostic. Works with ActiveRecord and Mongoid."
16
16
  s.email = "anton.pawlik@gmail.com"
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
@@ -38,8 +38,6 @@ Gem::Specification.new do |s|
38
38
  "app/assets/javascripts/bhf/classes/Ajaxify.js",
39
39
  "app/assets/javascripts/bhf/classes/ArrayFields.js",
40
40
  "app/assets/javascripts/bhf/classes/FormHelper.js",
41
- "app/assets/javascripts/bhf/classes/Locale.de-DE.js",
42
- "app/assets/javascripts/bhf/classes/Locale.en-US.js",
43
41
  "app/assets/javascripts/bhf/classes/MooEditable.js",
44
42
  "app/assets/javascripts/bhf/classes/MultipleFields.js",
45
43
  "app/assets/javascripts/bhf/classes/Picker.js",
@@ -52,6 +50,9 @@ Gem::Specification.new do |s|
52
50
  "app/assets/javascripts/bhf/classes/Setlatlng.js",
53
51
  "app/assets/javascripts/bhf/classes/showdown.js",
54
52
  "app/assets/javascripts/bhf/classes/wmd.js",
53
+ "app/assets/javascripts/bhf/locales/Locale.de-DE.js",
54
+ "app/assets/javascripts/bhf/locales/Locale.en-US.js",
55
+ "app/assets/javascripts/bhf/locales/Locale.pt-PT.js",
55
56
  "app/assets/javascripts/bhf/mootools-core-1.5.0-full-compat.js",
56
57
  "app/assets/javascripts/bhf/mootools-more-1.5.0.js",
57
58
  "app/assets/javascripts/bhf/mootools_ujs.js",
@@ -138,6 +139,7 @@ Gem::Specification.new do |s|
138
139
  "bhf.gemspec",
139
140
  "config/locales/de.yml",
140
141
  "config/locales/en.yml",
142
+ "config/locales/pt.yml",
141
143
  "config/routes.rb",
142
144
  "lib/bhf.rb",
143
145
  "lib/bhf/action_view/form_builder.rb",
@@ -159,7 +161,7 @@ Gem::Specification.new do |s|
159
161
  s.homepage = "http://antpaw.github.io/bhf"
160
162
  s.licenses = ["MIT"]
161
163
  s.rubygems_version = "2.2.2"
162
- s.summary = "Agnostic Rails backend"
164
+ s.summary = "A simple to use Rails-Engine-Gem that offers an admin interface for trusted user."
163
165
 
164
166
  if s.respond_to? :specification_version then
165
167
  s.specification_version = 4
@@ -0,0 +1,97 @@
1
+ pt:
2
+ bhf:
3
+ page_title: "%{title} &ndash; Admin"
4
+ areas:
5
+ page_title: "%{area} &ndash; %{title} &ndash; Admin"
6
+ helpers:
7
+ boolean:
8
+ 'true': 'sim'
9
+ 'false': 'não'
10
+ link: Link ⬀
11
+ form:
12
+ file_field:
13
+ select: Escolher arquivo
14
+ buttons:
15
+ save: 'Salvar %{platform_title}'
16
+ and_edit: e editar
17
+ and_add: e adicionar outro
18
+ searchform:
19
+ placeholder: Buscar
20
+ promts:
21
+ confirm: 'Você quer deletar o registro: %{platform_title}?'
22
+ entry:
23
+ new: "Criar %{platform_title}"
24
+ show: "Exibir %{platform_title}"
25
+ duplicate: "Duplicar %{platform_title}"
26
+ edit: "Editar %{platform_title}"
27
+ delete: "Deletar %{platform_title}"
28
+ empty: Esvaziar
29
+ cancel: Cancelar
30
+ user:
31
+ login:
32
+ success: Login efetuado com sucesso
33
+ error: "Login não pode ser feito"
34
+ as: 'Você está logado como <strong>%{user}</strong>'
35
+ logout:
36
+ link: Sair
37
+ activated:
38
+ success: "%{model} foi ativado com sucesso"
39
+ error: "Erro ao ativar %{model}"
40
+ validation:
41
+ header: '%{error} impediu esse "%{name}" de ser salvo:'
42
+ error: erro
43
+ file:
44
+ delete: Deletar arquivo
45
+ reselect: "Por favor, selecione novamente o arquivo"
46
+ image:
47
+ delete: Deletar imagem
48
+ input:
49
+ date_format:
50
+ timestamp: '%d-%m-%Y %H:%M'
51
+ datetime: '%d-%m-%Y %H:%M'
52
+ date: '%d-%m-%Y'
53
+ time: '%H:%M'
54
+ quick_edit:
55
+ buttons:
56
+ cancel: Cancelar
57
+ open: Abrir
58
+ save: Salvar
59
+ create: Criar
60
+ save_and_next: Salvar e ir para o próximo registro
61
+
62
+ pagination:
63
+ previous_label: « Anterior
64
+ next_label: Próximo »
65
+ truncate: …
66
+ load_more: Exibir mais registros
67
+ load_less: Exibir menos registros
68
+ entries: registros
69
+ info:
70
+ default: "Exibindo <strong>%{offset_start} - %{offset_end}</strong> de <strong>%{count}</strong> %{name} no total"
71
+ other: "Exibindo <strong>todos %{count}</strong> %{name_plural}"
72
+ one: "Exibindo <strong>1</strong> %{name_singular}"
73
+ zero: "Nenhum(a) %{name_zero} encontrado"
74
+
75
+ footer:
76
+ state: 'Página renderizada em ~%{time} segundos'
77
+ copy: 'Feito por <a href="http://twitter.com/antpaw">@antpaw</a>'
78
+ info: 'Mais informações no <a href="http://antpaw.github.io/bhf">GitHub</a>'
79
+
80
+ attributes:
81
+ _id: 'id'
82
+
83
+ activerecord:
84
+ notices:
85
+ messages:
86
+ duplicate:
87
+ success: "%{model} duplicado com sucesso"
88
+ error: "Erro ao duplicar %{model}"
89
+ create:
90
+ success: "%{model} criado com sucesso"
91
+ error: "Erro ao criar %{model}"
92
+ update:
93
+ success: "%{model} atualizado com sucesso"
94
+ error: "Erro ao atualizar %{model}"
95
+ destory:
96
+ success: "%{model} deletado com sucesso"
97
+ error: "Erro ao deletar %{model}"
@@ -24,7 +24,7 @@ module Bhf::ActiveRecord
24
24
 
25
25
  module ClassMethods
26
26
  def bhf_default_search(search_params)
27
- return self if (search_term = search_params['text']).blank?
27
+ return where([]) if (search_term = search_params['text']).blank?
28
28
  where_statement = []
29
29
  columns_hash.each_pair do |name, props|
30
30
  is_number = search_term.to_i.to_s == search_term || search_term.to_f.to_s == search_term
@@ -31,7 +31,11 @@ module Bhf::Platform
31
31
  chain = @user.send(table_value(:user_scope).to_sym)
32
32
  else
33
33
  chain = model
34
- chain = chain.send data_source if data_source
34
+ if options[:scope].present?
35
+ chain = chain.send options[:scope]
36
+ elsif data_source
37
+ chain = chain.send data_source
38
+ end
35
39
  end
36
40
 
37
41
  if options[:order].present? and options[:direction].present?
@@ -42,13 +46,12 @@ module Bhf::Platform
42
46
  chain = do_search(chain, options[:search])
43
47
  end
44
48
 
45
-
46
49
  if paginate_options && !sortable
47
50
  chain = chain.page(paginate_options[:page]).per(paginate_options[:per_page])
48
51
  elsif chain == model
49
52
  chain = chain.all
50
53
  end
51
-
54
+
52
55
  @objects = chain
53
56
  end
54
57
 
@@ -83,7 +86,7 @@ module Bhf::Platform
83
86
  def columns
84
87
  return @columns if @columns
85
88
 
86
- tmp = default_attrs(table_columns, attributes[0..5], true)
89
+ tmp = default_attrs(table_columns, attributes[0..5])
87
90
  if sortable and ! table_columns
88
91
  tmp = remove_excludes(tmp, [sortable_property.to_s])
89
92
  end
@@ -193,9 +196,27 @@ module Bhf::Platform
193
196
  def custom_partial
194
197
  table_value 'partial'
195
198
  end
199
+
200
+ def read_data_source
201
+ table_value(:source) || table_value(:scope)
202
+ end
196
203
 
197
204
  def data_source
198
- table_value(:source) || table_value(:scope)
205
+ temp_scope = read_data_source
206
+ return unless temp_scope
207
+ return temp_scope[0] if temp_scope.is_a?(Array)
208
+ temp_scope
209
+ end
210
+
211
+ def scopes
212
+ temp_scope = read_data_source
213
+ return unless temp_scope.is_a?(Array) and temp_scope.count > 1
214
+ temp_scope.each_with_object([]) do |s, array|
215
+ array << OpenStruct.new(
216
+ name: I18n.t("bhf.platforms.#{@name}.scopes.#{s}", default: s),
217
+ value: s
218
+ )
219
+ end
199
220
  end
200
221
 
201
222
  def show_extra_fields
@@ -229,10 +250,9 @@ module Bhf::Platform
229
250
  end
230
251
  end
231
252
 
232
- def default_attrs(attrs, d_attrs, warning = false)
253
+ def default_attrs(attrs, d_attrs)
233
254
  return d_attrs unless attrs
234
255
 
235
- model_respond_to?(attrs) if warning
236
256
  attrs.each_with_object([]) do |name, obj|
237
257
  obj << (
238
258
  attributes.select{ |field| name == field.name }[0] ||
@@ -292,17 +312,6 @@ module Bhf::Platform
292
312
  id + headlines + output.sort_by(&:name) + static_dates
293
313
  end
294
314
 
295
- def model_respond_to?(attrs)
296
- new_obj = model.new
297
- attrs.each do |attribute|
298
- unless new_obj.respond_to?(attribute)
299
- raise Exception.new("Model '#{model}' does not respond to '#{attribute}'")
300
- return false
301
- end
302
- end
303
- true
304
- end
305
-
306
315
  def default_attribute_options(name)
307
316
  {
308
317
  title: model.human_attribute_name(name),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bhf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Pawlik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-09 00:00:00.000000000 Z
11
+ date: 2014-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -150,7 +150,9 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.8'
153
- description: Gets you there on time
153
+ description: A simple to use Rails-Engine-Gem that offers an admin interface for trusted
154
+ user. Easy integratable and highly configurable and agnostic. Works with ActiveRecord
155
+ and Mongoid.
154
156
  email: anton.pawlik@gmail.com
155
157
  executables: []
156
158
  extensions: []
@@ -177,8 +179,6 @@ files:
177
179
  - app/assets/javascripts/bhf/classes/Ajaxify.js
178
180
  - app/assets/javascripts/bhf/classes/ArrayFields.js
179
181
  - app/assets/javascripts/bhf/classes/FormHelper.js
180
- - app/assets/javascripts/bhf/classes/Locale.de-DE.js
181
- - app/assets/javascripts/bhf/classes/Locale.en-US.js
182
182
  - app/assets/javascripts/bhf/classes/MooEditable.js
183
183
  - app/assets/javascripts/bhf/classes/MultipleFields.js
184
184
  - app/assets/javascripts/bhf/classes/Picker.js
@@ -191,6 +191,9 @@ files:
191
191
  - app/assets/javascripts/bhf/classes/Setlatlng.js
192
192
  - app/assets/javascripts/bhf/classes/showdown.js
193
193
  - app/assets/javascripts/bhf/classes/wmd.js
194
+ - app/assets/javascripts/bhf/locales/Locale.de-DE.js
195
+ - app/assets/javascripts/bhf/locales/Locale.en-US.js
196
+ - app/assets/javascripts/bhf/locales/Locale.pt-PT.js
194
197
  - app/assets/javascripts/bhf/mootools-core-1.5.0-full-compat.js
195
198
  - app/assets/javascripts/bhf/mootools-more-1.5.0.js
196
199
  - app/assets/javascripts/bhf/mootools_ujs.js
@@ -277,6 +280,7 @@ files:
277
280
  - bhf.gemspec
278
281
  - config/locales/de.yml
279
282
  - config/locales/en.yml
283
+ - config/locales/pt.yml
280
284
  - config/routes.rb
281
285
  - lib/bhf.rb
282
286
  - lib/bhf/action_view/form_builder.rb
@@ -317,5 +321,6 @@ rubyforge_project:
317
321
  rubygems_version: 2.2.2
318
322
  signing_key:
319
323
  specification_version: 4
320
- summary: Agnostic Rails backend
324
+ summary: A simple to use Rails-Engine-Gem that offers an admin interface for trusted
325
+ user.
321
326
  test_files: []