poodle-rb 0.1.5 → 0.1.6

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: 013d81fa630ad135c2cf767f2c533e258e0fbf60
4
- data.tar.gz: cc4dbb1760a22b68b125ae372a033b4fd2195591
3
+ metadata.gz: d2da546d91de8df4816c732220a3c01f6e2a6328
4
+ data.tar.gz: 7d6651914abd00d5d29968bbb429deda12615bb4
5
5
  SHA512:
6
- metadata.gz: 876667f2aa4e98e95f989220d8bf124fd61c1e7417184ff35ebe8a2d98b9e7bdcf08bb9b7999a9e2cb49da0139e2e0213144f35b726804dd1d7afe6b74596d53
7
- data.tar.gz: ae0b6672ea6c1a752fdf83a42d1a787f18e14291df383fa4f7ffb79476d8e14259e37014d0f28575357aea3bb4777059fe1ff35a978cfff03bc27732e808dbc8
6
+ metadata.gz: fde41c37d1ed9e52e5ca8c3e4b1a84208dac19e7b74842455b2429dc589c8dc56eb92f09e38adf379d1611d9a2536f9d88f982fefb6fc2be33ef95b30fd58a17
7
+ data.tar.gz: 6b7dc0d03b5599d6d558edb4e7690e52d5df6726a525a158e85828eef13a477aec8849cd2d0fb4f03d0a4d5222ffcc7450b32dbc561691616bff00e577f9b5d6
@@ -65,7 +65,7 @@ module Poodle
65
65
  end
66
66
 
67
67
  def default_collection_name
68
- params[:controller].gsub("admin/", "").to_s
68
+ params[:controller].split("/").last
69
69
  end
70
70
 
71
71
  def default_item_name
@@ -118,11 +118,15 @@ module Poodle
118
118
  return true
119
119
  end
120
120
 
121
+ def resource_url(obj)
122
+ url_for([:admin, obj])
123
+ end
124
+
121
125
  def save_resource(obj)
122
126
  obj.save
123
127
  set_flash_message(@options[:messages][:save], :success) if obj.errors.blank?
124
128
  action_name = params[:action].to_s == "create" ? "new" : "edit"
125
- url = obj.persisted? ? url_for([:admin, obj]) : nil
129
+ url = obj.persisted? ? resource_url(obj) : nil
126
130
  render_or_redirect(obj.errors.any?, url, action_name)
127
131
  end
128
132
 
@@ -1,6 +1,15 @@
1
1
  module Poodle
2
2
  module ImageHelper
3
3
 
4
+ # namify returns the first letters of first name and last name
5
+ # @examples Basic usage
6
+ #
7
+ # >>> namify("Krishnaprasad Varma")
8
+ # => "KV"
9
+ def namify(name)
10
+ name.split(" ").map{|x| x.first.capitalize}[0..1].join("")
11
+ end
12
+
4
13
  # placeholdit is a helper method used to return placechold.it urls with custom width, height and text
5
14
  # It is quite useful for POC Applications to get started with place holder images while developing views
6
15
  #
@@ -82,7 +91,7 @@ module Poodle
82
91
  #
83
92
  # @example Advanced Usage with
84
93
  #
85
- # >>> display_user_image(@user, 'profile_picture.image.thumb.url', width: 100, height: 100)
94
+ # >>> display_user_image(@user, 'profile_picture.image.thumb.url', width: 100px, height: 100px)
86
95
  # "<div><div class="rounded" style="width:100px;height:60px;"><img alt="Thumb krishnan" class="" src="/uploads/image/profile_picture/39/thumb_krishnan.jpg" style="width:100%;height:auto;cursor:default;"></div></div>"
87
96
  def display_user_image(user, method_name, **options)
88
97
 
@@ -99,7 +108,11 @@ module Poodle
99
108
  options[:html_options].reverse_merge!(
100
109
  style: "width:100%;height:auto;cursor:#{options.has_key?(:popover) ? "pointer" : "default"};",
101
110
  class: user.persisted? ? "#{user.id}-poodle-thumb-image" : ""
102
- )
111
+ )
112
+
113
+ if user.respond_to?(:name)
114
+ options[:place_holder].reverse_merge!(text: namify(user.name), width: "120px")
115
+ end
103
116
 
104
117
  options[:html_options].reverse_merge!(
105
118
  "data-toggle" => "popover",
@@ -106,7 +106,10 @@ module Poodle
106
106
  end
107
107
  end
108
108
 
109
- def theme_drop_down(collection, method_name)
109
+ def theme_drop_down(collection, method_name, **options)
110
+ options.reverse_merge!(
111
+ scope: :admin
112
+ )
110
113
  content_tag(:div, class: "btn-group mt-10 mb-10", style: "width:100%;") do
111
114
  button_tag(type: 'button', :class => "btn btn-default btn-block dropdown-toggle", "data-toggle" => "dropdown") do
112
115
  raw("Choose a Project" + content_tag(:span, "", class: "caret"))
@@ -115,7 +118,8 @@ module Poodle
115
118
  li_array = []
116
119
  collection.each do |item|
117
120
  li_array << content_tag(:li) do
118
- link_to item.send(method_name), main_app.url_for([:admin, item]), :remote => true
121
+ url = main_app.url_for([options[:scope], item])
122
+ link_to item.send(method_name), url, :remote => true
119
123
  end
120
124
  end
121
125
  raw(li_array.join(" ")) +
@@ -222,9 +226,9 @@ module Poodle
222
226
  when "edit"
223
227
  render partial: options[:edit_partial]
224
228
  when "index"
225
- collection.empty? ? (theme_panel_message(I18n.translate("forms.no_results_found"))) : render(partial: options[:index_partial])
229
+ collection.empty? ? (theme_panel_message(I18n.translate("forms.no_results"))) : render(partial: options[:index_partial])
226
230
  else
227
- theme_panel_message(I18n.translate("forms.no_results_found"))
231
+ theme_panel_message(I18n.translate("forms.no_results"))
228
232
  end
229
233
  end
230
234
 
@@ -1,3 +1,3 @@
1
1
  module Poodle
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -7,6 +7,14 @@ module Poodle
7
7
  let(:user) { FactoryGirl.create(:user) }
8
8
  let(:user_with_image) { FactoryGirl.create(:user_with_image, name: "Some Name") }
9
9
 
10
+ describe '#namify' do
11
+ it "should return the first letters of the names" do
12
+ expect(helper.namify("Ravi Shankar")).to eq("RS")
13
+ expect(helper.namify("Krishnaprasad")).to eq("K")
14
+ expect(helper.namify("Mohandas Karam Chand Gandhi")).to eq("MK")
15
+ end
16
+ end
17
+
10
18
  describe '#placeholdit' do
11
19
  it "should return placeholdit url" do
12
20
  expect(helper.placeholdit()).to eq("http://placehold.it/60x60&text=<No Image>")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poodle-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krishnaprasad Varma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kaminari