rademade_admin 0.1.4 → 0.1.5

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: ccaea2ae3050d33085373d84cb715b1cb037ad85
4
- data.tar.gz: c8510ac4aae7b02c5afcb3c56e57e815dbeac39f
3
+ metadata.gz: 506cc86834c33f984bbdf61e71dec4fa7a50e1e2
4
+ data.tar.gz: ea1cc018f8994d3757f7647ee0897c75aec5cb5f
5
5
  SHA512:
6
- metadata.gz: 842600c6b68c316e3aee92811e46523dd632262599691dfb51bd1d8a775a8044ed8d58713a798973af6c0b0adacc2670b6c2a541495bc9e485568b25af2c365e
7
- data.tar.gz: c7164d86d919e0c207a71c7c0ab7ce367b7f7d5a4897cf8923f06c110ab2d8487727d464992183d3b638c2798d18f4222b1027e66b2ebe9471c5cff7f5594ac5
6
+ metadata.gz: c0802b51d1350071bebd1c4ae8cde902a18627f13a14aef041575e32ed52c3be0a2d903a5f6c729d46512cf2357337b3d866a41105ce1aa6c2ab40cef5166080
7
+ data.tar.gz: 23254105027ffe82e06ecd9b0a61d61c1f0c96b520d43acb951fe62df286a38af1a8232989131bf1738c108e6e5aa1f4bfa14bda80d2971ad738537f5a72e784
@@ -80,6 +80,8 @@
80
80
  @import rademade_admin/blocks/form/map
81
81
  @import rademade_admin/blocks/gallery/main
82
82
 
83
+ @import rademade_admin/blocks/filter/main
84
+
83
85
 
84
86
  /******************/
85
87
  /** modules **/
@@ -1,129 +1,139 @@
1
+ button
2
+ margin: 0
3
+ padding: 0
4
+ outline: none
5
+ border: 0
6
+ +box-sizing(content-box)
7
+
1
8
  .btn
2
- display: inline-block
3
- margin: 0
4
- padding: 6px 12px
5
- font-size: 14px
6
- font-weight: 400
7
- color: #fff
8
- text-align: center
9
- cursor: pointer
10
- border: 1px solid transparent
11
- +border-radius(4px)
12
- +user-select
9
+ display: inline-block
10
+ margin: 0
11
+ padding: 0 12px
12
+ height: 32px
13
+ line-height: 30px
14
+ font-size: 14px
15
+ font-weight: 400
16
+ color: #fff
17
+ text-align: center
18
+ cursor: pointer
19
+ border: 1px solid transparent
20
+ +border-radius(4px)
21
+ +box-sizing(border-box)
22
+ +user-select
13
23
 
14
24
  .blue-btn
15
- background-color: #428bca
16
- border-color: #357ebd
17
- &:hover
18
- background-color: #3071a9
19
- border-color: #285e8e
25
+ background-color: #428bca
26
+ border-color: #357ebd
27
+ &:hover
28
+ background-color: #3071a9
29
+ border-color: #285e8e
20
30
 
21
31
  .green-btn
22
- background-color: #5cb85c
23
- border-color: #4cae4c
24
- &:hover
25
- background-color: #449d44
26
- border-color: #398439
32
+ background-color: #5cb85c
33
+ border-color: #4cae4c
34
+ &:hover
35
+ background-color: #449d44
36
+ border-color: #398439
27
37
 
28
38
  .l-blue-btn
29
- background-color: #5bc0de
30
- border-color: #46b8da
31
- &:hover
32
- background-color: #31b0d5
33
- border-color: #269abc
39
+ background-color: #5bc0de
40
+ border-color: #46b8da
41
+ &:hover
42
+ background-color: #31b0d5
43
+ border-color: #269abc
34
44
 
35
45
  .yellow-btn
36
- background-color: #f0ad4e
37
- border-color: #eea236
38
- &:hover
39
- background-color: #ec971f
40
- border-color: #d58512
46
+ background-color: #f0ad4e
47
+ border-color: #eea236
48
+ &:hover
49
+ background-color: #ec971f
50
+ border-color: #d58512
41
51
 
42
52
  .red-btn
53
+ background-color: #c9302c
54
+ border-color: #ac2925
55
+ &:hover
43
56
  background-color: #c9302c
44
57
  border-color: #ac2925
45
- &:hover
46
- background-color: #c9302c
47
- border-color: #ac2925
48
58
 
49
59
  .r-margin
50
- margin-right: 20px
60
+ margin-right: 20px
51
61
 
52
62
  .btn-sep
