phcdevworks_tutorials 1.2.1 → 2.0.0

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: b93b2be698a2b6af5d1caef7359a18c9982a913d9418baae3a1b1ab265fc2f78
4
- data.tar.gz: c35a37c51964b9d31d6ed9df137e1e72cec8ef2f8daab6cc248422f97c094515
3
+ metadata.gz: c0f64d687dc306c83c9812e27c23535b8ad1f6034509d490d94c81a6c243c57d
4
+ data.tar.gz: e240ea72bb6abbd8d330d49d79fa5847baab7b9da7077e3cd51bbb4f820698c0
5
5
  SHA512:
6
- metadata.gz: 23f22943873bb93365bfda9b15e29b25d86ed8bc315e160b8b776cdb747445c063ca5218cb37742ea59b0b28bea2fe7defb8fb3523abc3741c9a82138dd4d4f6
7
- data.tar.gz: f79b366422c3e9c0dd60b2c24136fde739c0eb49bae9fb25cdf8c666c0274abf6da53e87be979dc835e418d867af3143c2e60fa86fa2b88b22e42e8e101ac937
6
+ metadata.gz: a7e6e240e87ffd74be029311cf49a0d1bb474c99742d3b220ebb2c498fcb6e5f8ffaedef5537ada2d09d2f1981f5a1310014dc7a6bb9595a1335f3c3baf5526c
7
+ data.tar.gz: 989b0d77e5f5a2beb04c0fb4f3aa45ea1208ec163ed01d21a14b13fd66e38bd3e701f4ad2984ff059aedb6728d24228bd97dbfab6b1be0f99f30ff50ed5f7e89
@@ -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,
@@ -8,13 +8,17 @@ module PhcdevworksTutorials
8
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
 
@@ -6,6 +6,8 @@ module PhcdevworksTutorials
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 %>
@@ -3,8 +3,11 @@ class CreatePhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
3
3
  create_table :phcdevworks_tutorials_tutorial_posts do |t|
4
4
 
5
5
  t.string :tutorial_post_title
6
-
7
- t.references :category
6
+ t.text :tutorial_post_description
7
+ t.string :tutorial_post_status
8
+
9
+ t.string :tutorial_post_image
10
+ t.string :tutorial_post_images
8
11
 
9
12
  t.string :slug
10
13
  t.string :user_id
@@ -3,7 +3,11 @@ class CreatePhcdevworksTutorialsTutorialSteps < ActiveRecord::Migration[6.0]
3
3
  create_table :phcdevworks_tutorials_tutorial_steps do |t|
4
4
 
5
5
  t.integer :tutorial_step_number
6
- t.text :tutorial_step_body
6
+ t.string :tutorial_step_title
7
+ t.text :tutorial_step_description
8
+
9
+ t.string :tutorial_step_image
10
+ t.string :tutorial_step_images
7
11
 
8
12
  t.string :slug
9
13
  t.string :user_id
@@ -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
@@ -1,3 +1,3 @@
1
1
  module PhcdevworksTutorials
2
- VERSION = '1.2.1'
2
+ VERSION = '2.0.0'
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.1
4
+ version: 2.0.0
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
@@ -286,9 +286,7 @@ files:
286
286
  - db/migrate/20190911225813_create_phcdevworks_tutorials_tutorial_posts.rb
287
287
  - db/migrate/20190911225925_create_phcdevworks_tutorials_tutorial_categories.rb
288
288
  - db/migrate/20190923113101_create_phcdevworks_tutorials_tutorial_steps.rb
289
- - db/migrate/20190929044403_add_info_to_phcdevworks_tutorials_tutorial_posts.rb
290
- - db/migrate/20190929044505_add_info_to_phcdevworks_tutorials_tutorial_steps.rb
291
- - db/migrate/20191002093451_add_image_to_phcdevworks_tutorials_tutorial_posts.rb
289
+ - db/migrate/20191003235303_create_join_table_categories_posts.rb
292
290
  - lib/phcdevworks_tutorials.rb
293
291
  - lib/phcdevworks_tutorials/engine.rb
294
292
  - lib/phcdevworks_tutorials/version.rb
@@ -1,9 +0,0 @@
1
- class AddInfoToPhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
2
- def change
3
-
4
- add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_images, :string
5
- add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_description, :text
6
- add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_status, :string
7
-
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- class AddInfoToPhcdevworksTutorialsTutorialSteps < ActiveRecord::Migration[6.0]
2
- def change
3
-
4
- add_column :phcdevworks_tutorials_tutorial_steps, :tutorial_step_images, :string
5
-
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- class AddImageToPhcdevworksTutorialsTutorialPosts < ActiveRecord::Migration[6.0]
2
- def change
3
-
4
- add_column :phcdevworks_tutorials_tutorial_steps, :tutorial_step_image, :string
5
- add_column :phcdevworks_tutorials_tutorial_posts, :tutorial_post_image, :string
6
-
7
- end
8
- end