form_creation 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/form_creation/posts.js +3 -0
- data/app/assets/stylesheets/form_creation/posts.css +112 -0
- data/app/controllers/form_creation/posts_controller.rb +9 -3
- data/app/models/form_creation/post.rb +10 -0
- data/app/views/form_creation/posts/index.html.erb +36 -17
- data/app/views/layouts/form_creation/application.html.erb +3 -1
- data/config/application.rb +1 -0
- data/config/initializers/mime_types.rb +1 -0
- data/lib/form_creation/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b06fdb369df28541aad4f20f93dffc266d2ceadae3942978c8c86cc61c83ef41
|
4
|
+
data.tar.gz: 2b6011f7deb932168c67ab302ef7d0f66d799b029fa74e48d7896f19238ec22c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 863045755d45ed32d3cfc62e22e9b2fb31ffa931e9be3e2f7ed07b3f551c83f90b3dfda391ad2d1ded59767bb5c4b071ab0605a5e2daa80fdbbe902795566865
|
7
|
+
data.tar.gz: 77186d6cc0a423a0f66d2a2ea77814a39459d024a7c5bf5420f1fd6f91db616e39a2a352b5725b07794dff2bfc333beb997211850273653dc686365341be68f9
|
@@ -46,4 +46,116 @@
|
|
46
46
|
}
|
47
47
|
.save-btn {
|
48
48
|
width: 465px;
|
49
|
+
}
|
50
|
+
.btn {
|
51
|
+
text-decoration: none !important;
|
52
|
+
color: #fff !important;
|
53
|
+
background-color: #3378b7 !important;
|
54
|
+
text-align: center !important;
|
55
|
+
letter-spacing: .5px !important;
|
56
|
+
}
|
57
|
+
.btn-2 {
|
58
|
+
border: 1px solid transparent;
|
59
|
+
text-decoration: none !important;
|
60
|
+
color: #fff !important;
|
61
|
+
background-color: #3379b7 !important;
|
62
|
+
text-align: center !important;
|
63
|
+
letter-spacing: .5px !important;
|
64
|
+
}
|
65
|
+
.dataTables_filter input {
|
66
|
+
width: 300px;
|
67
|
+
height: 40px;
|
68
|
+
border-radius: 10px;
|
69
|
+
outline: none;
|
70
|
+
padding: 15px;
|
71
|
+
}
|
72
|
+
.dataTables_length select {
|
73
|
+
width: 70px;
|
74
|
+
height: calc(1.5em + .75rem + 2px);
|
75
|
+
padding: .375rem .75rem;
|
76
|
+
font-size: 1rem;
|
77
|
+
font-weight: 400;
|
78
|
+
line-height: 1.5;
|
79
|
+
color: #495057;
|
80
|
+
background-color: #fff;
|
81
|
+
background-clip: padding-box;
|
82
|
+
border: 1px solid #ced4da;
|
83
|
+
border-radius: .25rem;
|
84
|
+
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
|
85
|
+
}
|
86
|
+
.menu-nav {
|
87
|
+
height: 60px;
|
88
|
+
background-color: #ae99de;
|
89
|
+
}
|
90
|
+
footer {
|
91
|
+
background-color: #ae99de;
|
92
|
+
height: 45px;
|
93
|
+
color: #fff;
|
94
|
+
margin-top: 120px;
|
95
|
+
text-align: center;
|
96
|
+
padding-top: 8px;
|
97
|
+
}
|
98
|
+
.add-btn {
|
99
|
+
margin-bottom: 10px;
|
100
|
+
text-align: right;
|
101
|
+
margin-right: 22px;
|
102
|
+
margin-bottom: 20px;
|
103
|
+
}
|
104
|
+
.dataTables_filter label {
|
105
|
+
font-weight: bold;
|
106
|
+
}
|
107
|
+
.form-title {
|
108
|
+
color: #4a3a8e;
|
109
|
+
font-size: 40px;
|
110
|
+
margin-left: 40px;
|
111
|
+
font-weight: bold;
|
112
|
+
text-align: right;
|
113
|
+
position: relative;
|
114
|
+
right: 80px;
|
115
|
+
bottom: 62px;
|
116
|
+
}
|
117
|
+
.home {
|
118
|
+
text-align: left;
|
119
|
+
font-size: 40px;
|
120
|
+
margin-left: 80px;
|
121
|
+
}
|
122
|
+
.home a {
|
123
|
+
color: #fff;
|
124
|
+
}
|
125
|
+
.home a:hover {
|
126
|
+
color: #fff;
|
127
|
+
text-decoration: none;
|
128
|
+
}
|
129
|
+
.eye-color {
|
130
|
+
color: #3197f3;
|
131
|
+
margin-right: 10px;
|
132
|
+
}
|
133
|
+
.edit-color {
|
134
|
+
color: #f99a0b;
|
135
|
+
margin-right: 10px;
|
136
|
+
}
|
137
|
+
.delete-color {
|
138
|
+
color: #e72f36;
|
139
|
+
}
|
140
|
+
.eye-color:hover {
|
141
|
+
cursor: pointer;
|
142
|
+
}
|
143
|
+
.edit-color:hover {
|
144
|
+
cursor: pointer;
|
145
|
+
}
|
146
|
+
.delete-color:hover {
|
147
|
+
cursor: pointer;
|
148
|
+
}
|
149
|
+
#table_posts_length {
|
150
|
+
display: none;
|
151
|
+
}
|
152
|
+
.download-xls {
|
153
|
+
position: relative;
|
154
|
+
top: 40px;
|
155
|
+
width: auto;
|
156
|
+
float: left;
|
157
|
+
left: 0;
|
158
|
+
}
|
159
|
+
.dataTables_wrapper{
|
160
|
+
position: inherit !important;
|
49
161
|
}
|
@@ -1,10 +1,16 @@
|
|
1
1
|
require_dependency "form_creation/application_controller"
|
2
|
+
require 'csv'
|
2
3
|
|
3
4
|
module FormCreation
|
4
5
|
class PostsController < ApplicationController
|
5
6
|
def index
|
6
|
-
@posts = Post.order('id
|
7
|
-
@post = Post.new
|
7
|
+
@posts = Post.order('id ASC')
|
8
|
+
@post = Post.new
|
9
|
+
|
10
|
+
respond_to do |format|
|
11
|
+
format.html
|
12
|
+
format.xls { send_data @posts.to_csv(col_sep: "\t") }
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
# GET method to get a Post by id
|
@@ -63,4 +69,4 @@ module FormCreation
|
|
63
69
|
params.permit(:title, :description, :created_by)
|
64
70
|
end
|
65
71
|
end
|
66
|
-
end
|
72
|
+
end
|
@@ -3,5 +3,15 @@ module FormCreation
|
|
3
3
|
validates :title, presence: true
|
4
4
|
validates :description, presence: true
|
5
5
|
validates :created_by, presence: true
|
6
|
+
|
7
|
+
#Export xls sheet
|
8
|
+
def self.to_csv(options = {})
|
9
|
+
CSV.generate(options) do |csv|
|
10
|
+
csv << column_names
|
11
|
+
all.each do |post|
|
12
|
+
csv << post.attributes.values_at(*column_names)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
6
16
|
end
|
7
17
|
end
|
@@ -1,8 +1,18 @@
|
|
1
|
+
<div>
|
2
|
+
<nav class = 'navbar-fixed-top menu-nav'>
|
3
|
+
<div>
|
4
|
+
<div class="home">
|
5
|
+
<%= link_to "<i class=\"fa fa-home\"></i><span style=\"font-size: 17px;font-weight: bold;\">HOME</span>".html_safe, posts_path %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
</nav>
|
9
|
+
</div>
|
1
10
|
<!-- display all posts -->
|
2
11
|
<div class="container" style="margin-top: 70px;">
|
3
|
-
<
|
4
|
-
|
5
|
-
|
12
|
+
<div>
|
13
|
+
<div class="add-btn">
|
14
|
+
<%= button_tag "Create New Post <span class=\"fa fa-plus\"></span>".html_safe, class: "btn-2 btn-default btn-sm", "data-toggle" => "modal", "data-target" => "#add_post" %>
|
15
|
+
</div>
|
6
16
|
<div class="modal fade" id="add_post" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
7
17
|
<div class="modal-dialog" role="document">
|
8
18
|
<div class="modal-content post-content">
|
@@ -16,17 +26,22 @@
|
|
16
26
|
<%= render :partial => "form", :locals => {:f => f} %>
|
17
27
|
</div>
|
18
28
|
<div class="save">
|
19
|
-
<%= f.submit 'Create Post', class: "btn btn-
|
29
|
+
<%= f.submit 'Create Post', class: "btn btn-default save-btn", id: "sub" %>
|
20
30
|
</div>
|
21
31
|
<% end %>
|
22
32
|
</div>
|
23
33
|
</div>
|
24
34
|
</div>
|
25
35
|
</div>
|
26
|
-
</div>
|
27
|
-
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<table class="table table-striped" id="table_posts">
|
39
|
+
<div class="download-xls">
|
40
|
+
<%= link_to "Download Excel Sheet", posts_path(format: "xls"), class: "btn" %>
|
41
|
+
</div>
|
28
42
|
<thead>
|
29
43
|
<tr>
|
44
|
+
<th>id</th>
|
30
45
|
<th>Title</th>
|
31
46
|
<th>Description</th>
|
32
47
|
<th>Created By</th>
|
@@ -36,11 +51,12 @@
|
|
36
51
|
<tbody>
|
37
52
|
<% @posts.each do |p| %>
|
38
53
|
<tr>
|
54
|
+
<td><%= p.id %></td>
|
39
55
|
<td><%= p.title %></td>
|
40
56
|
<td><%= p.description %></td>
|
41
57
|
<td><%= p.created_by %></td>
|
42
58
|
<td>
|
43
|
-
|
59
|
+
<span class="fa fa-eye eye-color" data-toggle="modal" data-target="#show_post-<%= p.id %>"></span>
|
44
60
|
<div class="modal fade" id="show_post-<%= p.id %>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
45
61
|
<div class="modal-dialog" role="document">
|
46
62
|
<div class="modal-content">
|
@@ -63,12 +79,12 @@
|
|
63
79
|
</div>
|
64
80
|
</div>
|
65
81
|
<div class="modal-footer">
|
66
|
-
<%= button_tag "Close", class: "btn btn-
|
82
|
+
<%= button_tag "Close", class: "btn btn-default", "data-dismiss" => "modal" %>
|
67
83
|
</div>
|
68
84
|
</div>
|
69
85
|
</div>
|
70
86
|
</div>
|
71
|
-
|
87
|
+
<span class="fa fa-edit edit-color" data-toggle="modal" data-target="#edit_post-<%= p.id %>"></span>
|
72
88
|
<div class="modal fade edit_post-form" id="edit_post-<%= p.id %>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
73
89
|
<div class="modal-dialog" role="document">
|
74
90
|
<div class="modal-content post-content">
|
@@ -82,15 +98,15 @@
|
|
82
98
|
<%= render :partial => "form", :locals => {:f => f} %>
|
83
99
|
</div>
|
84
100
|
<div class="save">
|
85
|
-
<%= f.submit 'Update Post', class: "btn btn-
|
101
|
+
<%= f.submit 'Update Post', class: "btn btn-default save-btn", id: "sub" %>
|
86
102
|
</div>
|
87
103
|
<% end %>
|
88
104
|
</div>
|
89
105
|
</div>
|
90
106
|
</div>
|
91
107
|
</div>
|
92
|
-
|
93
|
-
<div class="modal fade" id="
|
108
|
+
<span class="fa fa-trash delete-color" data-toggle="modal" data-target="#delete_post-<%= p.id %>"></span>
|
109
|
+
<div class="modal fade" id="delete_post-<%= p.id %>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
94
110
|
<div class="modal-dialog" role="document">
|
95
111
|
<div class="modal-content">
|
96
112
|
<div class="modal-header">
|
@@ -101,14 +117,17 @@
|
|
101
117
|
Are you sure?
|
102
118
|
</div>
|
103
119
|
<div class="modal-footer">
|
104
|
-
<%= button_tag "Close", class: "btn btn-
|
105
|
-
<%= link_to 'Delete', post_path(p), method: :delete, class: "btn btn-
|
120
|
+
<%= button_tag "Close", class: "btn btn-default", "data-dismiss" => "modal" %>
|
121
|
+
<%= link_to 'Delete', post_path(p), method: :delete, class: "btn btn-default" %>
|
106
122
|
</div>
|
107
123
|
</div>
|
108
124
|
</div>
|
109
125
|
</div>
|
110
126
|
</tr>
|
111
127
|
<% end %>
|
112
|
-
|
113
|
-
</table>
|
114
|
-
</div>
|
128
|
+
</tbody>
|
129
|
+
</table>
|
130
|
+
</div>
|
131
|
+
<footer>
|
132
|
+
<div>@copyrights 2019</div>
|
133
|
+
</footer>
|
@@ -13,7 +13,9 @@
|
|
13
13
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
14
14
|
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
|
15
15
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
|
16
|
-
|
16
|
+
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
|
17
|
+
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
|
18
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
17
19
|
</head>
|
18
20
|
<body>
|
19
21
|
<%= yield %>
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'csv'
|
@@ -0,0 +1 @@
|
|
1
|
+
Mime::Type.register "application/xls", :xls
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form_creation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- madhubabu-nyros
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -90,6 +90,8 @@ files:
|
|
90
90
|
- app/views/form_creation/posts/show.html.erb
|
91
91
|
- app/views/form_creation/posts/update.html.erb
|
92
92
|
- app/views/layouts/form_creation/application.html.erb
|
93
|
+
- config/application.rb
|
94
|
+
- config/initializers/mime_types.rb
|
93
95
|
- config/routes.rb
|
94
96
|
- db/migrate/20191014040009_create_form_creation_posts.rb
|
95
97
|
- lib/form_creation.rb
|