phcdevworks_tutorials 1.2.0 → 1.2.5

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
  SHA256:
3
- metadata.gz: 6fb02f5f552818db1a3870f7fe9ca6b51b667d24d44a7ef920024e757c04593f
4
- data.tar.gz: 35fdd2b2e952c22ec951db3ef331a3ec64378eee415ac476640c6de85931cd7c
3
+ metadata.gz: 3d32d9df3aa7d8e9298f25416c9fc115b1734fa3830ef6a9c4ee7918d1501d80
4
+ data.tar.gz: 18dcdb6180462edf1100626b8f40c7405033d4159df62962b22993a1f842fda9
5
5
  SHA512:
6
- metadata.gz: 1abce4457ca8938d0746020cbc7090288baf7d0d281103b9958dbddd0f4c10c7cf98fc53adf90c35365a89ac338ca4aaa5ab5c5a6b3fbe16dd6e79860ab8c6f1
7
- data.tar.gz: a0601147138c7b06999164810be638ee90f1a952da1602c27443881cf33e85f6f367039b956ab6697ac6b89428d305b253d600e7caf8a07b8df9a1a09cf91c85
6
+ metadata.gz: f0731f199c9c95af142ed37ac488b98e6c6cf2ecd8e85818ae6868018b5edbade8d8961c5bf39ac8a62fc8df6193ecd46941bec0270eb1df7564daaef7cdea02
7
+ data.tar.gz: 9a72615547581a12636bd835cd6197ad65637bf8a653095e188fb7a23522889837cbe9f901f9b0bc6af2e97a4dbd03e38dd225cb3eee3ed15db25f7015aa9df9
@@ -75,7 +75,7 @@ module PhcdevworksTutorials
75
75
 
76
76
  # Whitelist
77
77
  def tutorial_post_params
78
- params.require(:tutorial_post).permit(:tutorial_post_step, :tutorial_post_title, :tutorial_post_text,:tutorial_post_description, :tutorial_post_status, :tutorial_post_image, :category_id, :slug, :user_id, :org_id)
78
+ params.require(:tutorial_post).permit(:tutorial_post_step, :tutorial_post_title, :tutorial_post_text,:tutorial_post_description, :tutorial_post_status, :tutorial_post_image, :slug, :user_id, :org_id, category_ids: [])
79
79
  end
80
80
 
81
81
  end
@@ -88,7 +88,7 @@ module PhcdevworksTutorials
88
88
 
89
89
  # Whitelist
90
90
  def tutorial_step_params
91
- params.require(:tutorial_step).permit(:steps_number, :steps_body, :tutorial_step_image, :post_id, :slug, :user_id, :org_id)
91
+ params.require(:tutorial_step).permit(:tutorial_step_number, :tutorial_step_body, :tutorial_step_image, :post_id, :slug, :user_id, :org_id)
92
92
  end
93
93
 
94
94
  end
@@ -5,7 +5,7 @@ module PhcdevworksTutorials
5
5
  extend FriendlyId
6
6
 
7
7
  #Relationships
8
- has_many :posts, class_name: 'PhcdevworksTutorials::Tutorial::Post'
8
+ has_and_belongs_to_many :posts, class_name: 'Tutorial::Post', :join_table => 'categories_posts', :dependent => :destroy
9
9
 
10
10
  # Form Fields Validation
11
11
  validates :tutorial_category_name,
@@ -5,16 +5,20 @@ module PhcdevworksTutorials
5
5
  extend FriendlyId
6
6
 
7
7
  # Image Upload
8
- has_one_attached :tutorial_post_images
8
+ has_one_attached :tutorial_post_image
9
9
 
10
10
  # Relationships
11
- belongs_to :category, class_name: 'PhcdevworksTutorials::Tutorial::Category'
12
- has_many :steps, class_name: "PhcdevworksTutorials::Tutorial::Step"
11
+ has_and_belongs_to_many :categories, class_name: "Tutorial::Category", :join_table => "categories_posts", :dependent => :destroy
12
+ has_many :steps, class_name: "Tutorial::Step"
13
+ belongs_to :user, class_name: "PhcdevworksAccounts::User"
13
14
 
