Created
July 11, 2017 16:43
-
-
Save spacerobotTR/a7a926559288948db864ffe805b1735f to your computer and use it in GitHub Desktop.
Project management comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if object.errors.any? %> | |
<div class="panel panel-danger"> | |
<div class="panel-heading" id="error_explanation"> | |
<h2><%= pluralize(object.errors.count, "error") %> | |
prohibited this project from being saved:</h2> | |
<ul> | |
<% object.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> | |
</div> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for([@project, @project.comments.build]) do |f| %> | |
<div> | |
<%= error_messages_for(f.object) %> | |
</div> | |
<div> | |
<%= f.text_area :content, { :class=>"summernote" } %> | |
</div> | |
<div style="padding-top:20px;"> | |
<%= f.submit 'Update Project', :class => 'btn btn-primary' %> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def error_messages_for(object) | |
render(:partial => 'application/error_messages', :locals => | |
{:object => object}) | |
end | |
def is_active_controller(controller_name, class_name = nil) | |
if params[:controller] == controller_name | |
class_name == nil ? 'active' : class_name | |
else | |
nil | |
end | |
end | |
def is_active_action(action_name) | |
params[:action] == action_name ? 'active' : nil | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment < ApplicationRecord | |
belongs_to :project | |
belongs_to :user | |
validates_presence_of :content, { message: "Update text box cannot be blank."} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
before_action :find_project | |
before_action :find_comment, only: [:destroy, :edit, :update, :comment_owner] | |
before_action :comment_owner, only: [:destroy, :edit, :update] | |
def create | |
@comment = @project.comments.new(params[:comment].permit(:content)) | |
@comment.user_id = current_user.id | |
if @comment.save | |
# redirect_to project_path(@project) | |
redirect_to project_path(@project), notice: 'Comment was successfully created.' | |
else | |
redirect_to project_path(@project) | |
end | |
end | |
def edit | |
end | |
def update | |
if @comment.update(params[:comment].permit(:content)) | |
redirect_to project_path(@project) | |
else | |
render 'edit' | |
end | |
end | |
def destroy | |
@comment.destroy | |
redirect_to project_path(@project) | |
end | |
private | |
def find_project | |
@project = Project.find(params[:project_id]) | |
end | |
def find_comment | |
@comment = @project.comments.find(params[:id]) | |
end | |
def comment_owner | |
unless current_user.id == @comment.user_id | |
flash[:notice] = "You cannot modify a different users udpates." | |
redirect_to @project | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% provide(:page_title, @project.projname) %> | |
<div class="row wrapper border-bottom white-bg page-heading"> | |
<div class="col-sm-4"> | |
<h2>Project detail</h2> | |
<ol class="breadcrumb"> | |
<li> | |
<%= link_to 'Home', root_path %> | |
</li> | |
<li> | |
<%= link_to 'Projects', projects_path %> | |
</li> | |
<li class="active"> | |
<strong>Project detail</strong> | |
</li> | |
</ol> | |
</div> | |
</div> | |
<cfoutput query="getproj"> | |
<div class="row"> | |
<div class="col-lg-9"> | |
<div class="wrapper wrapper-content animated fadeInUp"> | |
<div class="ibox"> | |
<div class="ibox-content"> | |
<div class="row"> | |
<div class="col-lg-12"> | |
<div class="m-b-md"> | |
<%= link_to 'Return to Projects', projects_path, { :class=>"btn btn-white btn-xs pull-right" } %> | |
<%= link_to 'Edit Project', edit_project_path(@project), { :class=>"btn btn-white btn-xs pull-right" } %> | |
<h2><%= @project.projname %> - <%= @project.cpdcprojnum %></h2> | |
</div> | |
<dl class="dl-horizontal"> | |
<dt>Status:</dt> <dd><span class="label label-<%= @project.proj_status.statusnotify %>"><%= @project.proj_status.statusdescr %></span></dd> | |
</dl> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-lg-5"> | |
<dl class="dl-horizontal"> | |
<dt>Created by:</dt> <dd><%= @project.user.username %></dd> | |
<dt>Customer Name:</dt> <dd> <%= @project.customername %></dd> | |
<dt>Customer Phone:</dt> <dd> <%= @project.customerphone %></dd> | |
<dt>Customer Email:</dt> <dd> <%= @project.customeremail %></dd> | |
<dt>Project Type:</dt> <dd> <%= @project.projtype %></dd> | |
</dl> | |
</div> | |
<div class="col-lg-7" id="cluster_info"> | |
<dl class="dl-horizontal" > | |
<dt>Project Manager:</dt> <dd><%= @project.projmanager %></dd> | |
<dt>Rooms/Location:</dt> <dd><%= @project.rooms %></dd> | |
<dt>Building:</dt> <dd><%= @project.building %></dd> | |
<dt>Last Updated:</dt> <dd><%= @project.updated_at.to_time.strftime('%B %e at %l:%M %p') %></dd> | |
<dt>Created On:</dt> <dd> <%= @project.created_at.to_time.strftime('%B %e at %l:%M %p') %> </dd> | |
</dl> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-lg-12"> | |
<dl class="dl-horizontal"> | |
<dt>Completed:</dt> | |
<dd> | |
<div class="progress progress-striped active m-b-sm"> | |
<div style="width: <%= @project.proj_status.percent %>%;" class="progress-bar"></div> | |
</div> | |
<small>Project completed in <strong><%= @project.proj_status.percent %>%</strong>. </small> | |
</dd> | |
</dl> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-lg-12"> | |
<dl class="dl-horizontal"> | |
<dt></dt> | |
<dd> | |
<div> | |
<div> | |
<%= render 'comments/form' %> | |
</div> | |
</div> | |
</dd> | |
</dl> | |
</div> | |
</div> | |
<div class="row m-t-sm"> | |
<div class="col-lg-12"> | |
<div class="panel blank-panel"> | |
<div class="panel-heading"> | |
<div class="panel-options"> | |
<ul class="nav nav-tabs"> | |
<li class="active"><a href="##tab-1" data-toggle="tab"><%= pluralize(@comments.count, "Project Update") %></a></li> | |
</ul> | |
</div> | |
</div> | |
<div class="panel-body"> | |
<div class="tab-content"> | |
<div class="tab-pane active" id="tab-1"> | |
<div class="feed-activity-list"> | |
<%= render 'comments/comment' %> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="col-lg-3"> | |
<div class="wrapper wrapper-content project-manager"> | |
<h4>Project description</h4> | |
<p class="small"> | |
<%= @project.description.html_safe %><br /> | |
</p> | |
<h5>Project files</h5> | |
<ul class="list-unstyled project-files"> | |
<li><a href=""><i class="fa fa-file"></i> Project_document.docx</a></li> | |
<li><a href=""><i class="fa fa-file-picture-o"></i> Logo_zender_company.jpg</a></li> | |
<li><a href=""><i class="fa fa-stack-exchange"></i> Email_from_Alex.mln</a></li> | |
<li><a href=""><i class="fa fa-file"></i> Contract_20_11_2014.docx</a></li> | |
</ul> | |
<div class="text-center m-t-md"> | |
<a href="" class="btn btn-xs btn-primary">Add files</a> | |
</div> | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
$(function() { | |
$('.summernote').summernote({height:50}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment