bhf 0.6.22 → 0.6.23

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: d655617e2044bd17eed546420dbb327be3a5249c
4
- data.tar.gz: a469136f9ff5e25146665d49ba4de00ce72fa09e
3
+ metadata.gz: 40eb9f60546480d4d8244eb96df55ba465ff7ff8
4
+ data.tar.gz: eb2483a8c3a52c516e7920e07f32fd11d59c14a8
5
5
  SHA512:
6
- metadata.gz: bad7751589cf51c48fa5ccba35fd4d4b99ec73a345f1436bbf3592bdeafb01f2225020504913459d7c4e7288594de89ca032ebc727ee0c3d4ca89fbfe5ea8af2
7
- data.tar.gz: fec1926b811562320c7bdc0d3c09ed947e9493ccd0bb31e1ab8b8eb6bc6f9f38f36df4ab0a1b31387a28a6bf262bec4dafc2274e9ce0ce5be57ec944e2a3a756
6
+ metadata.gz: c349ee82d84cc308573f6887eee7e57ee43b89a82e0742b33394b1ed780e70cba5ce418e522cfb83a4bb7ed9d67ac6abc7cfcdff139dfc37342eac759dd2a1fb
7
+ data.tar.gz: 58604f9039e028a3c4d1267f21cefe296338968e0ce800da5727e6d70728dab62c7016a0a8de5cefe2741535512751558052aa28eda278b59c98d36837b2ddca
@@ -52,8 +52,6 @@ var initHelper = function(callback){
52
52
  ajaxNote.success();
53
53
  },
54
54
  onSave: function(form){
55
- // TODO: visual flash of the quick_edit content on success
56
- // also after update, create and duplicate
57
55
  ajaxNote.success();
58
56
  },