14
15
  # Form Fields Validation
15
16
  validates :tutorial_post_title,
16
17
  presence: true
17
18
 
19
+ validates :tutorial_post_description,
20
+ presence: true
21
+
18
22
  # Clean URL Define
19
23
  friendly_id :phcdev_tutorials_post_nice_urls, use: [:slugged, :finders]
20
24
 
@@ -2,10 +2,12 @@ module PhcdevworksTutorials
2
2
  class Tutorial::Step < ApplicationRecord
3
3
 
4
4
  # Image Upload
5
- has_one_attached :tutorial_step_images
5
+ has_one_attached :tutorial_step_image
6
6
 
7
7
  # Relationships
8
8
  belongs_to :post, class_name: "PhcdevworksTutorials::Tutorial::Post"
9
+ has_many :categories, class_name: "Tutorial::Category", :through => :post
10
+ belongs_to :user, class_name: "PhcdevworksAccounts::User"
9
11
 
10
12
  end
11
13
  end
@@ -32,7 +32,12 @@
32
32
 
33
33
  <div class="form-group field_with_errors">
34
34
  <label>Select a Category</label>
35
- <%= form.collection_select :category_id, PhcdevworksTutorials::Tutorial::Category.order(:tutorial_category_name),:id, :tutorial_category_name, {}, {class: "form-control"} %>
35
+ <div class="panel-body">
36
+ <%= form.collection_check_boxes :category_ids, PhcdevworksTutorials::Tutorial::Category.order(:tutorial_category_name), :id, :tutorial_category_name do |post_category| %>
37
+ <%= post_category.check_box %>
38
+ <%= post_category.label %><br>
39
+ <% end %>
40
+ </div>
36
41
  </div>
37
42
  <!-- Form Input Fields -->
38
43
 
@@ -37,7 +37,8 @@
37
37
  <thead>
38
38
  <tr>
39
39
  <th>Tutorial Title</th>
40
- <th>Tutorial Category</th>
40
+ <th>Tutorial Description</th>
41
+ <th>Tutorial Status</th>
41
42
  <th></th>
42
43
  </tr>
43
44
  </thead>
@@ -46,7 +47,8 @@
46
47
  <% @tutorial_posts.each do |tutorial_post| %>
47
48
  <tr>
48
49
  <td><%= tutorial_post.tutorial_post_title %></td>
49
- <td><%= tutorial_post.category.tutorial_category_name %></td>
50
+ <td><%= tutorial_post.tutorial_post_description %></td>
51
+ <td><%= tutorial_post.tutorial_post_status %></td>
50
52
  <td>
51
53
  <div class="btn-group d-flex" role="group">
52
54
  <%= link_to "Details", tutorial_post, class: "btn btn-purple btn-xs" %>
@@ -10,11 +10,26 @@
10
10
  <%= form.select( :tutorial_step_number, [["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"]], {}, {class: "form-control"}) %>
11
11
  </div>
12
12
 
13
+ <div class="form-group field_with_errors">
14
+ <%= form.label :tutorial_step_title, "Step Title" %>
15
+ <%= form.text_area :tutorial_step_title, class: "form-control", rows: "10" %>
16
+ </div>
17
+
13
18
  <div class="form-group field_with_errors">
14
19
  <%= form.label :tutorial_step_body, "Step Text" %>
15
20
  <%= form.text_area :tutorial_step_body, class: "form-control", rows: "10" %>
16
21
  </div>
17
22
 
23
+ <div class="form-group field_with_errors">
24
+ <div class="form-group field_with_errors">
25
+ <%= form.label :tutorial_step_image, "Step Image" %>
26
+ <%= form.file_field :tutorial_step_image, class: "form-control" %>
27
+ </div>
28
+ <% if form.object.tutorial_step_image.attached? %>
29
+ <%= image_tag main_app.url_for(form.object.tutorial_step_image), class: "img-responsive img-thumbnail" %>
30
+ <% end %>
31
+ </div>
32
+
18
33
  <div class="form-group field_with_errors">
19
34
  <div class="form-group field_with_errors">
20
35
  <%= form.label :tutorial_step_image, "Step Image" %>
@@ -7,8 +7,8 @@
7
7
 
8
8
  <!-- Page Bradcrumbs -->
9
9
  <ol class="breadcrumb pull-right">
10
- <li class="breadcrumb-item"><%= yield(:phc_breadcrumb_one) %></li>
11
- <li class="breadcrumb-item active"><%= yield(:phc_breadcrumb_two) %></li>
10
+ <li class="breadcrumb-item"><%= yield(:phc_breadcrumb_one) %></li>
11
+ <li class="breadcrumb-item active"><%= yield(:phc_breadcrumb_two) %></li>
12
12
  </ol>
13
13
  <!-- Page Bradcrumbs -->
14
14
 
@@ -18,50 +18,60 @@
18
18
 
19
19
  <!-- Page & Panel Content -->
20
20
  <div class="panel panel-inverse">
21
- <!-- Panel Heading -->
22
- <div class="panel-heading">
23
- <div class="panel-heading-btn">
24
- <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
25
- <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-redo"></i></a>
26
- <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
21
+
22
+ <!-- Panel Heading -->
23
+ <div class="panel-heading">
24
+ <div class="panel-heading-btn">
25
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-default" data-click="panel-expand"><i class="fa fa-expand"></i></a>
26
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-success" data-click="panel-reload"><i class="fa fa-redo"></i></a>
27
+ <a href="javascript:;" class="btn btn-xs btn-icon btn-circle btn-warning" data-click="panel-collapse"><i class="fa fa-minus"></i></a>
28
+ </div>
29
+ <h4 class="panel-title"><%= yield(:phc_title_tagline) %></h4>
27
30
  </div>
28
- <h4 class="panel-title"><%= yield(:phc_title_tagline) %></h4>
29
- </div>
30
- <!-- Panel Heading -->
31
- <!-- Panel Body -->
32
- <div class="panel-body">
33
- <!-- Table - Snippet Index -->
34
- <div class="table-responsive">
35
- <table class="table table-striped table-bordered">
31
+ <!-- Panel Heading -->
32
+
33
+ <!-- Panel Body -->
34
+ <div class="panel-body">
35
+
36
+ <!-- Table - Snippet Index -->
37
+ <div class="table-responsive">
38
+ <table class="table table-striped table-bordered">
36
39
 
37
- <thead>
38
- <tr>
39
- <th>Tutorial Step Number</th>
40
- <th>Tutorial Step Body</th>
41
- <th></th>
42
- </tr>
43
- </thead>
40
+ <thead>
41
+ <tr>
42
+ <th>Tutorial Step Number</th>
43
+ <th>Tutorial Step Title</th>
44
+ <th></th>
45
+ </tr>
46
+ </thead>
44
47
 
45
- <tbody>
46
- <% @tutorial_steps.each do |tutorial_step| %>
47
- <tr>
48
- <td><%= tutorial_step.tutorial_step_number %></td>
49
- <td><%= tutorial_step.tutorial_step_body %></td>
50
- <td><%= link_to 'Show', tutorial_post_step_path(tutorial_step.post, tutorial_step) %></td>
51
- <td><%= link_to 'Edit', edit_tutorial_post_step_path(tutorial_step.post, tutorial_step) %></td>
52
- <td><%= link_to 'Destroy', tutorial_post_step_path(tutorial_step.post, tutorial_step), method: :delete, data: { confirm: 'Are you sure?' } %></td>
53
- </tr>
54
- <% end %>
55
- </tbody>
48
+ <tbody>
49
+ <% @tutorial_steps.each do |tutorial_step| %>
50
+ <tr>
51
+ <td><%= tutorial_step.tutorial_step_number %></td>
52
+ <td><%= tutorial_step.tutorial_step_title %></td>
53
+ <td>
54
+ <div class="btn-group d-flex" role="group">
55
+ <%= link_to 'Show', tutorial_post_step_path(tutorial_step.post, tutorial_step), class: "btn btn-purple btn-xs" %>
56
+ <%= link_to 'Update', edit_tutorial_post_step_path(tutorial_step.post, tutorial_step), class: "btn btn-primary btn-xs" %>
57
+ <%= link_to "Update", edit_tutorial_post_path(tutorial_post) %>
58
+ <%= link_to 'Destroy', tutorial_post_step_path(tutorial_step.post, tutorial_step), method: :delete, data: { confirm: 'Are you sure? This Action Cannot be Reversed.' }, class: "btn btn-danger btn-xs" %>
59
+ </div>
60
+ </td>
61
+ </tr>
62
+ <% end %>
63
+ </tbody>
64
+
65
+ </table>
66
+ <%= link_to phcdevworks_tutorials.new_tutorial_post_step_path, class: "btn btn-primary btn-sm" do %>
67
+ <i class="fas fa-plus-circle"></i>
68
+ Add a New Step for Tutorial
69
+ <% end %>
70
+ </div>
71
+ <!-- Table - Snippet Index -->
56
72
 
