foreman_datacenter 0.1.27 → 0.1.28

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fbb2b60766fe6af7321a5449bf8e57b52a47cf9
4
- data.tar.gz: 316f815ce5eca799bd92918e66077c919dc0fa73
3
+ metadata.gz: c3bb886dd6e594c44644dc906e0a114d3753fd41
4
+ data.tar.gz: 37c34a36aba8e89822ac4b470ad169dad4ad948c
5
5
  SHA512:
6
- metadata.gz: 0146588b60a9fae132d84d41c5e93251f2f3cae0693fc271623f91cbf28266d669f0fb50d267897cc9249730abffef485731ddb5834711de046afd902cba08c0
7
- data.tar.gz: 6dc8a7674869873604c795ba6f2de7758a2da3dd42fc2c941ccb2db3999aab07778f7e6f55dfb92fbe04584ddc630bdc6b728e0015a6becf51b352ba951e0bc8
6
+ metadata.gz: 1ce51989419d2d0118522ba9d1692d63a1abb560493e5b53d1445dc81c8cc852f78a411e39d7ff2888678945419d929380bcd9edbeeb63acbae52526c7542fe6
7
+ data.tar.gz: 7535811c728a339ef7f220d786e42f3a257e8af504986c6137ad91331230e0ddb8d1f062e5a0506f4728e4a4934f9affdb5007d59bfe38a261f6b7bbfc4a4498
@@ -0,0 +1,4 @@
1
+ ul.none-list {
2
+ list-style-type: none !important;
3
+ }
4
+
@@ -2,8 +2,14 @@ module ForemanDatacenter
2
2
  class CommentsController < ApplicationController
3
3
  before_filter :load_resource, :load_commentable
4
4
 
5
+ def new
6
+ @comment = Comment.new
7
+ @parent = Comment.find(params[:parent_id])
8
+ end
9
+
5
10
  def edit
6
11
  @comment = Comment.find(params[:id])
12
+ @parent = @comment.parent
7
13
  end
8
14
 
9
15
  def create
@@ -38,15 +44,23 @@ module ForemanDatacenter
38
44
  private
39
45
 
40
46
  def load_resource
41
- @resource, @id = request.path.split('/')[2, 3]
47
+ if (params[:resource] && params[:resource_id])
48
+ @resource, @id = params[:resource], params[:resource_id]
49
+ else
50
+ @resource, @id = request.path.split('/')[2, 3]
51
+ end
42
52
  end
43
53
 
44
54
  def load_commentable
45
- @commentable = "foreman_datacenter::#{@resource.capitalize}".singularize.classify.constantize.find(@id.to_i)
55
+ begin
56
+ @commentable = "foreman_datacenter::#{@resource.capitalize}".singularize.classify.constantize.find(@id.to_i)
57
+ rescue
58
+ @commentable = "foreman_datacenter::#{params[:resource].capitalize}".singularize.classify.constantize.find(params[:resource_id].to_i)
59
+ end
46
60
  end
47
61
 
48
62
  def comment_params
49
- params[:foreman_datacenter_comment].permit(:content, :commntable_type, :commentable_id)
63
+ params[:foreman_datacenter_comment].permit(:content, :commntable_type, :commentable_id, :parent_id)
50
64
  end
51
65
 
52
66
  def find_commentable(comment)
@@ -116,7 +116,8 @@ module ForemanDatacenter
116
116
  end
117
117
 
118
118
  def load_resource
119
- @resource, @id = request.path.split('/')[2, 3]
119
+ resource, id = request.path.split('/')[2, 3]
120
+ @commentable_data = {resource: resource, id: id }
120
121
  end
121
122
 
122
123
  def populate_from_host
@@ -142,3 +143,4 @@ module ForemanDatacenter
142
143
  end
143
144
  end
144
145
  end
146
+
@@ -2,7 +2,8 @@ module ForemanDatacenter
2
2
  class Comment < ActiveRecord::Base
3
3
  self.table_name = "datacenter_comments"
4
4
  belongs_to :commentable, polymorphic: true