53
- margin: 0 10px
54
- font-size: 12px
55
- line-height: 34px
63
+ margin: 0 10px
64
+ font-size: 12px
65
+ line-height: 34px
56
66
 
57
67
  .cancel-btn
58
- line-height: 34px
59
- font-size: 14px
60
- color: #46b8da
61
- border-bottom: 1px solid transparentize(#46b8da, 0.6)
62
- &:hover
63
- border-bottom: 1px solid transparent
68
+ line-height: 34px
69
+ font-size: 14px
70
+ color: #46b8da
71
+ border-bottom: 1px solid transparentize(#46b8da, 0.6)
72
+ &:hover
73
+ border-bottom: 1px solid transparent
64
74
 
65
75
  .related-link
66
- line-height: 30px
67
- font-size: 14px
68
- color: #46b8da
69
- border-bottom: 1px solid transparentize(#46b8da, 0.6)
70
- &:hover
71
- border-bottom: 1px solid transparent
76
+ line-height: 30px
77
+ font-size: 14px
78
+ color: #46b8da
79
+ border-bottom: 1px solid transparentize(#46b8da, 0.6)
80
+ &:hover
81
+ border-bottom: 1px solid transparent
72
82
 
73
83
  .login-btn
74
- padding: 9px 12px
75
- width: 100%
76
- font-size: 18px
84
+ padding: 9px 12px
85
+ width: 100%
86
+ font-size: 18px
77
87
 
78
88
  .select-btn
79
- padding: 4px 12px
89
+ padding: 4px 12px
80
90
 
81
91
  .lang-btn
82
- position: relative
83
- display: inline-block
84
- margin: 0
85
- padding: 6px 12px
86
- font-size: 13px
87
- font-weight: 400
88
- color: #fff
89
- text-align: center
90
- cursor: pointer
91
- border: 1px solid #397bc1
92
- background-color: #428bca
93
- +border-radius(5px)
94
- +user-select
92
+ position: relative
93
+ display: inline-block
94
+ margin: 0
95
+ padding: 6px 12px
96
+ font-size: 13px
97
+ font-weight: 400
98
+ color: #fff
99
+ text-align: center
100
+ cursor: pointer
101
+ border: 1px solid #397bc1
102
+ background-color: #428bca
103
+ +border-radius(5px)
104
+ +user-select
105
+
106
+ a
107
+ width: auto !important
108
+ padding: 0 10px
109
+
110
+ &:hover
111
+ background-color: #3071a9
112
+ border-color: #285e8e
95
113
 
114
+ &.ui-state-active
115
+ border: 1px solid #abc993
116
+ background-color: #eaf7de
96
117
  a
97
- width: auto !important
98
- padding: 0 10px
99
-
100
- &:hover
101
- background-color: #3071a9
102
- border-color: #285e8e
103
-
104
- &.ui-state-active
105
- border: 1px solid #abc993
106
- background-color: #eaf7de
107
- a
108
- position: relative
109
- color: #70ab3c !important
110
- &:after,
111
- &:before
112
- top: 100%
113
- left: 50%
114
- border: solid transparent
115
- content: " "
116
- height: 0
117
- width: 0
118
- position: absolute
119
- pointer-events: none
120
- &:after
121
- border-color: rgba(234, 247, 222, 0)
122
- border-top-color: #eaf7de
123
- border-width: 4px
124
- margin-left: -4px
125
- &:before
126
- border-color: rgba(171, 201, 147, 0)
127
- border-top-color: #abc993
128
- border-width: 5px
129
- margin-left: -5px
118
+ position: relative
119
+ color: #70ab3c !important
120
+ &:after,
121
+ &:before
122
+ top: 100%
123
+ left: 50%
124
+ border: solid transparent
125
+ content: " "
126
+ height: 0
127
+ width: 0
128
+ position: absolute
129
+ pointer-events: none
130
+ &:after
131
+ border-color: rgba(234, 247, 222, 0)
132
+ border-top-color: #eaf7de
133
+ border-width: 4px
134
+ margin-left: -4px
135
+ &:before
136
+ border-color: rgba(171, 201, 147, 0)
137
+ border-top-color: #abc993
138
+ border-width: 5px
139
+ margin-left: -5px
@@ -0,0 +1,10 @@
1
+ .filter-block
2
+ float: left
3
+ margin-right: 10px
4
+
5
+ .form-box
6
+ &.search
7
+ float: left
8
+ .btn
9
+ float: left
10
+ margin-right: 10px
@@ -41,16 +41,58 @@
41
41
  position: absolute
42
42
  top: 2px
43
43
  right: 5px
44
- font-size: 13px
44
+ width: 16px
45
+ height: 16px
46
+ padding: 1px
45
47
  cursor: pointer
46
- padding: 1px 5px
47
48
  border-radius: 3px
48
- background-color: #FFF
49
+ color: #333
49
50
  font-weight: bold
51
+ overflow: hidden
52
+ font-size: 16px
53
+ text-indent: 100%
54
+ background-color: #fff
55
+ &:before
56
+ position: absolute
57
+ top: 2px
58
+ left: 1px
59
+ width: 16px
60
+ height: 16px
61
+ text-indent: 0
62
+ @extend .glyphicon
63
+ @extend .glyphicon-remove
64
+ &:hover
65
+ +opacity(0.9)
50
66
 
51
67
  .crop-btn
52
68
  position: absolute
53
- bottom: 5px
69
+ top: 2px
70
+ right: 26px
71
+ width: 16px
72
+ height: 16px
73
+ padding: 1px
74
+ cursor: pointer
75
+ border-radius: 3px
76
+ color: #333
77
+ font-weight: bold
78
+ overflow: hidden
79
+ font-size: 14px
80
+ text-indent: 100%
81
+ background-color: #fff
82
+ border: 0
83
+ +box-sizing(content-box)
84
+ &:before
85
+ position: absolute
86
+ top: 2px
87
+ left: 1px
88
+ width: 16px
89
+ height: 16px
90
+ text-indent: 0
91
+ @extend .glyphicon
92
+ @extend .glyphicon-fullscreen
93
+ &:hover
94
+ +opacity(0.9)
95
+
54
96
 
55
97
  .gallery-images-container
56
98
  float: left
@@ -18,7 +18,7 @@ module RademadeAdmin
18
18
  protected
19
19
 
20
20
  def require_login
21
- redirect_to :controller => 'dashboard', :action => 'login' unless admin_logged_in?
21
+ redirect_to login_url unless admin_logged_in?
22
22
  end
23
23
 
24
24
  def init_user
@@ -41,7 +41,11 @@ class RademadeAdmin::FileController < RademadeAdmin::AbstractController
41
41
 
42
42
  def model
43
43
  model_class = RademadeAdmin::LoaderService.const_get(params[:model])
44
- params[:id].present? ? model_class.find(params[:id]) : model_class.new
44
+ model_object = nil
45
+ if params[:id].present?
46
+ model_object = model_class.find(params[:id]) rescue nil
47
+ end
48
+ model_object || model_class.new
45
49
  end
46
50
 
47
51
  end
@@ -31,7 +31,7 @@ module RademadeAdmin::FieldHelper
31
31
 
32
32
  selected = number == request.query_parameters[name.to_sym].to_i
33
33
  url_params = request.path_parameters.merge(hash_params)
34
- content_tag(:option, number.to_s, :selected => selected, :value => admin_url_for(url_params, true))
34
+ content_tag(:option, number.to_s, :selected => selected, :value => admin_url_for(url_params))
35
35
  end
36
36
 
37
37
  def input_attr(attrs = {})
@@ -2,7 +2,12 @@
2
2
  module RademadeAdmin::UriHelper
3
3
 
4
4
  def root_uri
5
- admin_url_for(controller: 'dashboard')
5
+ rademade_admin_route(:root_url)
6
+ end
7
+
8
+ def rademade_admin_route(route_url, opts = {})
9
+ opts[:only_path] = true
10
+ RademadeAdmin::Engine.routes.url_helpers.send(route_url, opts)
6
11
  end
7
12
 
8
13
  def admin_list_uri(model)
@@ -74,14 +79,14 @@ module RademadeAdmin::UriHelper
74
79
  end
75
80
 
76
81
  def admin_model_url_for(model, opts = {})
82
+ model_info = _real_model_info(model)
77
83
  admin_url_for(opts.merge({
78
- :controller => _real_model_info(model).controller
84
+ :controller => "#{model_info.module_name}/#{model_info.controller}"
79
85
  }))
80
86
  end
81
87
 
82
- def admin_url_for(opts, is_admin_controller = false)
88
+ def admin_url_for(opts)
83
89
  opts[:only_path] = true
84
- opts[:controller] = "rademade_admin/#{opts[:controller]}" unless is_admin_controller
85
90
  Rails.application.routes.url_helpers.url_for(opts)
86
91
  rescue
87
92
  RademadeAdmin::Engine.routes.url_helpers.url_for(opts) rescue nil
@@ -36,7 +36,7 @@ module RademadeAdmin
36
36
  :name => uploader.mounted_as,
37
37
  :data => {
38
38
  :saved => object.new_record? ? 0 : 1,
39
- :url => admin_url_for(:controller => 'file', :action => 'upload')
39
+ :url => rademade_admin_route(:file_upload_url)
40
40
  }.merge(uploader_params)
41
41
  })
42
42
  end
@@ -68,9 +68,9 @@ module RademadeAdmin
68
68
  template.content_tag(:a, I18n.t('rademade_admin.download_file'), {
69
69
  :class => 'btn blue-btn download-btn',
70
70
  :href => admin_url_for({
71
- :controller => 'file',
71
+ :controller => 'rademade_admin/file',
72
72
  :action => 'download'
73
- }.merge(uploader_params))
73
+ }.merge(uploader_params)) #todo use route name and resources
74
74
  }) unless uploader.file.nil?