57
- </table>
58
- <%= link_to phcdevworks_tutorials.new_tutorial_post_step_path, class: "btn btn-primary btn-sm" do %>
59
- <i class="fas fa-plus-circle"></i>
60
- Add a New Step for Tutorial
61
- <% end %>
62
73
  </div>
63
- <!-- Table - Snippet Index -->
64
- </div>
65
- <!-- Panel Body -->
74
+ <!-- Panel Body -->
75
+
66
76
  </div>
67
77
  <!-- Page & Panel Content -->
@@ -1,14 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <strong>Tutorial step number:</strong>
5
- <%= @tutorial_step.tutorial_step_number %>
6
- </p>
7
-
8
- <p>
9
- <strong>Tutorial step body:</strong>
10
- <%= @tutorial_step.tutorial_step_body %>
11
- </p>
12
-
13
- <%= link_to 'Edit', edit_tutorial_step_path(@tutorial_step) %> |
14
- <%= link_to 'Back', tutorial_steps_path %>
@@ -4,8 +4,6 @@ class CreatePhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
4
4
 
5
5
  t.string :tutorial_post_title
6
6
 
7
- t.references :category
8
-
9
7
  t.string :slug
10
8
  t.string :user_id
11
9
  t.string :org_id
@@ -1,4 +1,4 @@
1
- class AddImageToPhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
1
+ class AddImageToPhcdevworksTutorialsTutorialSteps < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
 
4
4
  add_column :phcdevworks_tutorials_tutorial_steps, :tutorial_step_image, :string
@@ -0,0 +1,10 @@
1
+ class CreateJoinTableCategoriesPosts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_join_table :categories, :posts do |t|
4
+
5
+ # t.index [:category_id, :post_id]
6
+ # t.index [:post_id, :category_id]
7
+
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ class AddTittleToPhcdevworksTutorialsTutorialSteps < ActiveRecord::Migration[6.0]
2
+ def change
3
+
4
+ add_column :phcdevworks_tutorials_tutorial_steps, :tutorial_step_title, :string
5
+
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module PhcdevworksTutorials
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phcdevworks_tutorials
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - PHCDevworks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2019-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -289,6 +289,8 @@ files:
289
289
  - db/migrate/20190929044403_add_info_to_phcdevworks_tutorials_tutorial_posts.rb
290
290
  - db/migrate/20190929044505_add_info_to_phcdevworks_tutorials_tutorial_steps.rb
291
291
  - db/migrate/20191002093451_add_image_to_phcdevworks_tutorials_tutorial_posts.rb
292
+ - db/migrate/20191003235303_create_join_table_categories_posts.rb
293
+ - db/migrate/20191006054657_add_tittle_to_phcdevworks_tutorials_tutorial_steps.rb
292
294
  - lib/phcdevworks_tutorials.rb
293
295
  - lib/phcdevworks_tutorials/engine.rb
294
296
  - lib/phcdevworks_tutorials/version.rb