bhf 0.6.32 → 0.7.0.rc1

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: de6ccdbe72fbdb750d12441dcde4893527e33f15
4
- data.tar.gz: e64a43e7e8207f963f85e11162f13ff584e27baf
3
+ metadata.gz: b97aa128d23d24b3449238bafc617ef50000da7e
4
+ data.tar.gz: c1903326a2ea3aee1df39635e2dad64aa98aec54
5
5
  SHA512:
6
- metadata.gz: 57f4cd5e2d3ed0efc7dc76fe3a1f955eea8d3fe70730871bfda5c635211aa1522db2463f404ba936b0d80b0c6f44664e92ff253b1a6c9dee6a1320029ab9da3a
7
- data.tar.gz: 7c0467a9a0e5f6c162c78322aea42922f89f4086ea4da988765f64cc5222b2a9bc4e7b83cfeefd8d094f83eadd6e071915eb4555e5d21c54de44899d6f7dd551
6
+ metadata.gz: a83ad3de716aeb36ee8bb8d1ad47bd585f168aec23b8726e459d27721522134733562b1212612a4c26c0c6e3dabe51e237b1539966643cbf8a03704701989739
7
+ data.tar.gz: eca937ce81d08337c924e422430e89b8631c0ba045580eeb09676f1882a0179a8901e2fdab0526233db0d950719fbfb494090efe3b649a6895f5d921d016bd88
@@ -27,6 +27,13 @@ var initHelper = function(callback){
27
27
  var editStack = new AjaxEditStack();
28
28
 
29
29
  initHelper(function(mainScope){
30
+ var areaSelect = mainScope.getElement('#area_select');
31
+ if (areaSelect) {
32
+ areaSelect.addEvent('change', function(){
33
+ location.href = this.value;
34
+ });
35
+ }
36
+
30
37
  var quickEditArray = [];
31
38
  var ajaxEditOptions;
32
39
 
@@ -88,14 +88,6 @@ header
88
88
  +bg-gradient($b2, $b1)
89
89
  +text-shadow(#0068B3, -1)
90
90
 
91
- .preview_image
92
- @extend .default_input
93
- vertical-align: middle
94
- padding: 2px
95
- width: auto
96
- max-width: 400px
97
- max-height: 200px
98
-
99
91
  .content_box
100
92
  margin: 10px 20px 20px 20px
101
93
  .dl
@@ -410,6 +402,7 @@ table.data_table
410
402
  background-position: -98px 0
411
403
  cursor: move
412
404
 
405
+
413
406
  .default_input
414
407
  border: 1px solid transparent
415
408
  background: #FFF
@@ -427,6 +420,14 @@ table.data_table
427
420
  -moz-box-shadow: 0 1px 12px $b2
428
421
  border-color: $b2
429
422
 
423
+ .preview_image
424
+ @extend .default_input
425
+ vertical-align: middle
426
+ padding: 2px
427
+ width: auto
428
+ max-width: 400px
429
+ max-height: 200px
430
+
430
431
  .search
431
432
  input[type="text"]
432
433
  @extend .default_input
@@ -1,6 +1,6 @@
1
1
  class Bhf::ApplicationController < ActionController::Base
2
2
 
3
- before_filter :init_time, :check_admin_account, :setup_current_account, :load_config, :set_title
3
+ before_filter :init_time, :check_admin_account, :setup_current_account, :load_config, :set_title, :set_areas
4
4
 
5
5
  helper_method :current_account
6
6
  layout 'bhf/application'
@@ -33,46 +33,16 @@ class Bhf::ApplicationController < ActionController::Base
33
33
  @current_account
34
34
  end
35
35
 
36
- def load_config
37
- @config = Bhf::Settings.new(roles_yml(get_account_roles))
38
- end
39
-
40
- def roles_yml(roles = nil)
41
- if roles.is_a?(String)
42
- load_yml("/#{roles}")
43
- elsif roles.is_a?(Array)
44
- files = roles.each_with_object({'pages' => []}) do |r, account_roles|
45
- pages = load_yml("/#{r}")['pages']
46
- account_roles['pages'] += pages if pages
47
- end
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
36
+ def get_account_roles(area = nil)
37
+ return unless current_account
38
+
39
+ if area
40
+ if current_account.respond_to?(:area_role)
41
+ return current_account.area_role(area)
42
+ elsif current_account.respond_to?(:area_roles)
43
+ return current_account.area_roles(area).collect(&:to_bhf_s)
63
44
  end
64
- merged_files
65
- else
66
- load_yml
67
45
  end
68
- end
69
-
70
- def load_yml(suffix = nil)
71
- YAML::load(IO.read("config/bhf#{suffix}.yml"))
72
- end
73
-
74
- def get_account_roles
75
- return unless current_account
76
46
 
77
47
  if current_account.respond_to?(:role)
78
48
  current_account.role.is_a?(String) ? current_account.role : current_account.role.to_bhf_s
@@ -81,11 +51,27 @@ class Bhf::ApplicationController < ActionController::Base
81
51
  end
82
52
  end
83
53
 
54
+ def load_config
55
+ @config = Bhf::ConfigParser::parse(get_account_roles(params[:bhf_area]), params[:bhf_area])
56
+ end
84
57
 
85
58
  def set_title
86
59
  @app_title = Rails.application.class.to_s.split('::').first
87
60
  @title = Bhf::Engine.config.page_title || ("#{@app_title} &ndash; Admin").html_safe
88
61
  end
62
+
63
+ def set_areas
64
+ @areas = []
65
+ if current_account and current_account.respond_to?(:bhf_areas)
66
+ current_account.bhf_areas.each do |area|
67
+ @areas << OpenStruct.new(
68
+ name: t("bhf.areas.links.#{area.to_bhf_s}", default: area.to_bhf_s),
69
+ selected: params[:bhf_area] == area.to_bhf_s,
70
+ path: main_app.bhf_path(area.to_bhf_s)
71
+ )
72
+ end
73
+ end
74
+ end
89
75
 
90
76
  def set_message(type, model = nil)
91
77
  key = model && ActiveModel::Naming.singular(model)
@@ -9,8 +9,14 @@ module Bhf
9
9
  if object.respond_to?(:'bhf_can_edit?', true)
10
10
  return unless object.bhf_can_edit?(options)
11
11
  end
12
+
13
+ area = if object.respond_to?(:bhf_area, true)
14
+ object.bhf_area(options)
15
+ else
16
+ nil
17
+ end
12
18
 
13
- render partial: 'bhf/helper/frontend_edit', locals: { platform_name: options[:platform_name], object: object, block: (with_output_buffer(&block) if block_given?)}
19
+ render partial: 'bhf/helper/frontend_edit', locals: { area: area, platform_name: options[:platform_name], object: object, block: (with_output_buffer(&block) if block_given?)}
14
20
  end
15
21
 
16
22
  end
@@ -1,3 +1,4 @@
1
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
2
+
3
+ = link_to bhf.edit_entry_path(platform_name, object, bhf_area: area), class: 'bhf_edit', data: {:'no-turbolink' => true}, title: link_title do
3
4
  = block ? block : link_title
@@ -8,9 +8,14 @@
8
8
  = stylesheet_link_tag css
9
9
  %body
10
10
  %header
11
+
11
12
  %h1
12
13
  - logo = Rails.application.assets.find_asset('logo_bhf.png') ? 'logo_bhf.png' : 'logo_bhf.svg'
13
14
  = link_to image_tag(asset_path(logo)), main_app.root_url, :'data-no-turbolink' => true
15
+
16
+ - if @areas.any?
17
+ = select_tag :area_select, options_from_collection_for_select(@areas, 'path', 'name', main_app.bhf_path(params[:bhf_area]))
18
+
14
19
  - if @config && @config.pages.any?
15
20
  %nav
16
21
  %ul{class: ('shrink_space' if @config.pages.count > 7)}
@@ -0,0 +1,84 @@
1
+ module Bhf
2
+
3
+ module ConfigParser
4
+
5
+ class << self
6
+ def parse(roles_array, area = nil)
7
+ roles_config = roles_yml(roles_array, area)
8
+
9
+ if Bhf::Engine.config.abstract_config.any?
10
+
11
+ tmp_pages = get_config_array(Bhf::Engine.config.abstract_config, '/abstract')['pages']
12
+ abstract_platform_config = tmp_pages.each_with_object({}) do |abstract_pages, hash|
13
+ abstract_pages.each do |abstract_page|
14
+ abstract_page[1].each do |abstract_platform|
15
+ hash.merge!(abstract_platform)
16
+ end
17
+ end
18
+ end
19
+
20
+ roles_config['pages'].each_with_index do |pages, i_1|
21
+ pages.each_pair do |key_1, page|
22
+ page.each_with_index do |platform, i_2|
23
+ platform.each_pair do |key_2, value|
24
+ abstract_platform_key = if value.to_h['extend_abstract']
25
+ value.to_h['extend_abstract']
26
+ elsif abstract_platform_config[key_2]
27
+ key_2
28
+ end
29
+ next unless abstract_platform_key
30
+ roles_config['pages'][i_1][key_1][i_2][key_2] = abstract_platform_config[abstract_platform_key].deep_merge(value.to_h)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ return Bhf::Settings.new(roles_config)
38
+ end
39
+
40
+
41
+ def get_config_array(array, dir)
42
+ array.each_with_object({'pages' => []}) do |r, account_roles|
43
+ pages = load_yml("#{dir}/#{r}")['pages']
44
+ account_roles['pages'] += pages if pages
45
+ end
46
+ end
47
+
48
+ def roles_yml(roles = nil, area = nil)
49
+ area_dir = "/#{area}" if area.present?
50
+ if roles.is_a?(String)
51
+ load_yml("#{area_dir}/#{roles}")
52
+ elsif roles.is_a?(Array)
53
+ files = get_config_array(roles, area_dir)
54
+
55
+ # find the same pages and merge them
56
+ merged_files = {'pages' => []}
57
+ files['pages'].each do |pages|
58
+ merged = false
59
+ pages.each_pair do |key, page|
60
+ merged_files['pages'].each do |m_page|
61
+ if m_page.include?(key)
62
+ merged = true
63
+ m_page[key] = m_page[key] + page
64
+ end
65
+ end
66
+ end
67
+ if !merged
68
+ merged_files['pages'] << pages
69
+ end
70
+ end
71
+ merged_files
72
+ else
73
+ load_yml
74
+ end
75
+ end
76
+
77
+ def load_yml(suffix = nil)
78
+ YAML::load(IO.read("config/bhf#{suffix}.yml"))
79
+ end
80
+
81
+ end
82
+
83
+ end
84
+ end
data/lib/bhf.rb CHANGED
@@ -19,6 +19,7 @@ module Bhf
19
19
  config.account_model_find_method = 'find'
20
20
  config.css = []
21
21
  config.js = []
22
+ config.abstract_config = []
22
23
 
23
24
  # config.bhf_logic = YAML::load(IO.read('config/bhf.yml'))
24
25
 
@@ -44,6 +45,7 @@ require 'bhf/active_record/upload'
44
45
  require 'bhf/mongoid/document'
45
46
  require 'bhf/data'
46
47
  require 'bhf/platform'
48
+ require 'bhf/config_parser'
47
49
  require 'bhf/settings'
48
50
  require 'bhf/pagination'
49
51
  require 'bhf/form'
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.6.32
4
+ version: 0.7.0.rc1
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-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.12.4
47
+ version: 0.15.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.12.4
54
+ version: 0.15.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: haml-rails
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -205,6 +205,7 @@ files:
205
205
  - lib/bhf.rb
206
206
  - lib/bhf/active_record/active_record.rb
207
207
  - lib/bhf/active_record/upload.rb
208
+ - lib/bhf/config_parser.rb
208
209
  - lib/bhf/data.rb
209
210
  - lib/bhf/form.rb
210
211
  - lib/bhf/mongoid/document.rb
@@ -227,9 +228,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
228
  version: '0'
228
229
  required_rubygems_version: !ruby/object:Gem::Requirement
229
230
  requirements:
230
- - - ">="
231
+ - - ">"
231
232
  - !ruby/object:Gem::Version
232
- version: '0'
233
+ version: 1.3.1
233
234
  requirements: []
234
235
  rubyforge_project: nowarning
235
236
  rubygems_version: 2.2.1