75
75
  end
76
76
 
@@ -79,7 +79,7 @@ module RademadeAdmin
79
79
  :class => 'btn red-btn upload-btn',
80
80
  :data => {
81
81
  :crop => true,
82
- :url => admin_url_for(:controller => 'file', :action => 'crop')
82
+ :url => rademade_admin_route(:file_crop_url)
83
83
  }
84
84
  })
85
85
  end
@@ -20,7 +20,7 @@ module RademadeAdmin
20
20
  :type => 'file',
21
21
  :multiple => true,
22
22
  :data => {
23
- :url => admin_url_for(:controller => 'gallery', :action => 'upload'),
23
+ :url => rademade_admin_route(:gallery_upload_url),
24
24
  :class_name => gallery_class.to_s
25
25
  }
26
26
  })
@@ -31,7 +31,7 @@ module RademadeAdmin
31
31
  template.content_tag(:div, HtmlBuffer.new([images_html]), {
32
32
  :class => 'gallery-images-container',
33
33
  :data => {
34
- :sortable_url => is_sortable ? admin_url_for(:controller => 'gallery', :action => 'sort') : ''
34
+ :sortable_url => is_sortable ? rademade_admin_route(:gallery_sort_url) : ''
35
35
  }
36
36
  })
37
37
  end
