form_creation 0.1.5 → 0.1.6
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/app/assets/javascripts/form_creation/posts.js +75 -26
- data/app/assets/stylesheets/form_creation/posts.css +24 -5
- data/app/controllers/form_creation/posts_controller.rb +2 -1
- data/app/models/form_creation/post.rb +3 -3
- data/app/views/form_creation/posts/_form.html.erb +12 -0
- data/app/views/form_creation/posts/edit.html.erb +5 -4
- data/app/views/form_creation/posts/index.html.erb +76 -12
- data/app/views/form_creation/posts/new.html.erb +1 -0
- data/app/views/form_creation/posts/show.html.erb +13 -12
- data/app/views/layouts/form_creation/application.html.erb +5 -7
- data/config/routes.rb +1 -0
- data/lib/form_creation/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66f198cf5b06375c2efe46483a4a34c8c09301908403e17f58e447650acf7e70
|
|
4
|
+
data.tar.gz: 86e4f431ee40a4227aaa964e6a7f873887c629bf9e8202949d482b87cc40ee77
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 897a48d113e90c7a1767de91cc74bc59ae2cb0f6c4d88466b98800a217b15e36ff84e99c444bd60ef3ddd7a1f9b5cbc48cf0644747b0677e663c50e4b0139295
|
|
7
|
+
data.tar.gz: 5ea2455fb874ad63fb634c4aa522f5923c6a13d61afc751a3c383c69e71756a26a5e5f2c373ebd83cd5bda3d9021c00d672bbfbb77c49a28d4fea4c24525dca9
|
|
@@ -1,29 +1,78 @@
|
|
|
1
1
|
// Place all the behaviors and hooks related to the matching controller here.
|
|
2
2
|
// All this logic will automatically be available in application.js.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
$(document).ready(function() {
|
|
4
|
+
// validations for new post
|
|
5
|
+
$("#new_post").validate({
|
|
6
|
+
rules: {
|
|
7
|
+
title: {
|
|
8
|
+
required: true,
|
|
9
|
+
maxlength: 30
|
|
10
|
+
},
|
|
11
|
+
description: "required",
|
|
12
|
+
created_by: {
|
|
13
|
+
required: true,
|
|
14
|
+
maxlength: 30
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
messages: {
|
|
18
|
+
title: {
|
|
19
|
+
required: "Please enter title",
|
|
20
|
+
maxlength: "Please enter no more than 30 characters."
|
|
21
|
+
},
|
|
22
|
+
description: "Please enter description",
|
|
23
|
+
created_by: {
|
|
24
|
+
required: "Please enter created_by",
|
|
25
|
+
maxlength: "Please enter no more than 30 characters."
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
// validations for edit post
|
|
30
|
+
$(".edit_post").validate({
|
|
31
|
+
rules: {
|
|
32
|
+
title: {
|
|
33
|
+
required: true,
|
|
34
|
+
maxlength: 30
|
|
35
|
+
},
|
|
36
|
+
description: "required",
|
|
37
|
+
created_by: {
|
|
38
|
+
required: true,
|
|
39
|
+
maxlength: 30
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
messages: {
|
|
43
|
+
title: {
|
|
44
|
+
required: "Please enter title",
|
|
45
|
+
maxlength: "Please enter no more than 30 characters."
|
|
46
|
+
},
|
|
47
|
+
description: "Please enter description",
|
|
48
|
+
created_by: {
|
|
49
|
+
required: "Please enter created_by",
|
|
50
|
+
maxlength: "Please enter no more than 30 characters."
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
// Reset modal new form
|
|
55
|
+
$(".close").click(function() {
|
|
56
|
+
$("#new_post")[0].reset();
|
|
57
|
+
var validator = $("#new_post").validate();
|
|
58
|
+
validator.resetForm();
|
|
59
|
+
});
|
|
60
|
+
// Reset modal edit form
|
|
61
|
+
$(".edit_close").click(function() {
|
|
62
|
+
$(".edit_post")[0].reset();
|
|
63
|
+
var validator = $(".edit_post").validate();
|
|
64
|
+
validator.resetForm();
|
|
65
|
+
});
|
|
66
|
+
// when click on body, reset modal new form
|
|
67
|
+
$('#add_post').on('hidden.bs.modal', function() {
|
|
68
|
+
$("#new_post")[0].reset();
|
|
69
|
+
var validator = $("#new_post").validate();
|
|
70
|
+
validator.resetForm();
|
|
71
|
+
});
|
|
72
|
+
// when click on body, reset modal edit form
|
|
73
|
+
$('.edit_post-form').on('hidden.bs.modal', function() {
|
|
74
|
+
$(".edit_post")[0].reset();
|
|
75
|
+
var validator = $(".edit_post").validate();
|
|
76
|
+
validator.resetForm();
|
|
77
|
+
});
|
|
29
78
|
});
|
|
@@ -10,21 +10,40 @@
|
|
|
10
10
|
border-radius: 3px;
|
|
11
11
|
}
|
|
12
12
|
.post-1 {
|
|
13
|
-
width:
|
|
13
|
+
width: 500px !important;
|
|
14
14
|
margin: 70px auto !important;
|
|
15
15
|
border: 1px solid #ccc;
|
|
16
16
|
padding: 32px;
|
|
17
17
|
border-radius: 3px;
|
|
18
|
-
box-shadow:
|
|
18
|
+
box-shadow: 10px 10px 13px #ccc;
|
|
19
19
|
background-color: #f9f8f8;
|
|
20
20
|
}
|
|
21
21
|
.error {
|
|
22
22
|
color: red;
|
|
23
23
|
font-size: 14px;
|
|
24
24
|
}
|
|
25
|
-
.fade:not(.show) {
|
|
26
|
-
opacity: 0.8 !important;
|
|
27
|
-
}
|
|
28
25
|
.modal-content {
|
|
29
26
|
margin-top: 145px;
|
|
30
27
|
}
|
|
28
|
+
.post-details {
|
|
29
|
+
color: #c56b6b;
|
|
30
|
+
text-align: left;
|
|
31
|
+
}
|
|
32
|
+
.post-col {
|
|
33
|
+
float: left !important;
|
|
34
|
+
}
|
|
35
|
+
.back-btn {
|
|
36
|
+
text-align: center;
|
|
37
|
+
margin-top: 20px;
|
|
38
|
+
clear: both;
|
|
39
|
+
}
|
|
40
|
+
.post-content {
|
|
41
|
+
margin-top: 0px !important;
|
|
42
|
+
}
|
|
43
|
+
.save {
|
|
44
|
+
margin-top: 10px;
|
|
45
|
+
margin-bottom: 30px;
|
|
46
|
+
}
|
|
47
|
+
.save-btn {
|
|
48
|
+
width: 465px;
|
|
49
|
+
}
|
|
@@ -3,7 +3,8 @@ require_dependency "form_creation/application_controller"
|
|
|
3
3
|
module FormCreation
|
|
4
4
|
class PostsController < ApplicationController
|
|
5
5
|
def index
|
|
6
|
-
@posts = Post.order('id DESC')
|
|
6
|
+
@posts = Post.order('id DESC')
|
|
7
|
+
@post = Post.new
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
# GET method to get a Post by id
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module FormCreation
|
|
2
2
|
class Post < ApplicationRecord
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
validates :title, presence: true
|
|
4
|
+
validates :description, presence: true
|
|
5
|
+
validates :created_by, presence: true
|
|
6
6
|
end
|
|
7
7
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<div class="form-group">
|
|
2
|
+
<label>Title</label>
|
|
3
|
+
<%= f.text_field :title, class: "form-control", name: "title" %>
|
|
4
|
+
</div>
|
|
5
|
+
<div class="form-group">
|
|
6
|
+
<label>Description</label>
|
|
7
|
+
<%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;", name: 'description' %>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="form-group">
|
|
10
|
+
<label>Created By</label>
|
|
11
|
+
<%= f.text_field :created_by, class: "form-control", name: "created_by" %>
|
|
12
|
+
</div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- Edit post form -->
|
|
1
2
|
<div class="container post">
|
|
2
3
|
<%= form_for @post, url: {action: :update} do |f| %>
|
|
3
4
|
<div>
|
|
@@ -7,12 +8,12 @@
|
|
|
7
8
|
<p>
|
|
8
9
|
<%= "<div>#{@post.errors.full_messages.first}</div>".html_safe if @post.errors.any? %>
|
|
9
10
|
<div class="form-group">
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
<label>Title</label>
|
|
12
|
+
<%= f.text_field :title, class: "form-control", name: "title" %>
|
|
12
13
|
</div>
|
|
13
14
|
<div class="form-group">
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
<label>Description</label>
|
|
16
|
+
<%= f.text_area :description, class: "form-control", rows: "5", cols: "10", style: "resize:none;", name: 'description' %>
|
|
16
17
|
</div>
|
|
17
18
|
<div class="form-group">
|
|
18
19
|
<label>Created By</label>
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
+
<!-- display all posts -->
|
|
1
2
|
<div class="container" style="margin-top: 70px;">
|
|
2
3
|
<h3>Posts</h3>
|
|
3
4
|
<div style="margin-bottom: 10px;">
|
|
4
|
-
<%=
|
|
5
|
+
<%= button_tag "Add <span class=\"fa fa-plus\"></span>".html_safe, class: "btn btn-success btn-sm", "data-toggle" => "modal", "data-target" => "#add_post" %>
|
|
6
|
+
<div class="modal fade" id="add_post" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
7
|
+
<div class="modal-dialog" role="document">
|
|
8
|
+
<div class="modal-content post-content">
|
|
9
|
+
<div class="modal-header">
|
|
10
|
+
<h3 class="post-details modal-title" id="exampleModalLabel">Add Post</h3>
|
|
11
|
+
<%= button_tag "<span aria-hidden=\"true\">×</span>".html_safe, class: "close close-2", "data-dismiss" => "modal", "aria-label" => "Close" %>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="modal-body">
|
|
14
|
+
<%= form_for @post, url: {action: :create} do |f| %>
|
|
15
|
+
<div>
|
|
16
|
+
<%= render :partial => "form", :locals => {:f => f} %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="save">
|
|
19
|
+
<%= f.submit 'Create Post', class: "btn btn-primary save-btn", id: "sub" %>
|
|
20
|
+
</div>
|
|
21
|
+
<% end %>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
5
26
|
</div>
|
|
6
27
|
<table class="table table-striped">
|
|
7
28
|
<thead>
|
|
@@ -19,25 +40,68 @@
|
|
|
19
40
|
<td><%= p.description %></td>
|
|
20
41
|
<td><%= p.created_by %></td>
|
|
21
42
|
<td>
|
|
22
|
-
<%=
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
<%= button_tag "<span class=\"fa fa-eye\"></span>".html_safe, class: "btn btn-info btn-sm", "data-toggle" => "modal", "data-target" => "#show_post-#{p.id}" %>
|
|
44
|
+
<div class="modal fade" id="show_post-<%= p.id %>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
45
|
+
<div class="modal-dialog" role="document">
|
|
46
|
+
<div class="modal-content">
|
|
47
|
+
<div class="modal-header">
|
|
48
|
+
<h3 class="post-details modal-title" id="exampleModalLabel">Post Details</h3>
|
|
49
|
+
<%= button_tag "<span aria-hidden=\"true\">×</span>".html_safe, class: "close close-2", "data-dismiss" => "modal", "aria-label" => "Close" %>
|
|
50
|
+
</div>
|
|
51
|
+
<div class="modal-body">
|
|
52
|
+
<div class="row">
|
|
53
|
+
<div class="col-md-4 "><b>Title:</b></div>
|
|
54
|
+
<div class="col-md-8"><%= p.title %></div>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="row">
|
|
57
|
+
<div class="col-md-4 "><b>Description:</b></div>
|
|
58
|
+
<div class="col-md-8 "><%= p.description %></div>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="row">
|
|
61
|
+
<div class="col-md-4 "><b>Created By:</b></div>
|
|
62
|
+
<div class="col-md-8"><%= p.created_by %></div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div class="modal-footer">
|
|
66
|
+
<%= button_tag "Close", class: "btn btn-secondary", "data-dismiss" => "modal" %>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
<%= button_tag "<span class=\"fa fa-edit\"></span>".html_safe, class: "btn btn-warning btn-sm", "data-toggle" => "modal", "data-target" => "#edit_post-#{p.id}" %>
|
|
72
|
+
<div class="modal fade edit_post-form" id="edit_post-<%= p.id %>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
73
|
+
<div class="modal-dialog" role="document">
|
|
74
|
+
<div class="modal-content post-content">
|
|
75
|
+
<div class="modal-header">
|
|
76
|
+
<h3 class="post-details modal-title" id="exampleModalLabel">Update Post</h3>
|
|
77
|
+
<%= button_tag "<span aria-hidden=\"true\">×</span>".html_safe, class: "close edit_close", "data-dismiss" => "modal", "aria-label" => "Close" %>
|
|
78
|
+
</div>
|
|
79
|
+
<div class="modal-body">
|
|
80
|
+
<%= form_for p, url: post_path(p), method: :put do |f| %>
|
|
81
|
+
<div>
|
|
82
|
+
<%= render :partial => "form", :locals => {:f => f} %>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="save">
|
|
85
|
+
<%= f.submit 'Update Post', class: "btn btn-primary save-btn", id: "sub" %>
|
|
86
|
+
</div>
|
|
87
|
+
<% end %>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
<%= button_tag "<span class=\"fa fa-trash\"></span>".html_safe, class: "btn btn-danger btn-sm", "data-toggle" => "modal", "data-target" => "#post-#{p.id}" %>
|
|
27
93
|
<div class="modal fade" id="post-<%= p.id %>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
28
94
|
<div class="modal-dialog" role="document">
|
|
29
95
|
<div class="modal-content">
|
|
30
96
|
<div class="modal-header">
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
<span aria-hidden="true">×</span>
|
|
34
|
-
</button>
|
|
97
|
+
<h3 class="modal-title" id="exampleModalLabel">Delete</h3>
|
|
98
|
+
<%= button_tag "<span aria-hidden=\"true\">×</span>".html_safe, class: "close close-2", "data-dismiss" => "modal", "aria-label" => "Close" %>
|
|
35
99
|
</div>
|
|
36
100
|
<div class="modal-body">
|
|
37
101
|
Are you sure?
|
|
38
102
|
</div>
|
|
39
103
|
<div class="modal-footer">
|
|
40
|
-
|
|
104
|
+
<%= button_tag "Close", class: "btn btn-secondary", "data-dismiss" => "modal" %>
|
|
41
105
|
<%= link_to 'Delete', post_path(p), method: :delete, class: "btn btn-danger" %>
|
|
42
106
|
</div>
|
|
43
107
|
</div>
|
|
@@ -47,4 +111,4 @@
|
|
|
47
111
|
<% end %>
|
|
48
112
|
</tbody>
|
|
49
113
|
</table>
|
|
50
|
-
</div>
|
|
114
|
+
</div>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
<!-- Show post based on user id -->
|
|
1
2
|
<div class="container post-1">
|
|
2
|
-
<h3>Post Details</h3>
|
|
3
|
-
<div>
|
|
4
|
-
<
|
|
5
|
-
|
|
3
|
+
<h3 class="post-details">Post Details</h3>
|
|
4
|
+
<div class="row">
|
|
5
|
+
<div class="col-md-4 "><b>Title:</b></div>
|
|
6
|
+
<div class="col-md-8"><%= @post.title %></div>
|
|
6
7
|
</div>
|
|
7
|
-
<div>
|
|
8
|
-
<
|
|
9
|
-
|
|
8
|
+
<div class="row">
|
|
9
|
+
<div class="col-md-4 "><b>Description:</b></div>
|
|
10
|
+
<div class="col-md-8 "><%= @post.description %></div>
|
|
10
11
|
</div>
|
|
11
|
-
<div>
|
|
12
|
-
<
|
|
13
|
-
|
|
12
|
+
<div class="row">
|
|
13
|
+
<div class="col-md-4 "><b>Created By:</b></div>
|
|
14
|
+
<div class="col-md-8"><%= @post.created_by %></div>
|
|
14
15
|
</div>
|
|
15
|
-
<div
|
|
16
|
+
<div class="back-btn">
|
|
16
17
|
<%= link_to 'Back', posts_path, class: "btn btn-info" %>
|
|
17
18
|
</div>
|
|
18
|
-
</div>
|
|
19
|
+
</div>
|
|
@@ -7,17 +7,15 @@
|
|
|
7
7
|
<%= stylesheet_link_tag "form_creation/application", media: "all" %>
|
|
8
8
|
<%= javascript_include_tag "form_creation/application" %>
|
|
9
9
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
|
10
|
-
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.1/jquery.validate.min.js"></script>
|
|
11
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
|
|
12
|
-
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> -->
|
|
13
10
|
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
|
|
14
11
|
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
|
|
15
12
|
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
|
|
16
|
-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.
|
|
13
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
|
14
|
+
<script src='https://kit.fontawesome.com/a076d05399.js'></script>
|
|
15
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
|
|
16
|
+
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
|
-
|
|
20
|
-
<%= yield %>
|
|
21
|
-
|
|
19
|
+
<%= yield %>
|
|
22
20
|
</body>
|
|
23
21
|
</html>
|
data/config/routes.rb
CHANGED
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.6
|
|
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-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- app/mailers/form_creation/application_mailer.rb
|
|
82
82
|
- app/models/form_creation/application_record.rb
|
|
83
83
|
- app/models/form_creation/post.rb
|
|
84
|
+
- app/views/form_creation/posts/_form.html.erb
|
|
84
85
|
- app/views/form_creation/posts/create.html.erb
|
|
85
86
|
- app/views/form_creation/posts/destroy.html.erb
|
|
86
87
|
- app/views/form_creation/posts/edit.html.erb
|