5
- belongs_to :parent, class_name: "ForemanDatacenter::Comment"
6
- has_many :children, class_name: "ForemanDatacenter::Comment", foreign_key: "parent_id"
5
+ has_ancestry
6
+ # belongs_to :parent, class_name: "ForemanDatacenter::Comment"
7
+ # has_many :children, class_name: "ForemanDatacenter::Comment", foreign_key: "parent_id"
7
8
  end
8
9
  end
@@ -0,0 +1,9 @@
1
+ <ul class="none-list">
2
+ <li>
3
+ <% c.each do |comment, children |%>
4
+ <%= render 'foreman_datacenter/comments/item', comment: comment, commentable_data: commentable_data %>
5
+ <%= render 'foreman_datacenter/comments/children', commentable_data: commentable_data, c: children if children.present? %>
6
+ <% end %>
7
+ </li>
8
+ </ul>
9
+
@@ -0,0 +1,23 @@
1
+ <% stylesheet 'foreman_datacenter/comments' %>
2
+
3
+ <table class="table table-hover panel-body table-striped">
4
+ <tbody>
5
+ <% comments.roots.each do |c| %>
6
+ <tr>
7
+ <td>
8
+ <ul class="none-list">
9
+ <li>
10
+ <%= render 'foreman_datacenter/comments/item', comment: c, commentable_data: commentable_data %>
11
+ </li>
12
+ <% if c.root.descendants != [] %>
13
+ <%= render 'foreman_datacenter/comments/children', c: c.root.descendants.arrange, commentable_data: commentable_data %>
14
+ <% end %>
15
+ </ul>
16
+ </td>
17
+ </tr>
18
+ <% end %>
19
+ </tbody>
20
+ </table>
21
+
22
+ <%= render 'foreman_datacenter/comments/form'%>
23
+
@@ -2,12 +2,44 @@
2
2
  <%= form_for @comment, url: "/datacenter/comments/#{@comment.id}" do |f| %>
3
3
  <div class="clearfix">
4
4
  <div class="form-group">
5
+ <% if @parent %>
6
+ <%= f.label "Parent comment" %>
7
+ <p>
8
+ <%= @parent.content %>
9
+ </p>
10
+ <% end %>
5
11
  <div class="col-md-5">
6
- <%= f.text_area :content, rows: 8, class: "form-control" %>
12
+ <%= f.text_area :content, rows: 6, class: "form-control" %>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ <div class="btn-toolbar">
17
+ <%= link_to 'Back', url_for(:back), class: 'btn btn-success' %>
18
+ <%= f.submit "Edit", class: "btn btn-primary remove_form_templates" %>
19
+ </div>
20
+ <% end %>
21
+ <% elsif action_name == "new" %>
22
+ <%= form_for @comment, url: "/datacenter/comments", method: :post do |f| %>
23
+ <div class="clearfix">
24
+ <div class="form-group">
25
+ <% if @parent %>
26
+ <%= f.label "Parent comment" %>
27
+ <p>
28
+ <%= @parent.content %>
29
+ </p>
30
+ <% end %>
31
+ <div class="col-md-5">
32
+ <%= f.text_area :content, rows: 6, class: "form-control" %>
33
+ <%= f.hidden_field :parent_id, value: @parent.id %>
34
+ <%= hidden_field_tag "resource", params[:resource] %>
35
+ <%= hidden_field_tag "resource_id", params[:resource_id] %>
7
36
  </div>
8
37
  </div>
9
38
  </div>
10
- <%= f.submit "Edit comment", class: "btn btn-primary remove_form_templates" %>
39
+ <div class="btn-toolbar">
40
+ <%= link_to 'Back', url_for(:back), class: 'btn btn-success' %>
41
+ <%= f.submit "Reply", class: "btn btn-primary remove_form_templates" %>
42
+ </div>
11
43
  <% end %>
12
44
  <% else %>
13
45
  <%= form_for [@commentable, @comment], url: "/datacenter/devices/#{@commentable.id}/comments" do |f| %>
@@ -18,7 +50,7 @@
18
50
  </div>
19
51
  </div>
20
52
  </div>
21
- <%= f.submit "Add comment", class: "btn btn-primary remove_form_templates" %>
53
+ <%= f.submit "Post", class: "btn btn-primary remove_form_templates" %>
22
54
  <% end %>
23
55
  <% end %>
24
56
 