@@ -25,7 +25,7 @@ module RademadeAdmin
25
25
  :class => 'btn red-btn crop-btn',
26
26
  :data => {
27
27
  :crop => true,
28
- :url => admin_url_for(:controller => 'gallery', :action => 'crop'),
28
+ :url => rademade_admin_route(:gallery_crop_url),
29
29
  :full_url => uploader.url,
30
30
  :original_dimensions => uploader.original_dimensions.join(',')
31
31
  }
@@ -50,11 +50,12 @@ module RademadeAdmin
50
50
  content_tag(:span, 'x', {
51
51
  :class => 'remove-ico',
52
52
  :data => {
53
- :url => admin_url_for(
54
- :controller => 'gallery',
53
+ #todo use route name and resources
54
+ :url => admin_url_for({
55
+ :controller => 'rademade_admin/gallery',
55
56
  :action => 'remove',
56
57
  :id => uploader.model.id.to_s
57
- )
58
+ })
58
59
  }
59
60
  })
60
61
  end
@@ -1,5 +1,5 @@
1
1
  <%
2
2
  if @sortable_service.can_reset?
3
- %><a href="<%= admin_url_for(request.path_parameters, true) %>"><%= t('rademade_admin.reset_sort') %></a><%
3
+ %><a href="<%= admin_url_for(request.path_parameters) %>"><%= t('rademade_admin.reset_sort') %></a><%
4
4
  end
5
5
  %>
@@ -1,7 +1,13 @@
1
1
  <%
2
2
  if @model_info.hideable? && can?(:edit, @model)
3
3
  element_id = "hide_#{item.id}"
4
- toggle_url = admin_url_for(:controller => :status, :action => :toggle, :model => @model, :id => item.id)
4
+ toggle_url = admin_url_for(
5
+ :controller => :status,
6
+ :action => :toggle,
7
+ :model => @model,
8
+ :id => item.id
9
+ ) #todo via native method. Add route resourse
10
+
5
11
  %><div class="view-option">
6
12
  <input id="<%=element_id%>" data-toggle-url="<%= toggle_url %>" type="checkbox"<%
7
13
  if item.shown?
@@ -10,8 +10,8 @@
10
10
  end %>
11
11
 
12
12
  <% content_for :content do %><%
13
- concat render @template_service.on_page_select_block
14
13
  concat render @template_service.search_block
