kuppayam 0.1.5 → 0.1.6dev2
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 +4 -4
- data/README.md +13 -0
- data/app/assets/images/{kuppayam/favicon.png → favicon.png} +0 -0
- data/app/assets/images/{kuppayam/logo.png → logo.png} +0 -0
- data/app/assets/javascripts/kuppayam.js +3 -0
- data/app/assets/javascripts/kuppayam/utilities.js +28 -0
- data/app/assets/stylesheets/kuppayam.css +1 -0
- data/app/assets/stylesheets/kuppayam/custom.css +4 -0
- data/app/controllers/kuppayam/base_controller.rb +14 -4
- data/app/controllers/kuppayam/documents_controller.rb +24 -0
- data/app/controllers/kuppayam/images_controller.rb +41 -1
- data/app/helpers/breadcrumbs_helper.rb +1 -1
- data/app/helpers/filter_helper.rb +9 -3
- data/app/helpers/image_helper.rb +11 -3
- data/app/helpers/kuppayam_helper.rb +2 -2
- data/app/helpers/meta_tags_helper.rb +0 -4
- data/app/helpers/notification_helper.rb +6 -6
- data/app/helpers/render_helper.rb +11 -2
- data/app/helpers/resource_helper.rb +23 -9
- data/app/models/document/base.rb +13 -15
- data/app/models/document/import_data_file.rb +14 -0
- data/app/models/document/import_report_file.rb +8 -0
- data/app/models/image/base.rb +12 -14
- data/app/models/import_data.rb +19 -2
- data/app/models/kuppayam/application_record.rb +3 -0
- data/app/uploaders/document_uploader.rb +4 -4
- data/app/uploaders/image_uploader.rb +1 -1
- data/app/uploaders/import_data_uploader.rb +15 -0
- data/app/views/kuppayam/documents/create.html.erb +1 -1
- data/app/views/kuppayam/documents/edit.js.erb +1 -1
- data/app/views/kuppayam/documents/new.js.erb +1 -1
- data/app/views/kuppayam/documents/update.html.erb +1 -1
- data/app/views/kuppayam/filters/_display_dropdown_filters.html.erb +11 -0
- data/app/views/kuppayam/filters/_display_filters.html.erb +29 -0
- data/app/views/kuppayam/http_status/404.html.erb +1 -0
- data/app/views/kuppayam/images/_form.html.erb +1 -1
- data/app/views/kuppayam/images/_index.html.erb +17 -20
- data/app/views/kuppayam/images/_show.html.erb +32 -0
- data/app/views/kuppayam/images/create.html.erb +4 -4
- data/app/views/kuppayam/images/crop.html.erb +1 -1
- data/app/views/kuppayam/images/destroy.js.erb +19 -0
- data/app/views/kuppayam/images/edit.js.erb +3 -3
- data/app/views/kuppayam/images/index.html.erb +8 -1
- data/app/views/kuppayam/images/new.js.erb +1 -1
- data/app/views/kuppayam/images/update.html.erb +5 -5
- data/app/views/kuppayam/import_data/new.js.erb +1 -1
- data/app/views/kuppayam/import_data/update.html.erb +1 -1
- data/app/views/kuppayam/workflows/parrot/create.js.erb +11 -6
- data/app/views/kuppayam/workflows/parrot/edit.js.erb +1 -1
- data/app/views/kuppayam/workflows/parrot/new.js.erb +2 -2
- data/app/views/kuppayam/workflows/parrot/row.js.erb +1 -1
- data/app/views/kuppayam/workflows/parrot/update.js.erb +10 -5
- data/app/views/kuppayam/workflows/peacock/create.js.erb +12 -7
- data/app/views/kuppayam/workflows/peacock/edit.js.erb +2 -2
- data/app/views/kuppayam/workflows/peacock/new.js.erb +2 -2
- data/app/views/kuppayam/workflows/peacock/row.js.erb +1 -1
- data/app/views/kuppayam/workflows/peacock/update.js.erb +11 -6
- data/app/views/layouts/kuppayam/_footer.html.erb +1 -0
- data/app/views/layouts/kuppayam/_head.html.erb +11 -2
- data/app/views/layouts/kuppayam/_heading.html.erb +11 -2
- data/app/views/layouts/kuppayam/_horizontal_menu.html.erb +932 -0
- data/app/views/layouts/kuppayam/_sidebar.html.erb +5 -2
- data/app/views/layouts/kuppayam/admin.html.erb +63 -6
- data/app/views/layouts/kuppayam/blank.html.erb +62 -5
- data/app/views/layouts/kuppayam/document_upload.html.erb +3 -2
- data/app/views/layouts/kuppayam/image_upload.html.erb +3 -2
- data/app/views/layouts/kuppayam/layout_horizontal_menu.html.erb +116 -0
- data/app/views/layouts/kuppayam/print_a4.html.erb +32 -0
- data/app/views/layouts/kuppayam/user.html.erb +120 -0
- data/config/initializers/importer.rb +303 -0
- data/config/initializers/validators.rb +78 -0
- data/config/locales/kuppayam/general.yml +1 -0
- data/config/routes.rb +1 -1
- data/db/migrate/20170000000000_create_images.rb +1 -0
- data/db/migrate/20170000000001_create_documents.rb +2 -1
- data/db/migrate/20170000000002_create_import_data.rb +2 -2
- data/lib/kuppayam/action_view/form_helper.rb +1 -1
- data/lib/kuppayam/action_view/theme_helper.rb +8 -2
- data/lib/kuppayam/engine.rb +2 -0
- data/lib/kuppayam/version.rb +1 -1
- data/lib/tasks/template.rake +72 -0
- data/lib/tasks/test_import.rake +40 -0
- data/vendor/assets/stylesheets/custom.css +0 -0
- metadata +76 -16
- data/app/views/kuppayam/images/_action_buttons.html.erb +0 -14
- data/app/views/layouts/kuppayam/_overlays.html.erb +0 -47
- data/config/initializers/kuppayam_validators.rb +0 -76
- data/lib/tasks/kuppayam_tasks.rake +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e1bdd06972d946d3a66cb0e43807d400dbf7349
|
|
4
|
+
data.tar.gz: 526bc0b5039d1382f83311600f16bd2a84c9e795
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a29bd72865ccc26d82d4a3799a1814b345a3af7738278c90c217e4ac4a602dcff5c77b747555354401c5c7ef5e9e151635f2d3b66e78c53215b5e9d964a1e1a
|
|
7
|
+
data.tar.gz: c768a4b73b07869e91935a9a01b03d951d1539e3bd771014d206ff71781b39d557e9c8724708f27a0cb83623908e660e721dce46cd16e54fe0f75022d78e4ffb
|
data/README.md
CHANGED
|
@@ -43,6 +43,19 @@ $ gem push gem push kuppayam-0.1.1.gem
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
|
|
46
|
+
## Testing the gem
|
|
47
|
+
|
|
48
|
+
cd spec/dummy
|
|
49
|
+
rails db:create db:migrate
|
|
50
|
+
|
|
51
|
+
rails s -p <port>
|
|
52
|
+
|
|
53
|
+
## Running rspec
|
|
54
|
+
rails db:create db:migrate RAILS_ENV
|
|
55
|
+
|
|
56
|
+
# run rspec from the rails root folder and not from dummy folder as spec helper has been linked to dummy.
|
|
57
|
+
rspec
|
|
58
|
+
|
|
46
59
|
|
|
47
60
|
## License
|
|
48
61
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
File without changes
|
|
File without changes
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
//
|
|
13
13
|
//= require kuppayam/utilities.js
|
|
14
14
|
//= require bootstrap.min.js
|
|
15
|
+
//= require moment.min.js
|
|
15
16
|
//= require TweenMax.min.js
|
|
16
17
|
//= require resizeable.js
|
|
17
18
|
//= require joinable.js
|
|
@@ -21,5 +22,7 @@
|
|
|
21
22
|
//= require wysihtml5/lib/js/wysihtml5-0.3.0.js
|
|
22
23
|
//= require wysihtml5/src/bootstrap-wysihtml5.js
|
|
23
24
|
//= require toastr/toastr.min.js
|
|
25
|
+
//= require daterangepicker/daterangepicker.js
|
|
26
|
+
//= require multiselect/js/jquery.multi-select.js
|
|
24
27
|
|
|
25
28
|
|
|
@@ -10,10 +10,31 @@ function sendAjaxRequest(url, mType){
|
|
|
10
10
|
jQuery.ajax({type: methodType, dataType:"script", url:url});
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
var imageUploadModalId = "div_modal_image_upload";
|
|
13
14
|
var genericModalId = "div_modal_generic";
|
|
14
15
|
var largeModalId = "div_modal_large";
|
|
15
16
|
var messageModalId = "div_modal_message";
|
|
16
17
|
|
|
18
|
+
// Call this function by passing model Id, heading and a bodyContent.
|
|
19
|
+
// it will pop up bootstrap 3 modal.
|
|
20
|
+
function showImageUploadModal(heading, bodyContent, showHeading){
|
|
21
|
+
$('#' + imageUploadModalId + ' .modal-header .modal-title').text(heading);
|
|
22
|
+
$('#' + imageUploadModalId + ' div.modal-body-main').html(bodyContent);
|
|
23
|
+
$('#' + imageUploadModalId).modal({show: true, backdrop: 'static', keyboard: false});
|
|
24
|
+
|
|
25
|
+
if(showHeading){
|
|
26
|
+
$('#' + imageUploadModalId + ' .modal-header').show();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
$('#' + imageUploadModalId + ' .modal-header').hide();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setTimeout(function() {
|
|
33
|
+
$('#' + imageUploadModalId).modal('handleUpdate'); //Update backdrop on modal show
|
|
34
|
+
$('#' + imageUploadModalId).scrollTop(0); //reset modal to top position
|
|
35
|
+
}, 1000);
|
|
36
|
+
}
|
|
37
|
+
|
|
17
38
|
// Call this function by passing model Id, heading and a bodyContent.
|
|
18
39
|
// it will pop up bootstrap 3 modal.
|
|
19
40
|
function showGenericModal(heading, bodyContent, showHeading){
|
|
@@ -72,6 +93,13 @@ function showMessageModal(heading, message, modalId){
|
|
|
72
93
|
}, 1000);
|
|
73
94
|
}
|
|
74
95
|
|
|
96
|
+
function closeImageUploadModal(modalId){
|
|
97
|
+
$('#' + imageUploadModalId).modal('hide');
|
|
98
|
+
|
|
99
|
+
showAndHideModals();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
75
103
|
function closeGenericModal(modalId){
|
|
76
104
|
$('#' + genericModalId).modal('hide');
|
|
77
105
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
module Kuppayam
|
|
2
2
|
class BaseController < ActionController::Base
|
|
3
3
|
|
|
4
|
-
protect_from_forgery with: :
|
|
4
|
+
protect_from_forgery with: :null_session
|
|
5
5
|
rescue_from ActionController::InvalidAuthenticityToken, :with => :handle_invalid_authenticity_token
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
layout 'kuppayam/admin'
|
|
8
8
|
|
|
9
|
+
before_action :get_nested_resource_objects
|
|
9
10
|
before_action :set_locale, :stylesheet_filename, :javascript_filename,
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
:set_default_title, :set_navs, :parse_pagination_params,
|
|
12
|
+
:configure_filters, :configure_notification, :configure_breadcrumbs
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
include ParamsParserHelper
|
|
14
16
|
include RenderHelper
|
|
@@ -44,6 +46,14 @@ module Kuppayam
|
|
|
44
46
|
{ locale: I18n.locale }
|
|
45
47
|
end
|
|
46
48
|
|
|
49
|
+
# This is more like a hooker method which is called
|
|
50
|
+
# before all other before_action method.
|
|
51
|
+
# This method can be overriden by inherited controller classes
|
|
52
|
+
# An e.g: would be to call a method to get @store object from params[:store_id]
|
|
53
|
+
# The object @store has to be initiated before the breadcrumbs or set_title methods are called
|
|
54
|
+
def get_nested_resource_objects
|
|
55
|
+
end
|
|
56
|
+
|
|
47
57
|
def stylesheet_filename
|
|
48
58
|
@stylesheet_filename = "kuppayam"
|
|
49
59
|
end
|
|
@@ -12,6 +12,10 @@ module Kuppayam
|
|
|
12
12
|
@document = @document_class.find(params[:id])
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def download
|
|
16
|
+
@document = @document_class.find(params[:id])
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def new
|
|
16
20
|
@document = @document_class.new
|
|
17
21
|
end
|
|
@@ -83,6 +87,26 @@ module Kuppayam
|
|
|
83
87
|
@relation = @relation.order(@order_by)
|
|
84
88
|
end
|
|
85
89
|
|
|
90
|
+
def resource_controller_configuration
|
|
91
|
+
{
|
|
92
|
+
page_title: "Documents",
|
|
93
|
+
js_view_path: "/kuppayam/workflows/parrot",
|
|
94
|
+
view_path: "/kuppayam/images"
|
|
95
|
+
}
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def breadcrumbs_configuration
|
|
99
|
+
{
|
|
100
|
+
heading: "Manage Documents",
|
|
101
|
+
icon: "fa-file",
|
|
102
|
+
description: "Listing all Documents",
|
|
103
|
+
links: [
|
|
104
|
+
{name: "Home", link: root_path, icon: 'fa-home'},
|
|
105
|
+
{name: "Manage Documents", link: documents_path, icon: 'fa-file', active: true}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
end
|
|
109
|
+
|
|
86
110
|
def configure_filter_settings
|
|
87
111
|
@filter_settings = {
|
|
88
112
|
string_filters: [
|
|
@@ -9,7 +9,12 @@ module Kuppayam
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def show
|
|
12
|
-
@image =
|
|
12
|
+
@image = Image::Base.find(params[:id])
|
|
13
|
+
@r_object = @image = Image::Base.find(params[:id])
|
|
14
|
+
unless @r_object
|
|
15
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: "Image"))
|
|
16
|
+
end
|
|
17
|
+
render_accordingly
|
|
13
18
|
end
|
|
14
19
|
|
|
15
20
|
def new
|
|
@@ -24,6 +29,7 @@ module Kuppayam
|
|
|
24
29
|
@image = @image_class.new
|
|
25
30
|
@image.imageable = @resource
|
|
26
31
|
@image.image = params[:image]
|
|
32
|
+
# @image.image_type = @image_class.name
|
|
27
33
|
@image.save if @image.valid?
|
|
28
34
|
set_flash_message("Image has been created successfully", :success)
|
|
29
35
|
render layout: "kuppayam/image_upload"
|
|
@@ -46,6 +52,20 @@ module Kuppayam
|
|
|
46
52
|
render layout: "kuppayam/image_upload"
|
|
47
53
|
end
|
|
48
54
|
|
|
55
|
+
def destroy
|
|
56
|
+
@image = @r_object = @image_class.find(params[:id])
|
|
57
|
+
@id = @image.id
|
|
58
|
+
if @image
|
|
59
|
+
@image.destroy
|
|
60
|
+
set_flash_message(I18n.t('success.deleted'), :success)
|
|
61
|
+
set_notification(true, I18n.t('status.success'), I18n.t('success.deleted', item: "Image"))
|
|
62
|
+
@destroyed = true
|
|
63
|
+
else
|
|
64
|
+
set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: "Image"))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
49
69
|
private
|
|
50
70
|
|
|
51
71
|
def permitted_params
|
|
@@ -83,6 +103,26 @@ module Kuppayam
|
|
|
83
103
|
@relation = @relation.order(@order_by)
|
|
84
104
|
end
|
|
85
105
|
|
|
106
|
+
def resource_controller_configuration
|
|
107
|
+
{
|
|
108
|
+
page_title: "Images",
|
|
109
|
+
js_view_path: "/kuppayam/workflows/parrot",
|
|
110
|
+
view_path: "/kuppayam/images"
|
|
111
|
+
}
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def breadcrumbs_configuration
|
|
115
|
+
{
|
|
116
|
+
heading: "Manage Images",
|
|
117
|
+
icon: "fa-photo",
|
|
118
|
+
description: "Listing all Images",
|
|
119
|
+
links: [
|
|
120
|
+
{name: "Home", link: root_path, icon: 'fa-home'},
|
|
121
|
+
{name: "Manage Images", link: images_path, icon: 'fa-photo', active: true}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
|
|
86
126
|
def configure_filter_settings
|
|
87
127
|
@filter_settings = {
|
|
88
128
|
string_filters: [
|
|
@@ -21,7 +21,7 @@ module BreadcrumbsHelper
|
|
|
21
21
|
# Initialize @links in your controller action
|
|
22
22
|
def breadcrumb
|
|
23
23
|
if @breadcrumbs && @breadcrumbs.has_key?(:links) && @breadcrumbs[:links].any?
|
|
24
|
-
content_tag(:div, class: "breadcrumb-env") do
|
|
24
|
+
content_tag(:div, class: "breadcrumb-env hidden-xs") do
|
|
25
25
|
content_tag(:ol, class: "breadcrumb bc-1") do
|
|
26
26
|
li_array = []
|
|
27
27
|
@breadcrumbs[:links].each do |item|
|
|
@@ -3,7 +3,6 @@ module FilterHelper
|
|
|
3
3
|
|
|
4
4
|
def configure_filters
|
|
5
5
|
configure_filter_settings
|
|
6
|
-
configure_filter_ui_settings
|
|
7
6
|
configure_filter_param_mapping
|
|
8
7
|
end
|
|
9
8
|
|
|
@@ -98,6 +97,8 @@ module FilterHelper
|
|
|
98
97
|
options = rpf[:options] || {}
|
|
99
98
|
parse_reference_filter_from_params(rpf[:filter_name], rpf[:filter_class], options)
|
|
100
99
|
end if filter_settings.has_key?(:reference_filters)
|
|
100
|
+
|
|
101
|
+
configure_filter_ui_settings
|
|
101
102
|
end
|
|
102
103
|
|
|
103
104
|
# Use this method to create a filter if the value is in a variable
|
|
@@ -329,10 +330,15 @@ module FilterHelper
|
|
|
329
330
|
end
|
|
330
331
|
selected_text = filter_options[:select_label] unless selected_text
|
|
331
332
|
|
|
332
|
-
# Clone the existing filters
|
|
333
|
+
# Clone the existing filters first
|
|
333
334
|
# remove the filters which are to be removed and add which are to be added
|
|
334
335
|
# Also remove the filter which is currently selected
|
|
335
|
-
|
|
336
|
+
|
|
337
|
+
unless filter_options[:current_filters].blank?
|
|
338
|
+
temp_filters = {}
|
|
339
|
+
else
|
|
340
|
+
temp_filters = filter_options[:current_filters].clone
|
|
341
|
+
end
|
|
336
342
|
temp_filters.merge!(filter_options[:filters_to_add])
|
|
337
343
|
temp_filters.reject!{|k,v| filter_options[:filters_to_remove].include?(k)}
|
|
338
344
|
temp_filters.reject!{|k,v| k == filter_name.to_sym }
|
data/app/helpers/image_helper.rb
CHANGED
|
@@ -85,7 +85,15 @@ module ImageHelper
|
|
|
85
85
|
class: ""
|
|
86
86
|
)
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
begin
|
|
89
|
+
image_object_name = method_name.split(".").first
|
|
90
|
+
image_object = object.send :eval, image_object_name
|
|
91
|
+
image_object_id = image_object ? image_object.id : nil
|
|
92
|
+
rescue
|
|
93
|
+
raise "Error with display_image method in kuppayam image_helper.rb"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
options[:class] = options[:class] + (object.persisted? ? " #{image_object_id}-#{options[:size]}-image" : "")
|
|
89
97
|
|
|
90
98
|
img_url = image_url(object, method_name, **options)
|
|
91
99
|
return image_tag(img_url, class: options[:class], width: options[:width], height: options[:height])
|
|
@@ -116,7 +124,7 @@ module ImageHelper
|
|
|
116
124
|
icon: "trash",
|
|
117
125
|
class: "btn btn-danger btn-block btn-only-hover btn-xs"
|
|
118
126
|
)
|
|
119
|
-
|
|
127
|
+
|
|
120
128
|
# Image HTML
|
|
121
129
|
image_tag = display_image(object, method_name, **options[:image_options])
|
|
122
130
|
|
|
@@ -130,7 +138,7 @@ module ImageHelper
|
|
|
130
138
|
image_object = object.send(assoc_name) if object.respond_to?(assoc_name)
|
|
131
139
|
if image_object && image_object.persisted?
|
|
132
140
|
remove_btn_display = raw(theme_fa_icon(options[:delete_options][:icon]) + theme_button_text(options[:delete_options][:text]))
|
|
133
|
-
remove_btn = link_to(remove_btn_display, delete_url, :class=>options[:delete_options][:class], :remote=>options[:delete_options][:remote])
|
|
141
|
+
remove_btn = link_to(remove_btn_display, delete_url, :class=>options[:delete_options][:class], :remote=>options[:delete_options][:remote], method: :delete)
|
|
134
142
|
end
|
|
135
143
|
|
|
136
144
|
link_to(image_tag, edit_url, :remote => options[:remote]) +
|
|
@@ -42,10 +42,10 @@ module KuppayamHelper
|
|
|
42
42
|
button_text: "Search!",
|
|
43
43
|
form_html: {
|
|
44
44
|
:class=>"pull-right",
|
|
45
|
-
:style=>"margin-bottom:0px;"},
|
|
45
|
+
:style=>"margin-bottom:0px;width:100%;"},
|
|
46
46
|
div_html: {:class=>"input-group"},
|
|
47
47
|
button_class: "btn btn-primary",
|
|
48
|
-
text_class: "btn-text"
|
|
48
|
+
text_class: "btn-text hidden-sm hidden-xs"
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
form_for cls.new,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
module NotificationHelper
|
|
2
|
-
|
|
3
|
-
# Example
|
|
4
|
-
# set_notification("Success", "The message has been sent successfully")
|
|
5
|
-
# set_notification("Success", "Permission denied")
|
|
6
|
-
|
|
2
|
+
|
|
7
3
|
def default_notification_configuration
|
|
8
4
|
{
|
|
9
5
|
success: false,
|
|
@@ -19,7 +15,11 @@ module NotificationHelper
|
|
|
19
15
|
@notification = default_notification_configuration
|
|
20
16
|
end
|
|
21
17
|
end
|
|
22
|
-
|
|
18
|
+
|
|
19
|
+
# This function will set a notification message depending up on the request type (ajax - xml http or direct http)
|
|
20
|
+
# Example
|
|
21
|
+
# set_notification("Success", "The message has been sent successfully")
|
|
22
|
+
# set_notification("Success", "Permission denied")
|
|
23
23
|
def set_notification(success, title, message)
|
|
24
24
|
@notification[:success] = success
|
|
25
25
|
@notification[:title] = title
|
|
@@ -7,6 +7,9 @@ module RenderHelper
|
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
# TODO - This is still not fixed.
|
|
11
|
+
# May be it will work on Ajax Request and show sign in pop up.
|
|
12
|
+
# This is not working for HTTP direct requests
|
|
10
13
|
def handle_invalid_authenticity_token
|
|
11
14
|
heading = I18n.t("status.invalid_token.heading")
|
|
12
15
|
message = I18n.t("status.invalid_token.message")
|
|
@@ -15,7 +18,10 @@ module RenderHelper
|
|
|
15
18
|
notifyError('#{heading}','#{message}');
|
|
16
19
|
eos
|
|
17
20
|
respond_to do |format|
|
|
18
|
-
format.html {
|
|
21
|
+
format.html {
|
|
22
|
+
#redirect_to root_path
|
|
23
|
+
render template: '/kuppayam/404', layout: 'kuppayam/blank', :status => 404
|
|
24
|
+
}
|
|
19
25
|
format.js { render text: js_message }
|
|
20
26
|
end
|
|
21
27
|
end
|
|
@@ -38,7 +44,10 @@ module RenderHelper
|
|
|
38
44
|
|
|
39
45
|
def render_accordingly
|
|
40
46
|
respond_to do |format|
|
|
41
|
-
format.html {
|
|
47
|
+
format.html {
|
|
48
|
+
get_collections
|
|
49
|
+
render :index
|
|
50
|
+
}
|
|
42
51
|
format.js {
|
|
43
52
|
view_path = @resource_options && @resource_options[:view_path] ? "#{@resource_options[:js_view_path]}/#{params[:action]}" : params[:action].to_sym
|
|
44
53
|
render view_path
|
|
@@ -49,7 +49,13 @@ module ResourceHelper
|
|
|
49
49
|
if @r_object
|
|
50
50
|
@r_object.assign_attributes(permitted_params)
|
|
51
51
|
instance_variable_set("@#{@resource_options[:item_name]}", @r_object)
|
|
52
|
-
|
|
52
|
+
if @r_object.can_be_edited?
|
|
53
|
+
save_resource
|
|
54
|
+
else
|
|
55
|
+
message = I18n.t('errors.failed_to_update', item: default_item_name.titleize)
|
|
56
|
+
set_flash_message(message, :failure)
|
|
57
|
+
set_notification(false, I18n.t('status.error'), message)
|
|
58
|
+
end
|
|
53
59
|
else
|
|
54
60
|
set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize))
|
|
55
61
|
end
|
|
@@ -57,14 +63,13 @@ module ResourceHelper
|
|
|
57
63
|
|
|
58
64
|
def destroy
|
|
59
65
|
@r_object = @resource_options[:class].find_by_id(params[:id])
|
|
60
|
-
|
|
61
66
|
if @r_object
|
|
62
67
|
instance_variable_set("@#{@resource_options[:item_name]}", @r_object)
|
|
63
68
|
if @r_object.can_be_deleted?
|
|
64
69
|
@r_object.destroy
|
|
65
70
|
get_collections
|
|
66
71
|
set_flash_message(I18n.t('success.deleted'), :success)
|
|
67
|
-
set_notification(
|
|
72
|
+
set_notification(true, I18n.t('status.success'), I18n.t('success.deleted', item: default_item_name.titleize))
|
|
68
73
|
@destroyed = true
|
|
69
74
|
else
|
|
70
75
|
message = I18n.t('errors.failed_to_delete', item: default_item_name.titleize)
|
|
@@ -90,12 +95,11 @@ module ResourceHelper
|
|
|
90
95
|
@r_object = @resource_options[:class].find_by_id(params[:id])
|
|
91
96
|
if @r_object
|
|
92
97
|
instance_variable_set("@#{@resource_options[:item_name]}", @r_object)
|
|
93
|
-
@r_object.status
|
|
94
|
-
if @r_object.
|
|
95
|
-
@r_object.save
|
|
98
|
+
@r_object.update_attribute(:status, params[:status])
|
|
99
|
+
if @r_object.errors.blank?
|
|
96
100
|
set_notification(true, I18n.t('status.success'), I18n.t('state.changed', item: default_item_name.titleize, new_state: @r_object.status))
|
|
97
101
|
else
|
|
98
|
-
set_notification(false, I18n.t('status.error'),
|
|
102
|
+
set_notification(false, I18n.t('status.error'), @r_object.errors.full_messages.join("<br>"))
|
|
99
103
|
end
|
|
100
104
|
else
|
|
101
105
|
set_notification(false, I18n.t('status.not_found'), I18n.t('status.not_found', item: default_item_name.titleize))
|
|
@@ -114,7 +118,11 @@ module ResourceHelper
|
|
|
114
118
|
end
|
|
115
119
|
|
|
116
120
|
def default_collection_name
|
|
117
|
-
|
|
121
|
+
begin
|
|
122
|
+
params[:controller].split("/").last
|
|
123
|
+
rescue
|
|
124
|
+
:items
|
|
125
|
+
end
|
|
118
126
|
end
|
|
119
127
|
|
|
120
128
|
def default_item_name
|
|
@@ -122,7 +130,11 @@ module ResourceHelper
|
|
|
122
130
|
end
|
|
123
131
|
|
|
124
132
|
def default_class
|
|
125
|
-
|
|
133
|
+
begin
|
|
134
|
+
default_collection_name.singularize.camelize.constantize
|
|
135
|
+
rescue
|
|
136
|
+
nil
|
|
137
|
+
end
|
|
126
138
|
end
|
|
127
139
|
|
|
128
140
|
def resource_controller_configuration
|
|
@@ -137,6 +149,8 @@ module ResourceHelper
|
|
|
137
149
|
item_name: default_item_name,
|
|
138
150
|
class: default_class,
|
|
139
151
|
layout: :table,
|
|
152
|
+
show_modal_after_create: true,
|
|
153
|
+
show_modal_after_update: true,
|
|
140
154
|
view_path: "/kuppayam/workflows/peacock",
|
|
141
155
|
js_view_path: "/kuppayam/workflows/peacock"
|
|
142
156
|
}
|