poodle-rb 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a04e19c29121aaa00b743aa062def280e1d2ce
|
4
|
+
data.tar.gz: ceb3dd427f68ec9942a6929d3c272d20179cf7eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a37cf5f6cecac8aad4c472cbc252c44064c054b9c9edd75dfa2ce04c53f67197438cde5e96a01d330f17eebb0e05c1bd205befac0b45afa39004be928703ce0d
|
7
|
+
data.tar.gz: 28c503d4731298687758eb3cf149daff237cc4a6fd54fa330b8edf2b410788d5affd8920dbd240607eccf0eb1041dea64541e6a223555610d31b0abd45a3b781
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Poodle
|
2
|
+
module AdminFunctionalitiesHelper
|
3
|
+
def get_collections(collection_name, **options)
|
4
|
+
options.reverse_merge!(
|
5
|
+
kls: collection_name.to_s.camelize.singularize.camelize.constantize
|
6
|
+
)
|
7
|
+
relation = options[:kls].where("")
|
8
|
+
@filters = {}
|
9
|
+
|
10
|
+
if params[:query]
|
11
|
+
@query = params[:query].strip
|
12
|
+
relation = relation.search(@query) if !@query.blank?
|
13
|
+
end
|
14
|
+
objects = relation.order("created_at desc").page(@current_page).per(@per_page)
|
15
|
+
instance_variable_set("@#{collection_name}", objects)
|
16
|
+
unless instance_variable_get("@#{collection_name.to_s.singularize}")
|
17
|
+
instance_variable_set("@#{collection_name.to_s.singularize}", objects.first)
|
18
|
+
end
|
19
|
+
|
20
|
+
return true
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_list(collection_name, **options)
|
24
|
+
respond_to do |format|
|
25
|
+
format.html {
|
26
|
+
get_collections(collection_name, **options) and render :index }
|
27
|
+
format.js {}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def render_or_redirect(error, redirect_url, action)
|
32
|
+
respond_to do |format|
|
33
|
+
format.html {
|
34
|
+
if error
|
35
|
+
render action: action
|
36
|
+
else
|
37
|
+
redirect_to redirect_url, notice: @message
|
38
|
+
end
|
39
|
+
}
|
40
|
+
format.js {}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -100,13 +100,20 @@ module Poodle
|
|
100
100
|
object_name: object.class.name.underscore,
|
101
101
|
label: field_name.to_s.gsub("_", " ").titleize,
|
102
102
|
required: true,
|
103
|
-
error_class: "has-
|
103
|
+
error_class: "has-error",
|
104
104
|
html_options: {}
|
105
105
|
)
|
106
106
|
options.reverse_merge!(
|
107
107
|
param_name: "#{options[:object_name]}[#{field_name}]"
|
108
108
|
)
|
109
|
-
|
109
|
+
|
110
|
+
if object.errors[field_name.to_s].any?
|
111
|
+
error_class = options[:error_class]
|
112
|
+
error_message = content_tag(:span, object.errors[field_name].first, class: "help-block")
|
113
|
+
else
|
114
|
+
error_class = ""
|
115
|
+
error_message = ""
|
116
|
+
end
|
110
117
|
|
111
118
|
theme_form_group(options[:label], required: options[:required], error_class: error_class) do
|
112
119
|
options[:html_options].reverse_merge!(
|
@@ -126,7 +133,7 @@ module Poodle
|
|
126
133
|
when :checkbox
|
127
134
|
options[:html_options][:class] = "checkbox mt-10"
|
128
135
|
check_box_tag(options[:param_name], field_name, object.send(field_name.to_s), **options[:html_options])
|
129
|
-
end
|
136
|
+
end + error_message
|
130
137
|
end
|
131
138
|
|
132
139
|
end
|
@@ -165,17 +172,34 @@ module Poodle
|
|
165
172
|
label: foreign_key.to_s.titleize,
|
166
173
|
prompt: true,
|
167
174
|
editable: true,
|
168
|
-
error_class: "has-
|
175
|
+
error_class: "has-error"
|
169
176
|
)
|
170
177
|
|
171
|
-
|
178
|
+
# Populating Errors
|
179
|
+
errors = object.errors[foreign_key.to_s]
|
180
|
+
# if foreign_key is an id, check errors for the association
|
181
|
+
# errors = project.errors[:client_id] + project.errors[:client]
|
182
|
+
if object.errors[foreign_key.to_s.gsub("_id", "")]
|
183
|
+
errors += object.errors[foreign_key.to_s.gsub("_id", "")]
|
184
|
+
end
|
185
|
+
|
186
|
+
error_class = errors.any? ? options[:error_class] : ""
|
187
|
+
if errors.any?
|
188
|
+
error_class = options[:error_class]
|
189
|
+
error_message = content_tag(:span, errors.first, class: "help-block")
|
190
|
+
else
|
191
|
+
error_class = ""
|
192
|
+
error_message = ""
|
193
|
+
end
|
172
194
|
|
173
|
-
|
195
|
+
selected_id = object.send(foreign_key)
|
196
|
+
|
197
|
+
theme_form_group(options[:label], required: options[:required], error_class: error_class) do
|
174
198
|
if !options[:editable] && options[:assoc_object]
|
175
199
|
raw(options[:assoc_object].send(options[:assoc_display_method]) + hidden_field_tag("#{options[:param_name]}[#{foreign_key}]", options[:assoc_object].id))
|
176
200
|
else
|
177
|
-
collection_select(options[:object_name], foreign_key, options[:assoc_collection], :id, options[:assoc_display_method], {:
|
178
|
-
end
|
201
|
+
collection_select(options[:object_name], foreign_key, options[:assoc_collection], :id, options[:assoc_display_method], {prompt: options[:prompt], selected: selected_id}, {:class => 'form-control'})
|
202
|
+
end + error_message
|
179
203
|
end
|
180
204
|
|
181
205
|
end
|
@@ -200,12 +224,20 @@ module Poodle
|
|
200
224
|
label: "Label",
|
201
225
|
param_name: "Param",
|
202
226
|
prompt: true,
|
203
|
-
error_class: "has-
|
227
|
+
error_class: "has-error",
|
204
228
|
required: false
|
205
229
|
)
|
206
230
|
error_class = object.errors[field_name.to_s].any? ? options[:error_class] : ""
|
207
|
-
|
208
|
-
|
231
|
+
if object.errors[field_name.to_s].any?
|
232
|
+
error_class = options[:error_class]
|
233
|
+
error_message = content_tag(:span, object.errors[field_name].first, class: "help-block")
|
234
|
+
else
|
235
|
+
error_class = ""
|
236
|
+
error_message = ""
|
237
|
+
end
|
238
|
+
|
239
|
+
theme_form_group(options[:label], required: options[:required], error_class: error_class) do
|
240
|
+
form.select(options[:param_name], options_for_select(options_list, :selected => form.object.name), {:prompt=>options[:prompt]}, {:class => 'form-control'}) + error_message
|
209
241
|
end
|
210
242
|
end
|
211
243
|
|
@@ -215,9 +247,9 @@ module Poodle
|
|
215
247
|
# is equivalent to:
|
216
248
|
# ---------------------------
|
217
249
|
# submit_tag button_text, "data-reset-text"=>button_text, "data-loading-text"=>"Saving ...", :class=>"btn btn-primary ml-10"
|
218
|
-
def theme_form_button(object, button_text="", saving_message="Saving ...")
|
250
|
+
def theme_form_button(object, button_text="", saving_message="Saving ...", classes="btn btn-primary ml-10")
|
219
251
|
button_text = "#{object.new_record? ? "Create" : "Update"}" if button_text.blank?
|
220
|
-
submit_tag(button_text, "data-reset-text"=>button_text, "data-loading-text"=>saving_message, :class=>
|
252
|
+
submit_tag(button_text, "data-reset-text"=>button_text, "data-loading-text"=>saving_message, :class=>classes)
|
221
253
|
end
|
222
254
|
end
|
223
255
|
end
|
@@ -125,7 +125,7 @@ module Poodle
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def clear_tag(height)
|
128
|
-
content_tag(:div, "", class: "cl-#{height}")
|
128
|
+
content_tag(:div, "", class: "clearfix cl-#{height}")
|
129
129
|
end
|
130
130
|
|
131
131
|
# Example
|
@@ -170,8 +170,8 @@ module Poodle
|
|
170
170
|
# is equivalent to:
|
171
171
|
# ---------------------------
|
172
172
|
# <h3 class="panel-title">Team Members</h3>
|
173
|
-
def theme_panel_title(title)
|
174
|
-
content_tag(:h3, title, class: "panel-title")
|
173
|
+
def theme_panel_title(title, classes="")
|
174
|
+
content_tag(:h3, title, class: "panel-title #{classes}")
|
175
175
|
end
|
176
176
|
|
177
177
|
# Example
|
@@ -205,12 +205,22 @@ module Poodle
|
|
205
205
|
content_tag(:div, description, class: classes)
|
206
206
|
end
|
207
207
|
|
208
|
-
def theme_detail_box(collection)
|
208
|
+
def theme_detail_box(collection, **options)
|
209
|
+
options.reverse_merge!(
|
210
|
+
show_partial: "show",
|
211
|
+
new_partial: "form",
|
212
|
+
edit_partial: "form",
|
213
|
+
index_partial: "show",
|
214
|
+
)
|
209
215
|
case params[:action]
|
210
216
|
when "show"
|
211
|
-
render partial:
|
217
|
+
render partial: options[:show_partial]
|
218
|
+
when "new"
|
219
|
+
render partial: options[:new_partial]
|
220
|
+
when "edit"
|
221
|
+
render partial: options[:edit_partial]
|
212
222
|
when "index"
|
213
|
-
collection.empty? ? (theme_panel_message(I18n.translate("forms.no_results_found"))) : render(partial:
|
223
|
+
collection.empty? ? (theme_panel_message(I18n.translate("forms.no_results_found"))) : render(partial: options[:index_partial])
|
214
224
|
else
|
215
225
|
theme_panel_message(I18n.translate("forms.no_results_found"))
|
216
226
|
end
|
data/lib/poodle/engine.rb
CHANGED
@@ -17,6 +17,7 @@ module Poodle
|
|
17
17
|
include Poodle::ParamsParserHelper
|
18
18
|
include Poodle::TitleHelper
|
19
19
|
include Poodle::UrlHelper
|
20
|
+
include Poodle::AdminFunctionalitiesHelper
|
20
21
|
helper Poodle::DisplayHelper
|
21
22
|
helper Poodle::FlashHelper
|
22
23
|
helper Poodle::ImageHelper
|
@@ -25,6 +26,7 @@ module Poodle
|
|
25
26
|
helper Poodle::ParamsParserHelper
|
26
27
|
helper Poodle::TitleHelper
|
27
28
|
helper Poodle::UrlHelper
|
29
|
+
helper Poodle::AdminFunctionalitiesHelper
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
data/lib/poodle/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.7
|
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-01-
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- app/assets/stylesheets/poodle/font-awesome.css
|
100
100
|
- app/assets/stylesheets/poodle/poodle-theme.css
|
101
101
|
- app/controllers/poodle/application_controller.rb
|
102
|
+
- app/helpers/poodle/admin_functionalities_helper.rb
|
102
103
|
- app/helpers/poodle/application_helper.rb
|
103
104
|
- app/helpers/poodle/display_helper.rb
|
104
105
|
- app/helpers/poodle/flash_helper.rb
|