make labels editable in threads
This commit is contained in:
@@ -572,6 +572,7 @@ input , select, textarea {
|
||||
|
||||
option {
|
||||
padding: 0.5em;
|
||||
height: 2em;
|
||||
|
||||
&:hover {
|
||||
background: #0f0;
|
||||
@@ -588,14 +589,26 @@ input , select, textarea {
|
||||
}
|
||||
}
|
||||
|
||||
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
|
||||
background: #ddd;
|
||||
border: none;
|
||||
height: 3em;
|
||||
margin: 4px 0 0;
|
||||
padding: 0.5em 1em;
|
||||
.table-cell {
|
||||
display: table-cell;
|
||||
|
||||
&.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
|
||||
background: #ddd;
|
||||
border: none;
|
||||
height: 3em;
|
||||
margin: 4px 0 0;
|
||||
padding: 0.5em 1em;
|
||||
width: 100%;
|
||||
|
||||
&.auto-width {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
input, select, textarea {
|
||||
&.disabled, &[disabled] {
|
||||
|
||||
@@ -83,7 +83,7 @@ class ForumthreadsController < ApplicationController
|
||||
end
|
||||
|
||||
def thread_params(add = [])
|
||||
a = [:title, :content]
|
||||
a = [:title, :content, :label_id]
|
||||
a += add
|
||||
params.require(:forumthread).permit(a)
|
||||
end
|
||||
|
||||
@@ -43,6 +43,7 @@ class SessionsController < ApplicationController
|
||||
logout_user = current_user
|
||||
session[:user_id] = original_user.try(:id)
|
||||
session.delete(:original_user_id)
|
||||
puts "User #{original_user} reverted from #{logout_user}!"
|
||||
flash[:notice] = "You are no longer '#{logout_user.name}'!"
|
||||
redirect_to original_user
|
||||
else
|
||||
@@ -63,6 +64,7 @@ class SessionsController < ApplicationController
|
||||
else
|
||||
session[:original_user_id] = original_user.id
|
||||
session[:user_id] = new_user.id
|
||||
puts "User #{original_user} became #{new_user}!"
|
||||
flash[:notice] = "You are now '#{new_user.name}'!"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
class Label < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
validate :color_valid
|
||||
belongs_to :role
|
||||
has_and_belongs_to_many :forums
|
||||
has_many :forumthreads
|
||||
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
<% 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>
|
||||
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → New thread
|
||||
<%= form_for @thread do |f|%>
|
||||
@@ -13,17 +24,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<%= f.text_field :title, placeholder: "Title" %>
|
||||
<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" %>
|
||||
</div>
|
||||
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
|
||||
<p><%= f.submit "Update thread", class: "btn blue left" %></p>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<% 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
|
||||
<h1>New thread</h1>
|
||||
<%= form_for @thread do |f|%>
|
||||
@@ -15,7 +22,12 @@
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<%= f.text_field :title, placeholder: "Title" %>
|
||||
<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" %>
|
||||
</div>
|
||||
<%= render partial: "md_editor", locals: {name: "forumthread[content]", content: @thread.content, mini: false} %>
|
||||
<%= f.hidden_field :forum_id %>
|
||||
<p><%= f.submit "Create thread", class: "btn blue left" %></p>
|
||||
|
||||
5
db/migrate/20150117154652_remove_role_from_label.rb
Normal file
5
db/migrate/20150117154652_remove_role_from_label.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class RemoveRoleFromLabel < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :labels, :role_id
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# 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|
|
||||
t.string "title"
|
||||
@@ -70,9 +70,8 @@ ActiveRecord::Schema.define(version: 20150117134404) do
|
||||
end
|
||||
|
||||
create_table "labels", force: true do |t|
|
||||
t.string "name"
|
||||
t.integer "role_id"
|
||||
t.string "color"
|
||||
t.string "name"
|
||||
t.string "color"
|
||||
end
|
||||
|
||||
create_table "register_tokens", force: true do |t|
|
||||
|
||||
Reference in New Issue
Block a user