14
+ concat render @template_service.on_page_select_block
15
15
  concat render @template_service.sort_reset_block
16
16
  %><table class="table-box"><%
17
17
  concat render @template_service.table_head_block, {
@@ -5,10 +5,12 @@ RademadeAdmin::Engine.routes.draw do
5
5
 
6
6
  root 'dashboard#index'
7
7
 
8
+ #todo via resources :file
8
9
  match 'file-upload' => 'file#upload', :via => [:post, :patch]
9
10
  match 'file-download/:model/:id/:uploader/:column' => 'file#download', :via => [:get]
10
11
  match 'file-crop' => 'file#crop', :via => [:post, :patch]
11
12
 
13
+ #todo via resources :gallery
12
14
  match 'gallery-upload' => 'gallery#upload', :via => [:post, :patch]
13
15
  match 'gallery-crop' => 'gallery#crop', :via => [:post, :patch]
14
16
  match 'gallery-sort' => 'gallery#sort', :via => [:post, :patch]
@@ -50,7 +50,7 @@ module RademadeAdmin
50
50
  end
51
51
 
52
52
  def model(model_name)
53
- @model_name = model_name
53
+ @model_name = model_name.to_s
54
54
  end
55
55
 
56
56
  def menu_count(&block)
@@ -4,15 +4,15 @@ module RademadeAdmin
4
4
  class Graph
5
5
  include Singleton
6
6
 
7
- def add_pair(controller_name, inner)
7
+ def add_pair(module_name, controller_name, inner)
8
8
  # Controller includes configuration for mapping model
9
- controller = LoaderService.const_get("rademade_admin/#{controller_name}_controller")
9
+ controller = LoaderService.const_get("#{module_name}/#{controller_name}_controller")
10
10
  controller.configuration.model(controller_name.classify) unless controller.model_name
11
11
 
12
12
  model = controller.model_class
13
13
 
14
14
  unless @model_infos[model.to_s]
15
- model_reflection = RademadeAdmin::Model::Reflection.new(model, controller_name)
15
+ model_reflection = RademadeAdmin::Model::Reflection.new(model, controller_name, module_name)
16
16
  model_info = RademadeAdmin::Model::Info.new(model_reflection, controller.configuration, inner)
17
17
  @model_infos[model.to_s] = model_info
18
18
  end
@@ -37,6 +37,10 @@ module RademadeAdmin
37
37
  model_reflection.controller
38
38
  end
39
39
 
40
+ def module_name
41
+ model_reflection.module_name
42
+ end
43
+
40
44
  def nested?
41
45
  @nested
42
46
  end
@@ -3,15 +3,15 @@ module RademadeAdmin
3
3
  module Model
4
4
  class Reflection
5
5
 
6
- attr_reader :model, :controller
7
-
8
- def initialize(model, controller)
9
- @model, @controller = model, controller
10
- end
11
-
12
6
  ORM_TYPE_ACTIVERECORD = 'ActiveRecord'
13
7
  ORM_TYPE_MONGOID = 'Mongoid'
14
8
 
9
+ attr_reader :model, :controller, :module_name
10
+
11
+ def initialize(model, controller, module_name)
12
+ @model, @controller, @module_name = model, controller, module_name
13
+ end
14
+
15
15
  # Load data adapter for current model
16
16
  #
17
17
  # @return [RademadeAdmin::Model::Adapter::Data]
@@ -35,7 +35,7 @@ module RademadeAdmin
35
35
 
36
36
  end
37
37
 
38
- Model::Graph.instance.add_pair(@scope[:controller], self.shallow?)
38
+ Model::Graph.instance.add_pair(@scope[:module], @scope[:controller], self.shallow?)
39
39
 
40
40
  end
41
41
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module RademadeAdmin
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rademade_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Melanitskiy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-11 00:00:00.000000000 Z
13
+ date: 2015-02-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -447,6 +447,7 @@ files:
447
447
  - app/assets/stylesheets/rademade_admin.sass.erb
448
448
  - app/assets/stylesheets/rademade_admin/base/main.sass
449
449
  - app/assets/stylesheets/rademade_admin/blocks/buttons/main.sass
450
+ - app/assets/stylesheets/rademade_admin/blocks/filter/_main.sass
450
451
  - app/assets/stylesheets/rademade_admin/blocks/form/checkbox.sass
451
452
  - app/assets/stylesheets/rademade_admin/blocks/form/input.sass
452
453
  - app/assets/stylesheets/rademade_admin/blocks/form/label.sass