@@ -0,0 +1,24 @@
1
+ <strong>
2
+ <small class="text-left pull-left">
3
+ Posted by ... <%#= "#{@user.firstname} #{@user.lastname}" %> at <%= comment.updated_at %>
4
+ </small>
5
+
6
+ <small class="text-right pull-right">
7
+ <%= link_to "##{comment.id}", "#comment-#{comment.id}" %>
8
+ </small>
9
+ </strong>
10
+ <br/>
11
+ <div class="text-left pull-left">
12
+ <%= comment.content %>
13
+ <br/>
14
+ <small>
15
+ <%= link_to "Reply", new_comment_path(parent_id: comment.id, resource: commentable_data[:resource], resource_id: commentable_data[:id]) %>
16
+ &nbsp;
17
+ <%= link_to "Edit", "/datacenter/comments/#{comment.id}/edit" %>
18
+ &nbsp;
19
+ <%= link_to "Delete", "/datacenter/#{commentable_data[:resource]}/#{commentable_data[:id]}/comments/#{comment.id}", method: :delete, data: {confirm: "Are you sure?"} %>
20
+ </small>
21
+ </div>
22
+ <br/>
23
+ <br/>
24
+
@@ -0,0 +1,4 @@
1
+ <% title 'Reply to comment' %>
2
+
3
+ <%= render 'form' %>
4
+
@@ -1,4 +1,5 @@
1
1
  <% javascript 'foreman_datacenter/devices' %>
2
+ <% stylesheet 'foreman_datacenter/comments' %>
2
3
 
3
4
  <% title _('Devices') %>
4
5
  <% title_actions display_link_if_authorized(_('New device'), hash_for_new_device_path, class: 'btn btn-success'),
@@ -4,8 +4,10 @@ Foreman::Application.routes.draw do
4
4
  get 'datacenter/import_to_device', to: 'hosts#import_to_device',
5
5
  as: 'import_to_device'
6
6
 
7
+
7
8
  scope 'datacenter', module: :foreman_datacenter do
8
- resources :comments, only: [:edit, :update]
9
+ resources :comments, only: [:new, :edit, :create, :update]
10
+
9
11
  resources :sites
10
12
  resources :racks do
11
13
  get :rack_groups, on: :collection
@@ -103,3 +105,4 @@ Foreman::Application.routes.draw do
103
105
  end
104
106
  end
105
107
  end
108
+
@@ -1,3 +1,3 @@
1
1
  module ForemanDatacenter
2
- VERSION = '0.1.27'.freeze
2
+ VERSION = '0.1.28'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_datacenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.27
4
+ version: 0.1.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-01 00:00:00.000000000 Z
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -111,6 +111,7 @@ files:
111
111
  - app/assets/javascripts/foreman_datacenter/management_devices.js
112
112
  - app/assets/javascripts/foreman_datacenter/racks.js
113
113
  - app/assets/javascripts/foreman_datacenter/shared.js
114
+ - app/assets/stylesheets/foreman_datacenter/comments.css
114
115
  - app/assets/stylesheets/foreman_datacenter/device_interface_connections.css
115
116
  - app/controllers/concerns/foreman_datacenter/hosts_controller_extensions.rb
116
117
  - app/controllers/foreman_datacenter/comments_controller.rb
@@ -176,8 +177,12 @@ files:
176
177
  - app/models/foreman_datacenter/rack.rb
177
178
  - app/models/foreman_datacenter/rack_group.rb
178
179
  - app/models/foreman_datacenter/site.rb
180
+ - app/views/foreman_datacenter/comments/_children.html.erb
181
+ - app/views/foreman_datacenter/comments/_comments.html.erb
179
182
  - app/views/foreman_datacenter/comments/_form.html.erb
183
+ - app/views/foreman_datacenter/comments/_item.html.erb
180
184
  - app/views/foreman_datacenter/comments/edit.html.erb
185
+ - app/views/foreman_datacenter/comments/new.html.erb
181
186
  - app/views/foreman_datacenter/console_port_templates/_form.html.erb
182
187
  - app/views/foreman_datacenter/console_port_templates/new.html.erb
183
188
  - app/views/foreman_datacenter/console_ports/_for_device.html.erb