59
57
  onBeforeSubmit: function(){
@@ -15,9 +15,7 @@ var AjaxEdit = new Class({
15
15
  },
16
16
 
17
17
  startEdit: function(element, wrapElement){
18
- this.clean();
19
18
  this.wrapElement = wrapElement ? wrapElement : element;
20
- this.wrapElement.addClass('live_edit');
21
19
  this.newEntry = this.wrapElement.hasClass('add_field');
22
20
 
23
21
  this.fireEvent('startRequest');
@@ -74,12 +72,7 @@ var AjaxEdit = new Class({
74
72
  this.holder.getElements('.open, .cancel, .save_and_next, .save').set('disabled', 'disabled');
75
73
  },
76
74
 
77
- clean: function(){
78
- document.body.getElements('.live_edit').removeClass('live_edit');
79
- },
80
-
81
75
  close: function(){
82
- this.clean();
83
76
  this.holder.dispose();
84
77
  this.fireEvent('closed')
85
78
  },
@@ -28,6 +28,24 @@ var AjaxEditStack = new Class({
28
28
  }
29
29
  });
30
30
 
31
+ var fadeTm;
32
+ qe.addEvents({
33
+ startRequest: function(){
34
+ this.wrapElement.addClass('live_edit');
35
+ setTimeout(function(){
36
+ this.wrapElement.addClass('live_edit');
37
+ }.bind(this), 10);
38
+ },
39
+ closed: function(){
40
+ this.wrapElement.addClass('animate');
41
+ setTimeout(function(){
42
+ this.wrapElement.removeClass('live_edit');
43
+ }.bind(this));
44
+ setTimeout(function(){
45
+ this.wrapElement.removeClass('animate');
46
+ }.bind(this), 600);
47
+ }
48
+ });
31
49
  qe.startEdit(link, linkParent);
32
50
  },
33
51
  addStack: function(){
@@ -329,32 +329,36 @@ table.data_table
329
329
 
330
330
 
331
331
  tr
332
- &:hover td,
333
- &.live_edit td
334
- +bg-gradient($b1, $b2)
335
- border-bottom-color: $b1
336
- color: $w1
337
- .duplicate
338
- background-position: -348px -50px
339
- &:hover
340
- background-position: -348px -100px
341
- .edit
342
- background-position: 0 -50px
343
- &:hover
344
- background-position: 0 -100px
345
- .delete
346
- background-position: -50px -50px
347
- &:hover
348
- background-position: -50px -100px
349
- .handle
350
- background-position: -98px -50px
351
- &:hover
352
- background-position: -98px -100px
353
- .duplicate,
354
- .edit,
355
- .delete
356
- &.clicked
357
- background: image-url('bhf/small_ajax_loader_h.gif') no-repeat center center
332
+ &.animate td
333
+ +transition-duration(.3)
334
+ +transition-delay(.28)
335
+ &:hover,
336
+ &.live_edit
337
+ td
338
+ +bg-gradient($b1, $b2)
339
+ border-bottom-color: $b1
340
+ color: $w1
341
+ .duplicate
342
+ background-position: -348px -50px
343
+ &:hover
344
+ background-position: -348px -100px
345
+ .edit
346
+ background-position: 0 -50px
347
+ &:hover
348
+ background-position: 0 -100px
349
+ .delete
350
+ background-position: -50px -50px
351
+ &:hover
352
+ background-position: -50px -100px
353
+ .handle
354
+ background-position: -98px -50px
355
+ &:hover
356
+ background-position: -98px -100px
357
+ .duplicate,
358
+ .edit,
359
+ .delete
360
+ &.clicked
361
+ background: image-url('bhf/small_ajax_loader_h.gif') no-repeat center center
358
362
  &.live_edit td
359
363
  +bg-gradient($b2, $b1)
360
364
  border-bottom-color: $b2
@@ -366,11 +370,9 @@ table.data_table
366
370
  thead
367
371
  th.drag
368
372
  width: 24px
369
-
370
373
  tfoot
371
374
  td
372
375
  padding-top: 10px
373
-
374
376
  thead,
375
377
  tbody
376
378
  .primary_key,
@@ -387,6 +389,7 @@ table.data_table
387
389
  tbody
388
390
  .primary_key
389
391
  color: #999
392
+
390
393
  .icon
391
394
  text-indent: -9999px
392
395
  display: inline-block
@@ -541,7 +544,7 @@ form
541
544
  text-decoration: none
542
545
  border: 2px solid $b1
543
546
  background: white
544
- padding: 3px 6px
547
+ padding: 3px 4px
545
548
  border-radius: 4px
546
549
  margin-left: -6px
547
550
  display: inline-block
@@ -553,6 +556,9 @@ form
553
556
  color: white
554
557
  background-color: $b2
555
558
  border-color: $b2
559
+ &.animate
560
+ +transition-duration(.3)
561
+ +transition-delay(.28)
556
562
  .add_field
557
563
  font-size: 20px
558
564
  font-weight: bold
@@ -941,6 +947,8 @@ input[type="submit"].alt_button,
941
947
  float: right
942
948
  .clear
943
949
  clear: both
950
+ .animate
951
+ +transition-duration
944
952
 
945
953
  #ajax_holder
946
954
  text-indent: -9999px
@@ -1108,17 +1116,13 @@ input[type="submit"].alt_button,
1108
1116
  input[type="text"]
1109
1117
  border: 0
1110
1118
  color: black
1111
- > form
1112
1119
  input[type="button"]
1113
1120
  border: 0
1114
1121
  font-size: 0.8em
1115
1122
  font-weight: bold
1116
1123
 
1117
1124
 
1118
- // TODO: bigger radio buttons
1119
-
1120
1125
 
1121
- // TODO: remove me
1122
1126
  .translation_missing
1123
1127
  color: red !important
1124
1128
 
@@ -45,11 +45,23 @@ class Bhf::ApplicationController < ActionController::Base
45
45
  pages = load_yml("/#{r}")['pages']
46
46
  account_roles['pages'] += pages if pages
47
47
  end
48
- # TODO: merge platforms of the same pages rather the replace them
49
- files['pages'].uniq! do |a|
50
- a.keys
48
+
49
+ merged_files = {'pages' => []}
50
+ files['pages'].each do |pages|
51
+ merged = false
52
+ pages.each do |page|
53
+ merged_files['pages'].each do |m_page|
54
+ if m_page.include?(page[0])
55
+ merged = true
56
+ m_page[page[0]] << page[1]
57
+ end
58
+ end
59
+ end
60
+ if !merged
61
+ merged_files['pages'] << pages
62
+ end
51
63
  end
52
- files
64
+ merged_files
53
65
  else
54
66
  load_yml
55
67
  end
@@ -114,7 +114,6 @@ class Bhf::EntriesController < Bhf::ApplicationController
114
114
  @model = @platform.model
115
115
  @model_sym = ActiveModel::Naming.singular(@model).to_sym
116
116
  @permited_params = ActionController::Parameters.new(params[@model_sym]).permit!
117
- #params.require(@model_sym).permit! TODO: check this
118
117
  end
119
118
 
120
119
  def load_object
@@ -129,17 +128,21 @@ class Bhf::EntriesController < Bhf::ApplicationController
129
128
 
130
129
  def manage_many_to_many
131
130
  return unless params[:has_and_belongs_to_many]
132
- params[:has_and_belongs_to_many].each_pair do |relation, ids|
131
+ params[:has_and_belongs_to_many].each_pair do |relation, all_ids|
133
132
  reflection = @model.reflections[relation.to_sym]
134
133
 
135
- @object.send(reflection.name).delete_all # TODO: drop only the diff
136
134
 
137
- ids = ids.values.reject(&:blank?)
138
-
139
- next if ids.blank?
140
-
141
- reflection.klass.unscoped.find(ids).each do |relation_obj|
142
- @object.send(relation) << relation_obj
135
+ if all_ids.any?
136
+ reflection.klass.unscoped.find(all_ids.keys).each do |relation_obj|
137
+ @object.send(relation).delete(relation_obj)
138
+ end
139
+
140
+ ids = all_ids.values.reject(&:blank?)
141
+ if ids.any?
142
+ reflection.klass.unscoped.find(ids).each do |relation_obj|
143
+ @object.send(relation) << relation_obj
144
+ end
145
+ end
143
146
  end
144
147
  end
145
148
  end
@@ -1,7 +1,7 @@
1
1
  module Bhf
2
2
  module FrontendHelper
3
3
 
4
- def bhf_edit(object, options = {}) # TODO: add a block of html for custom editing buttons and links
4
+ def bhf_edit(object, options = {}, &block)
5
5
  return unless session[Bhf::Engine.config.session_auth_name.to_s] == true
6
6
 
7
7
  options[:platform_name] ||= object.class.to_s.pluralize.downcase
@@ -10,7 +10,7 @@ module Bhf
10
10
  return unless object.bhf_can_edit?(options)
11
11
  end
12
12
 
13
- render partial: 'bhf/helper/frontend_edit', locals: { platform_name: options[:platform_name], object: object }
13
+ render partial: 'bhf/helper/frontend_edit', locals: { platform_name: options[:platform_name], object: object, block: (with_output_buffer(&block) if block_given?)}
14
14
  end
15
15
 
16
16
  end
@@ -1,3 +1,2 @@
1
- - # TODO: this doesnt work
2
- - data_source = current_account.send(field.reflection.name.to_s.pluralize)
3
- = render partial: 'bhf/entries/form/belongs_to/select', locals: {data_source: data_source, field: field, f: f}
1
+ - data_source = current_account.send(field.reflection.name)
2
+ = render partial: 'bhf/entries/form/has_one/static', locals: {ref_object: ref_object, field: field, f: f}
@@ -5,5 +5,5 @@
5
5
  - if ref_object
6
6
  %li= link_to_if field.link, ref_object.to_bhf_s, edit_entry_path(field.link || 0, ref_object), class: :quick_edit
7
7
 
8
- - if field.link
8
+ -# if field.link
9
9
  = link_to '+', new_entry_path(field.link), class: 'add_field quick_edit'
@@ -1 +1,3 @@
1
- = link_to t('bhf.helpers.entry.edit', platform_name: object.to_bhf_s), bhf.edit_entry_path(platform_name, object), class: 'bhf_edit', data: {:'no-turbolink' => true}
1
+ - link_title = t('bhf.helpers.entry.edit', platform_name: object.to_bhf_s)
2
+ = link_to bhf.edit_entry_path(platform_name, object), class: 'bhf_edit', data: {:'no-turbolink' => true}, title: link_title do
3
+ = block ? block : link_title
@@ -37,7 +37,6 @@
37
37
  - if platform.sortable
38
38
  %td.drag
39
39
  %span.handle.icon &nbsp;
40
- -# TODO: external link partial from anpex
41
40
  - platform.columns.each do |column|
42
41
  %td{class: "#{column.field.macro} #{column.field.display_type}", :'data-column-name' => column.name}
43
42
  - a = if column.field.display_type != :boolean && object.send(column.name).blank?
@@ -0,0 +1,2 @@
1
+ = link_to object.send(column.name), title: object.send(column.name), target: '_blank' do
2
+ %strong= t('bhf.helpers.link', link: object.send(column.name)).html_safe
@@ -4,6 +4,7 @@ de:
4
4
  boolean:
5
5
  a: ja
6
6
  b: nein
7
+ link: Link ⬀
7
8
  searchform:
8
9
  placeholder: Suche
9
10
  promts:
@@ -1,12 +1,10 @@
1
1
  en:
2
2
  bhf:
3
- pages:
4
- headline: Content
5
-
6
3
  helpers:
7
4
  boolean:
8
- a: 'yes'
9
- b: 'no'
5
+ a: yes
6
+ b: no
7
+ link: Link ⬀
10
8
  searchform:
11
9
  placeholder: Search
12
10
  promts:
@@ -22,9 +22,9 @@ module Bhf
22
22
  self.to_s.humanize
23
23
  end
24
24
 
25
- module ClassMethods
25
+ module ClassMethods
26
26
  def bhf_default_search(search_params)
27
- return if (search_term = search_params[:text]).blank?
27
+ return self 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
@@ -38,7 +38,7 @@ module Bhf
38
38
  end
39
39
  end
40
40
 
41
- where_statement.join(' OR ')
41
+ where(where_statement.join(' OR '))
42
42
  end
43
43
 
44
44
  def bhf_primary_key
@@ -82,25 +82,33 @@ module Bhf
82
82
  '_id'
83
83
  end
84
84
 
85
- def except(key)
86
- if key == :order || key == :sort
87
- #order_by.extras(sort: []) #TODO: drop default_scope criteria
88
- end
89
- self
85
+ def order(a)
86
+ order_by(a)
90
87
  end
91
88
 
92
- def order(a)
93
- field, direction = a.split(' ')
94
- return self if field.blank? or direction.blank?
95
- self.send(direction.downcase, field)
89
+ def reorder(a)
90
+ order_by(a)
96
91
  end
97
92
 
98
93
  def bhf_default_search(search_params)
99
- return if (search_term = search_params[:text]).blank?
100
-
101
- # TODO: add mongoid search
102
- return where(name: /^antp/i)
103
- #return where("this.nick == 'antpaw'")
94
+ return self if (search_term = search_params[:text]).blank?
95
+
96
+ arr = []
97
+ columns_hash.each_pair do |column, props|
98
+ is_number = search_term.to_i.to_s == search_term || search_term.to_f.to_s == search_term
99
+
100
+ if props.type == :primary_key
101
+ arr << {props.name.to_sym => search_term}
102
+ elsif props.type == :string || props.type == :text
103
+ arr << {props.name.to_sym => /#{search_term}/i}
104
+ elsif props.type == :integer && is_number
105
+ arr << {props.name.to_sym => search_term.to_i}
106
+ elsif props.type == :float && is_number
107
+ arr << {props.name.to_sym => search_term.to_f}
108
+ end
109
+
110
+ end
111
+ self.or(arr)
104
112
  end
105
113
 
106
114
  def get_embedded_parent(parent_id, &block)
@@ -3,13 +3,13 @@ module Kaminari
3
3
  class Tag
4
4
  def initialize(template, options = {}) #:nodoc:
5
5
  @template, @options = template, options.dup
6
- @param_name = @options.delete(:param_name)
6
+ @param_name = @options.delete(:param_name) || Kaminari.config.param_name
7
7
  @theme = @options[:theme] ? "#{@options.delete(:theme)}/" : ''
8
8
  @params = @options[:params] ? template.params.merge(@options.delete :params) : template.params
9
9
  end
10
10
 
11
11
  def to_s(locals = {}) #:nodoc:
12
- @template.render partial: "kaminari/#{@theme}#{self.class.name.demodulize.underscore}", locals: @options.merge(locals)
12
+ @template.render :partial => "kaminari/#{@theme}#{self.class.name.demodulize.underscore}", :locals => @options.merge(locals), :formats => [:html]
13
13
  end
14
14
 
15
15
  def page_url_for(page)
@@ -23,8 +23,8 @@ module Kaminari
23
23
  end
24
24
  end
25
25
  end
26
- # TODO: lets hope they'll fix nested params and we can remove this
27
- # https://github.com/amatsuda/kaminari/issues/152
26
+ # TODO: check for support here
27
+ # https://github.com/amatsuda/kaminari/pull/491
28
28
 
29
29
 
30
30
  module Bhf
data/lib/bhf/platform.rb CHANGED
@@ -51,10 +51,6 @@ module Bhf
51
51
  @user && table_options(:user_scope)
52
52
  end
53
53
 
54
- def search_source
55
- table_options(:search) || :where
56
- end
57
-
58
54
  def prepare_objects(options, paginate_options = nil)
59
55
  if user_scope?
60
56
  chain = @user.send(table_options(:user_scope).to_sym)
@@ -63,7 +59,7 @@ module Bhf
63
59
  chain = chain.send data_source if data_source
64
60
  end
65
61
 
66
- if options[:order]
62
+ unless options[:order].blank?
67
63
  chain = chain.reorder("#{options[:order]} #{options[:direction]}")
68
64
  end
69
65
 
@@ -183,13 +179,11 @@ module Bhf
183
179
  private
184
180
 
185
181
  def do_search(chain, search_params)
186
- search_condition = if table_options(:search)
187
- search_params
182
+ if table_options(:search)
183
+ chain.send table_options(:search), search_params
188
184
  else
189
- model.bhf_default_search(search_params)
185
+ chain.bhf_default_search(search_params)
190
186
  end
191
-
192
- chain.send search_source, search_condition
193
187
  end
194
188
 
195
189
  def data_source
data/lib/bhf/settings.rb CHANGED
@@ -4,10 +4,20 @@ module Bhf
4
4
 
5
5
  def initialize(options)
6
6
  @options = options
7
+
8
+ t = pages.each_with_object([]) do |page, obj|
9
+ content_for_page(page).each do |platform|
10
+ obj << platform.keys.flatten
11
+ end
12
+ end.flatten!
13
+ if t.uniq.length != t.length
14
+ raise Exception.new("Platforms with identical names: '#{t.detect{ |e| t.count(e) > 1 }}'")
15
+ end
7
16
  end
8
17
 
9
18
  def pages
10
- @options['pages'].each_with_object([]) do |page, obj|
19
+ return @pages if @pages
20
+ @pages = @options['pages'].each_with_object([]) do |page, obj|
11
21
  if page.is_a?(String)
12
22
  page = {page => nil}
13
23
  end
@@ -27,7 +37,6 @@ module Bhf
27
37
  end
28
38
 
29
39
  def find_platform(platform_name, current_account = nil)
30
- # TODO: error for platforms whit the same name
31
40
  pages.each do |page|
32
41
  content_for_page(page).each do |platform|
33
42
  bhf_platform = Bhf::Platform.new(platform, page, current_account)
data/lib/bhf.rb CHANGED
@@ -28,6 +28,17 @@ module Bhf
28
28
  end
29
29
  end
30
30
 
31
+ initializer 'bhf.hooks' do
32
+ if defined?(::I18n)
33
+ ::I18n.send :include, Bhf::I18nTranslationFallbackHelper
34
+ end
35
+ if defined?(::ActiveRecord)
36
+ ::ActiveRecord::Base.send :include, Bhf::ActiveRecord::Object
37
+ end
38
+ if defined?(::Mongoid)
39
+ ::Mongoid::Document.send :include, Bhf::Mongoid::Document
40
+ end
41
+ end
31
42
  end
32
43
  end
33
44
 
@@ -41,12 +52,4 @@ require 'bhf/settings'
41
52
  require 'bhf/pagination'
42
53
  require 'bhf/form'
43
54
 
44
- ::I18n.send :include, Bhf::I18nTranslationFallbackHelper
45
-
46
- if defined?(ActiveRecord)
47
- ::ActiveRecord::Base.send :include, Bhf::ActiveRecord::Object
48
- end
49
- if defined?(Mongoid)
50
- ::Mongoid::Document.send :include, Bhf::Mongoid::Document
51
- end
52
55
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bhf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.22
4
+ version: 0.6.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Pawlik
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3.0
33
+ version: 2.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3.0
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: kaminari
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +177,7 @@ files:
177
177
  - app/views/bhf/pages/macro/column/_array.haml
178
178
  - app/views/bhf/pages/macro/column/_boolean.haml
179
179
  - app/views/bhf/pages/macro/column/_date.haml
180
+ - app/views/bhf/pages/macro/column/_extern_link.haml
180
181
  - app/views/bhf/pages/macro/column/_file.haml
181
182
  - app/views/bhf/pages/macro/column/_hash.haml
182
183
  - app/views/bhf/pages/macro/column/_image.haml