Archived
make labels editable in threads
This commit is contained in:
@@ -572,6 +572,7 @@ input , select, textarea {
|
|||||||
|
|
||||||
option {
|
option {
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
|
height: 2em;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #0f0;
|
background: #0f0;
|
||||||
@@ -588,6 +589,14 @@ input , select, textarea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table-cell {
|
||||||
|
display: table-cell;
|
||||||
|
|
||||||
|
&.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
|
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
|
||||||
background: #ddd;
|
background: #ddd;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -595,6 +604,10 @@ input[type=text], input[type=email], input[type=password], input[type=number], t
|
|||||||
margin: 4px 0 0;
|
margin: 4px 0 0;
|
||||||
padding: 0.5em 1em;
|
padding: 0.5em 1em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
&.auto-width {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input, select, textarea {
|
input, select, textarea {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class ForumthreadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def thread_params(add = [])
|
def thread_params(add = [])
|
||||||
a = [:title, :content]
|
a = [:title, :content, :label_id]
|
||||||
a += add
|
a += add
|
||||||
params.require(:forumthread).permit(a)
|
params.require(:forumthread).permit(a)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class SessionsController < ApplicationController
|
|||||||
logout_user = current_user
|
logout_user = current_user
|
||||||
session[:user_id] = original_user.try(:id)
|
session[:user_id] = original_user.try(:id)
|
||||||
session.delete(:original_user_id)
|
session.delete(:original_user_id)
|
||||||
|
puts "User #{original_user} reverted from #{logout_user}!"
|
||||||
flash[:notice] = "You are no longer '#{logout_user.name}'!"
|
flash[:notice] = "You are no longer '#{logout_user.name}'!"
|
||||||
redirect_to original_user
|
redirect_to original_user
|
||||||
else
|
else
|
||||||
@@ -63,6 +64,7 @@ class SessionsController < ApplicationController
|
|||||||
else
|
else
|
||||||
session[:original_user_id] = original_user.id
|
session[:original_user_id] = original_user.id
|
||||||
session[:user_id] = new_user.id
|
session[:user_id] = new_user.id
|
||||||
|
puts "User #{original_user} became #{new_user}!"
|
||||||
flash[:notice] = "You are now '#{new_user.name}'!"
|
flash[:notice] = "You are now '#{new_user.name}'!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
class Label < ActiveRecord::Base
|
class Label < ActiveRecord::Base
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validate :color_valid
|
validate :color_valid
|
||||||
belongs_to :role
|
|
||||||
has_and_belongs_to_many :forums
|
has_and_belongs_to_many :forums
|
||||||
has_many :forumthreads
|
has_many :forumthreads
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
<% title "Edit Thread: #{@thread}" %>
|
<% title "Edit Thread: #{@thread}" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
forums = []
|
||||||
|
Forum.all.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f|
|
||||||
|
forums << ["#{f.forumgroup.name} → #{f.name}", f.id] if f.forumgroup
|
||||||
|
end
|
||||||
|
labels = [["Label", nil]]
|
||||||
|
Label.order(:name).each do |l|
|
||||||
|
labels << [l.name, l.id]
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
|
||||||
<h1>Edit thread</h1>
|
<h1>Edit thread</h1>
|
||||||
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread
|
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread
|
||||||
<%= form_for @thread do |f|%>
|
<%= form_for @thread do |f|%>
|
||||||
@@ -13,17 +24,16 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= f.label :forum_id, "Move thread" %></td>
|
<td><%= f.label :forum_id, "Move thread" %></td>
|
||||||
<%
|
|
||||||
forums = []
|
|
||||||
Forum.all.sort_by{ |f| f.forumgroup && f.forumgroup.position || 0 }.each do |f|
|
|
||||||
forums << ["#{f.forumgroup.name} → #{f.name}", f.id] if f.forumgroup
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
<td><%= f.select :forum_id, forums %></td>
|
<td><%= f.select :forum_id, forums %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="table-cell">
|
||||||
|
<%= f.select :label_id, labels, {}, class: "auto-width" %>
|
||||||
|
</div>
|
||||||
|
<div class="table-cell full-width">
|
||||||
<%= f.text_field :title, placeholder: "Title" %>
|
<%= f.text_field :title, placeholder: "Title" %>
|
||||||
|
</div>
|
||||||
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
|
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
|
||||||
<p><%= f.submit "Update thread", class: "btn blue left" %></p>
|
<p><%= f.submit "Update thread", class: "btn blue left" %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
<% title "New Thread: #{@thread.forum.name}" %>
|
<% title "New Thread: #{@thread.forum.name}" %>
|
||||||
|
|
||||||
|
<%
|
||||||
|
labels = [["Label", nil]]
|
||||||
|
Label.order(:name).each do |l|
|
||||||
|
labels << [l.name, l.id]
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
|
||||||
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread
|
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread
|
||||||
<h1>New thread</h1>
|
<h1>New thread</h1>
|
||||||
<%= form_for @thread do |f|%>
|
<%= form_for @thread do |f|%>
|
||||||
@@ -15,7 +22,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
<div class="table-cell">
|
||||||
|
<%= f.select :label_id, labels, {}, class: "auto-width" %>
|
||||||
|
</div>
|
||||||
|
<div class="table-cell full-width">
|
||||||
<%= f.text_field :title, placeholder: "Title" %>
|
<%= f.text_field :title, placeholder: "Title" %>
|
||||||
|
</div>
|
||||||
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
|
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
|
||||||
<%= f.hidden_field :forum_id %>
|
<%= f.hidden_field :forum_id %>
|
||||||
<p><%= f.submit "Create thread", class: "btn blue left" %></p>
|
<p><%= f.submit "Create thread", class: "btn blue left" %></p>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class RemoveRoleFromLabel < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :labels, :role_id
|
||||||
|
end
|
||||||
|
end
|
||||||
+1
-2
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150117134404) do
|
ActiveRecord::Schema.define(version: 20150117154652) do
|
||||||
|
|
||||||
create_table "blogposts", force: true do |t|
|
create_table "blogposts", force: true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
@@ -71,7 +71,6 @@ ActiveRecord::Schema.define(version: 20150117134404) do
|
|||||||
|
|
||||||
create_table "labels", force: true do |t|
|
create_table "labels", force: true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.integer "role_id"
|
|
||||||
t.string "color"
|
t.string "color"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user