lot of changes for dashboard and project management

This commit is contained in:
Harry Bomrah 2017-11-28 19:47:23 +08:00
parent 5b265bb976
commit 90740bb5d2
10 changed files with 724 additions and 5 deletions

View File

@ -1,10 +1,23 @@
.dashboard-wrapper { .dashboard-wrapper {
margin: 25px; margin: 25px;
.left-side{
display: inline-block;
width: 65%;
}
.right-side{
display: inline-block;
width: 32%;
margin-left: 30px;
position: sticky;
position: -webkit-sticky;
vertical-align: top;
top: 100px;
}
#url-box { #url-box {
border: 1px solid #ddd; border: 1px solid #ddd;
background: #fff; background: #fff;
width: 950px;
height: 45px; height: 45px;
width: auto;
padding:20px 50px 0 50px; padding:20px 50px 0 50px;
.site-title{ .site-title{
color: #337ab7; color: #337ab7;
@ -54,8 +67,213 @@
margin-top: 30px; margin-top: 30px;
border: 1px solid #ddd; border: 1px solid #ddd;
background: #fff; background: #fff;
width: 950px; // width: calc(100% + 50px);
width: auto;
min-height: 545px; min-height: 545px;
padding:20px 50px 0 50px; padding:20px 25px 0 25px;
.conversations{
margin: 15px;
height: 70%;
width: 100%;
h3{
text-align: center;
color: #8a8a8a;
font-style: italic;
}
.conversation{
margin-bottom: 25px;
.avatar{
height: 50px;
width: 50px;
margin-right: 15px;
display: inline-block;
vertical-align: top;
.avatar-name{
text-align: center;
font-style: italic;
line-height: 14px;
}
.avatar-pic{
border-radius: 50px;
height: 50px;
width: 50px;
}
}
.message{
display: inline-block;
background-color: #e7ffc6;
border-radius: 20px;
padding: 20px;
width: calc(100% - 120px);
.date{
position: relative;
float: right;
vertical-align: top;
margin-right: 20px;
color: #838383;
font-style: italic;
.tagged-user{
text-align: right;
a{
text-decoration: none;
.tag-avatar-pic{
border-radius: 25px;
width: 20px;
height: 20px;
}
}
}
}
.content{
min-height: 50px;
font-size: 14px;
}
}
&.my{
.avatar{
margin-left: 15px;
margin-right: 0px;
}
.message {
text-align: right;
background-color: #ceecff;
.date {
float: left;
margin-left: 20px;
margin-right: 0px;
.tagged-user{
text-align: left;
}
}
}
}
}
}
.editor-wrapper{
margin-top: 35px;
padding-top: 20px;
border-top: 1px solid #cecece;
#post-loader{
text-align: center;
}
.ticket-internal-response-wrap{
margin-top: 20px;
.ticket-internal-response{
display: inline-block;
vertical-align: top;
margin: 0 5px 10px 0;
height: 44px;
line-height: 44px;
background: #888888;
color: white;
padding: 0 0.625rem;
font-family: "Roboto", sans-serif;
font-size: 14px;
border-radius: 0.125rem;
}
.ticket-tag-member{
margin-left: 35px;
display: inline-block;
.select2-container{
height: 44px;
min-width: 200px;
li.select2-search-choice{
// height: 40px;
div{
line-height: 30px;
font-size: 14px;
}
}
}
}
.submit-form-btn{
display: inline-block;
width: 100%;
input{
float: right;
}
}
}
}
}
}
#progress-tracker{
background-color: #fff;
height: 600px;
border: 1px solid #ddd;
h3{
text-align: center;
color: #8a8a8a;
border-bottom: 1px solid #ddd;
margin: 0 15px;
padding: 10px 0;
}
.departments{
margin: 15px;
.department{
margin: 15px 0;
h4{
font-size: 18px;
}
ul{
list-style: none;
input{
display: inline-block;
margin-top: 0;
// vertical-align: top;
}
label{
font-size: 16px;
display: inline-block;
margin-left: 10px;
}
.strikethrough{
text-decoration: line-through;
}
span.time{
margin-left: 20px;
font-size: 16px;
font-style: italic;
&.deadline{
color: red;
}
&.completed{
color: green;
}
}
}
}
}
}
.select2-result{
img {
width: 50px;
}
}
#timeline-box{
border: 1px solid #ddd;
background: #fff;
width: auto;
min-height: 350px;
padding: 10px 50px 0 50px;
margin-top: 20px;
transition: 0.3s;
&.collapsed{
min-height: 45px !important;
h3.sub-title{
border-bottom: none;
}
}
h3.sub-title{
color: #337ab7;
font-size: 18px;
border-bottom: 1px solid #ddd;
a{
text-decoration: none;
outline: none;
}
}
#timeline-chart{
transition: 0.3s;
} }
} }

View File

@ -43,6 +43,30 @@ class Admin::ClientManagementsController < OrbitAdminController
def project_dashboard def project_dashboard
@site_request = SiteRequest.find(params[:id]) @site_request = SiteRequest.find(params[:id])
@members = []
@project_post = ProjectPost.new
MemberProfile.all.each do |mp|
user = mp.user rescue nil
if !user.nil? && user.id.to_s != current_user.id.to_s
avatar = (mp.avatar.thumb.url == "thumb_person.png" ? "/assets/thumb_person.png" : mp.avatar.thumb.url rescue "/assets/thumb_person.png")
@members << {
"id" => user.id.to_s,
"user_name" => (user.user_name rescue ""),
"avatar" => avatar,
"name" => (mp.name_translations rescue {"en" => "","zh_tw" => ""})
}
end
end
@timeline = []
timeline = @site_request.site_timeline
@timeline << [{"test_site_creation_start" => timeline.test_site_creation_start.strftime("%Y-%m-%d"), "test_site_creation_end" => timeline.test_site_creation_end.strftime("%Y-%m-%d")}] if !timeline.test_site_creation_start.nil?
@timeline << [{"template_design_images_start" => timeline.template_design_images_start.strftime("%Y-%m-%d"), "template_design_images_end" => timeline.template_design_images_end.strftime("%Y-%m-%d")}] if !timeline.template_design_images_start.nil?
@timeline << [{"template_html_css_start" => timeline.template_html_css_start.strftime("%Y-%m-%d"), "template_html_css_end" => timeline.template_html_css_end.strftime("%Y-%m-%d")}] if !timeline.template_html_css_start.nil?
@timeline << [{"customized_module_start" => timeline.customized_module_start.strftime("%Y-%m-%d"), "customized_module_end" => timeline.customized_module_end.strftime("%Y-%m-%d")}] if !timeline.customized_module_start.nil?
@timeline << [{"data_migration_start" => timeline.data_migration_start.strftime("%Y-%m-%d"), "data_migration_end" => timeline.data_migration_end.strftime("%Y-%m-%d")}] if !timeline.data_migration_start.nil?
@timeline << [{"site_structure_start" => timeline.site_structure_start.strftime("%Y-%m-%d"), "site_structure_end" => timeline.site_structure_end.strftime("%Y-%m-%d")}] if !timeline.site_structure_start.nil?
@timeline << [{"site_migration_start" => timeline.site_migration_start.strftime("%Y-%m-%d"), "site_migration_end" => timeline.site_migration_end.strftime("%Y-%m-%d")}] if !timeline.site_migration_start.nil?
end end
def complete_request def complete_request
@ -160,8 +184,105 @@ class Admin::ClientManagementsController < OrbitAdminController
@contracts = RequestContract.all.order_by(:created_at => "desc", :confirmed => 'desc').page(params[:page]).per(10) @contracts = RequestContract.all.order_by(:created_at => "desc", :confirmed => 'desc').page(params[:page]).per(10)
end end
def create_project_post
ppost = ProjectPost.new(project_post_params)
ppost.save
render :partial => "conversation", :object => ppost
end
def timeline_update
timeline = SiteTimeline.find(params[:id])
if params[:checked] == "true"
case params[:field]
when "test_site_creation"
timeline.test_site_creation_completed = Time.now
timeline.test_site_creation_by = current_user.id.to_s
time = timeline.test_site_creation_completed.strftime("%Y/%m/%d")
when "template_design_images"
timeline.template_design_images_completed = Time.now
timeline.template_design_images_by = current_user.id.to_s
time = timeline.template_design_images_completed.strftime("%Y/%m/%d")
when "template_html_css"
timeline.template_html_css_completed = Time.now
timeline.template_html_css_by = current_user.id.to_s
time = timeline.template_html_css_completed.strftime("%Y/%m/%d")
when "customized_module"
timeline.customized_module_completed = Time.now
timeline.customized_module_by = current_user.id.to_s
time = timeline.customized_module_completed.strftime("%Y/%m/%d")
when "data_migration"
timeline.data_migration_completed = Time.now
timeline.data_migration_by = current_user.id.to_s
time = timeline.data_migration_completed.strftime("%Y/%m/%d")
when "site_structure"
timeline.site_structure_completed = Time.now
timeline.site_structure_by = current_user.id.to_s
time = timeline.site_structure_completed.strftime("%Y/%m/%d")
when "site_migration"
timeline.site_migration_completed = Time.now
timeline.site_migration_by = current_user.id.to_s
time = timeline.site_migration_completed.strftime("%Y/%m/%d")
when "psd_approval"
timeline.psd_approval_completed = Time.now
time = timeline.psd_approval_completed.strftime("%Y/%m/%d")
when "cutomer_approval"
timeline.cutomer_approval_completed = Time.now
time = timeline.cutomer_approval_completed.strftime("%Y/%m/%d")
when "module_approval"
timeline.module_approval_completed = Time.now
time = timeline.module_approval_completed.strftime("%Y/%m/%d")
end
else
case params[:field]
when "test_site_creation"
timeline.test_site_creation_completed = nil
timeline.test_site_creation_by = nil
time = timeline.test_site_creation_end.strftime("%Y/%m/%d")
when "template_design_images"
timeline.template_design_images_completed = nil
timeline.template_design_images_by = nil
time = timeline.template_design_images_end.strftime("%Y/%m/%d")
when "template_html_css"
timeline.template_html_css_completed = nil
timeline.template_html_css_by = nil
time = timeline.template_html_css_end.strftime("%Y/%m/%d")
when "customized_module"
timeline.customized_module_completed = nil
timeline.customized_module_by = nil
time = timeline.customized_module_end.strftime("%Y/%m/%d")
when "data_migration"
timeline.data_migration_completed = nil
timeline.data_migration_by = nil
time = timeline.data_migration_end.strftime("%Y/%m/%d")
when "site_structure"
timeline.site_structure_completed = nil
timeline.site_structure_by = nil
time = timeline.site_structure_end.strftime("%Y/%m/%d")
when "site_migration"
timeline.site_migration_completed = nil
timeline.site_migration_by = nil
time = timeline.site_migration_end.strftime("%Y/%m/%d")
when "psd_approval"
timeline.psd_approval_completed = nil
time = ""
when "cutomer_approval"
timeline.cutomer_approval_completed = nil
time = ""
when "module_approval"
timeline.module_approval_completed = nil
time = ""
end
end
timeline.save
render :json => {"success" => true, "time" => time, "name" => current_user.name}.to_json
end
private private
def project_post_params
params.require(:project_post).permit!
end
def receipt_params def receipt_params
params.require(:purchase_receipt).permit! params.require(:purchase_receipt).permit!
end end

View File

@ -0,0 +1,23 @@
class ProjectPost
include Mongoid::Document
include Mongoid::Timestamps
field :content
field :user_id
field :user_tags, type: Array, :default => []
field :internal_response, type: Boolean, :default => true
belongs_to :site_request
def my_post?(userid)
self.user_id == userid
end
def get_user
User.find(self.user_id) rescue nil
end
def tagged_users
User.find(self.user_tags) rescue []
end
end

View File

@ -29,6 +29,7 @@ class SiteRequest
belongs_to :c_panel_user belongs_to :c_panel_user
has_one :site_timeline has_one :site_timeline
has_many :project_posts
def get_site def get_site
self.site_id == "newsite" || self.site_id == "upgrade" ? nil : (RegisteredSite.find(self.site_id) rescue nil) self.site_id == "newsite" || self.site_id == "upgrade" ? nil : (RegisteredSite.find(self.site_id) rescue nil)

View File

@ -37,5 +37,9 @@ class SiteTimeline
field :site_migration_by field :site_migration_by
field :site_migration_completed, type: DateTime field :site_migration_completed, type: DateTime
field :psd_approval_completed, type: DateTime
field :cutomer_approval_completed, type: DateTime
field :module_approval_completed, type: DateTime
belongs_to :site_request belongs_to :site_request
end end

View File

@ -0,0 +1,36 @@
<%
conv_user = conversation.get_user
is_my_post = conversation.my_post?(current_user.id.to_s)
tagged_users = conversation.tagged_users
%>
<div class="conversation <%= conversation.my_post?(current_user.id.to_s) ? "my" : "" %>">
<% if !is_my_post %>
<div class="avatar">
<img class="avatar-pic" src="<%= (conv_user.member_profile.get_avatar rescue "/assets/thumb_person.png") %>">
<div class="avatar-name"><%= conv_user.name rescue "" %></div>
</div>
<% end %>
<div class="message">
<div class="date">
<div><%= conversation.created_at.strftime("%d %b %Y %H:%M")%></div>
<% if !tagged_users.empty? %>
<div class="tagged-user">
<% tagged_users.each do |user| %>
<a href="" onclick="return false;" title="<%= user.name rescue "" %>">
<img class="tag-avatar-pic" src="<%= (user.member_profile.get_avatar rescue "/assets/thumb_person.png") %>">
</a>
<% end %>
</div>
<% end %>
</div>
<div class="content clearfix">
<%= conversation.content.html_safe %>
</div>
</div>
<% if is_my_post %>
<div class="avatar">
<img class="avatar-pic" src="<%= (conv_user.member_profile.get_avatar rescue "/assets/thumb_person.png") %>">
<div class="avatar-name"><%= conv_user.name rescue "" %></div>
</div>
<% end %>
</div>

View File

@ -0,0 +1,125 @@
<div id="progress-tracker">
<h3>Progress Tracker</h3>
<div class="departments">
<div class="department">
<h4>Server</h4>
<ul class="responsibilities">
<li>
<% if @site_request.site_timeline.test_site_creation_completed == nil %>
<input type="checkbox" id="test_site_creation" name="test_site_creation" class="progress-checkbox"><label for="test_site_creation">Create pending site</label>
<span class="time deadline"><%= @site_request.site_timeline.test_site_creation_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="test_site_creation" name="test_site_creation" class="progress-checkbox" checked="checked"><label for="test_site_creation" class="strikethrough">Create pending site</label>
<span class="time completed"><%= @site_request.site_timeline.test_site_creation_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.test_site_creation_by).name rescue "" %></span>
<% end %>
</li>
<% if @site_request.type == "upgrade" %>
<li>
<% if @site_request.site_timeline.data_migration_completed == nil %>
<input type="checkbox" id="data_migration" name="data_migration" class="progress-checkbox"><label for="data_migration">Database migration</label>
<span class="time deadline"><%= @site_request.site_timeline.data_migration_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="data_migration" name="data_migration" class="progress-checkbox" checked="checked"><label for="data_migration" class="strikethrough">Database migration</label>
<span class="time completed"><%= @site_request.site_timeline.data_migration_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.data_migration_by).name rescue "" %></span>
<% end %>
</li>
<% end %>
<% if !@site_request.host_with_rulingdigital %>
<li>
<% if @site_request.site_timeline.site_migration_completed == nil %>
<input type="checkbox" id="site_migration" name="site_migration" class="progress-checkbox"><label for="site_migration">Site migration</label>
<span class="time deadline"><%= @site_request.site_timeline.site_migration_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="site_migration" name="site_migration" class="progress-checkbox" checked="checked"><label class="strikethrough" for="site_migration">Site migration</label>
<span class="time completed"><%= @site_request.site_timeline.site_migration_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.site_migration_by).name rescue "" %></span>
<% end %>
</li>
<% else %>
<li>
<% if @site_request.site_timeline.site_migration_completed == nil %>
<input type="checkbox" id="site_migration" name="site_migration" class="progress-checkbox"><label for="site_migration">DNS redirect</label>
<span class="time deadline"><%= @site_request.site_timeline.site_migration_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="site_migration" name="site_migration" class="progress-checkbox" checked="checked"><label for="site_migration" class="strikethrough">DNS redirect</label>
<span class="time completed"><%= @site_request.site_timeline.site_migration_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.site_migration_by).name rescue "" %></span>
<% end %>
</li>
<% end %>
</ul>
</div>
<div class="department">
<h4>Design</h4>
<ul class="responsibilities">
<li>
<% if @site_request.site_timeline.psd_approval_completed == nil %>
<input type="checkbox" id="template_design_images" name="template_design_images" class="progress-checkbox"><label for="template_design_images">Create PSD</label>
<span class="time deadline"><%= @site_request.site_timeline.template_design_images_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="template_design_images" name="template_design_images" class="progress-checkbox" checked="checked"><label for="template_design_images" class="strikethrough">Create PSD</label>
<span class="time completed"><%= @site_request.site_timeline.template_design_images_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.template_design_images_by).name rescue "" %></span>
<% end %>
</li>
<li>
<% if @site_request.site_timeline.psd_approval_completed == nil %>
<input type="checkbox" id="psd_approval" name="psd_approval" class="progress-checkbox"><label for="psd_approval">PSD approved</label><span class="time"></span>
<% else %>
<input type="checkbox" id="psd_approval" name="psd_approval" class="progress-checkbox" checked="checked"><label for="psd_approval" class="strikethrough">PSD approved</label><span class="time completed"><%= @site_request.site_timeline.psd_approval_completed.strftime("%Y/%m/%d") %></span>
<% end %>
</li>
<li>
<% if @site_request.site_timeline.template_html_css_completed == nil %>
<input type="checkbox" id="template_html_css" name="template_html_css" class="progress-checkbox"><label for="template_html_css">HTML &amp; CSS completed</label>
<span class="time deadline"><%= @site_request.site_timeline.template_html_css_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="template_html_css" name="template_html_css" class="progress-checkbox" checked="checked"><label for="template_html_css" class="strikethrough">HTML &amp; CSS completed</label>
<span class="time completed"><%= @site_request.site_timeline.template_html_css_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.template_html_css_by).name rescue "" %> </span>
<% end %>
</li>
</ul>
</div>
<% if @site_request.custom_module %>
<div class="department">
<h4>R&amp;D</h4>
<ul class="responsibilities">
<li>
<% if @site_request.site_timeline.customized_module_completed == nil %>
<input type="checkbox" id="customized_module" name="customized_module" class="progress-checkbox"><label for="customized_module">Create module</label>
<span class="time deadline"><%= @site_request.site_timeline.customized_module_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="customized_module" name="customized_module" class="progress-checkbox" checked="checked"><label for="customized_module" class="strikethrough">Create module</label>
<span class="time completed"><%= @site_request.site_timeline.customized_module_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.customized_module_by).name rescue "" %></span>
<% end %>
</li>
<li>
<% if @site_request.site_timeline.module_approval_completed == nil %>
<input type="checkbox" id="module_approval" name="module_approval" class="progress-checkbox"><label for="module_approval">Module approved</label><span class="time"></span>
<% else %>
<input type="checkbox" id="module_approval" name="module_approval" class="progress-checkbox"><label for="module_approval" class="strikethrough">Module approved</label><span class="time completed"><%= @site_request.site_timeline.module_approval_completed.strftime("%Y/%m/%d") %></span>
<% end %>
</li>
</ul>
</div>
<% end %>
<div class="department">
<h4>Customer Service</h4>
<ul class="responsibilities">
<li>
<% if @site_request.site_timeline.site_structure_completed == nil %>
<input type="checkbox" id="site_structure" name="site_structure" class="progress-checkbox"><label for="site_structure">Site menu and structure</label>
<span class="time deadline"><%= @site_request.site_timeline.site_structure_end.strftime("%Y/%m/%d") %></span>
<% else %>
<input type="checkbox" id="site_structure" name="site_structure" class="progress-checkbox" checked="checked"><label for="site_structure" class="strikethrough">Site menu and structure</label>
<span class="time completed"><%= @site_request.site_timeline.site_structure_completed.strftime("%Y/%m/%d") %> by <%= User.find(@site_request.site_timeline.site_structure_by).name rescue "" %></span>
<% end %>
</li>
<li>
<% if @site_request.site_timeline.cutomer_approval_completed == nil %>
<input type="checkbox" id="cutomer_approval" name="cutomer_approval" class="progress-checkbox"><label for="cutomer_approval">Customer approval</label><span class="time"></span>
<% else %>
<input type="checkbox" id="cutomer_approval" name="cutomer_approval" checked="checked" class="progress-checkbox"><label for="cutomer_approval" class="strikethrough">Customer approval</label><span class="time completed"><%= @site_request.site_timeline.cutomer_approval_completed.strftime("%Y/%m/%d") %></span>
<% end %>
</li>
</ul>
</div>
</div>
</div>

View File

@ -0,0 +1,7 @@
<h3 class="sub-title">
Timeline
<a href="#" id="timeline-expand-btn" class="pull-right"><i class="icons-plus" aria-hidden="true"></i></a>
</h3>
<div id="timeline-chart" style="height: 350px;">
</div>

View File

@ -1,6 +1,15 @@
<%= csrf_meta_tag %>
<% content_for :page_specific_css do %> <% content_for :page_specific_css do %>
<%= stylesheet_link_tag "client_management/dashboard" %> <%= stylesheet_link_tag "client_management/dashboard" %>
<%= stylesheet_link_tag "select2/select2" %>
<% end %> <% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/jquery.form.js" %>
<%= javascript_include_tag "validator" %>
<%= javascript_include_tag "select2/select2.min" %>
<%= javascript_include_tag "jquery.viewport" %>
<% end %>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div class="dashboard-wrapper"> <div class="dashboard-wrapper">
<div class="left-side"> <div class="left-side">
<div id="url-box"> <div id="url-box">
@ -29,13 +38,60 @@
<% end %> <% end %>
</span> </span>
</div> </div>
<div id="dashboard"> <div id="timeline-box" class="collapsed">
<%= render :partial => "timeline_box" %>
</div> </div>
<div id="dashboard">
<div class="conversations">
<% if @site_request.project_posts.count > 0 %>
<%= render :partial => "conversation", :collection => @site_request.project_posts.asc(:created_at) %>
<% else %>
<h3>No posts found</h3>
<% end %>
</div>
<div class="editor-wrapper">
<div id="post-loader" style="display:none;">
<%= image_tag("preloader.gif", size: "50") %>
<div>Posting your response.</div>
</div>
<%= form_for @project_post, :url => {:action => "create_project_post"}, :html => {:id => "dashboard-post"} do |f| %>
<textarea class="ckeditor" name="project_post[content]" data-fv-validation="required;" data-fv-messages="Cannot be empty;"></textarea>
<div class="ticket-internal-response-wrap">
<div class="ticket-internal-response">
<%= f.check_box :internal_response %>
<%= f.hidden_field :site_request_id , :value => @site_request.id.to_s %>
<%= f.hidden_field :user_id , :value => current_user.id.to_s %>
<span class="ticket-internal-response">Internal Response</span>
</div>
<div class="ticket-tag-member">
<!-- <h4 class="ticket-tag-mebmer-heading">Tag member</h4> -->
<select class="member_tags" multiple="multiple" name="project_post[user_tags][]">
<% @members.each do |member| %>
<%
name = member["name"][I18n.locale.to_s] == "" ? member["name"]["zh_tw"] : member["name"][I18n.locale.to_s]
name = "" if name.nil?
user_name = "(#{member["user_name"]})"
text = " #{name} #{user_name}"
%>
<option value="<%= member["id"] %>" data-member="<%= member.to_json %>"><%= text %></option>
<% end %>
</select>
</div>
<div class="submit-form-btn">
<input type="submit" class="btn btn-primary" id="dashboard-post-submit-btn" value="Submit">
</div>
</div>
<% end %>
</div>
</div>
</div>
<div class="right-side">
<%= render :partial => "progress_tracker" %>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var locale = "<%= I18n.locale.to_s %>";
$("#edit-url-btn").on("click",function(){ $("#edit-url-btn").on("click",function(){
$("#edit-url-box").hide(); $("#edit-url-box").hide();
$("#site-url-edit-box").show(); $("#site-url-edit-box").show();
@ -56,6 +112,132 @@
}) })
return false; return false;
}) })
$(".member_tags").select2({
formatResult: function (el) {
var $el = $(el.element),
member = $el.data("member"),
name = (member.name[locale] == "" ? member.name.zh_tw : member.name[locale]),
user_name = "(" + member.user_name + ")",
text = name + " " + user_name;
if (!el.id) { return el.text; }
var $state = $(
'<span><img src="' + member.avatar + '" class="img-avatar" /> ' + text + '</span>'
);
return $state;
},
placeholder: "Tag Members"
});
var fv = new FormValidator($("#dashboard-post"));
$("#dashboard-post-submit-btn").on("click",function(){
for (instance in CKEDITOR.instances) {
CKEDITOR.instances[instance].updateElement();
}
if(fv.isFormValidated()){
$("#dashboard-post").hide();
$("#post-loader").show();
fv.form.ajaxSubmit({
success : function(data){
setTimeout(function(){
fv.reset();
$(".member_tags").select2("val","");
for (instance in CKEDITOR.instances) {
CKEDITOR.instances[instance].setData("");
}
$("#dashboard-post").show();
$(".conversations").find("h3").remove();
$(".conversations").append(data);
$("#post-loader").hide();
},500)
},
error : function(){
$("#post-loader").find("img").hide();
$("#post-loader").find("div").text("There was some error.");
}
});
}
return false;
})
$(document).on("click", ".progress-checkbox", function(){
var el = $(this),
value = el.attr("name"),
checked = el.prop("checked");
$.ajax({
url : "<%= timeline_update_admin_client_management_path(@site_request.site_timeline) %>",
data : {"field" : value, "checked" : checked},
dataType : "json",
type : "post",
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
}).success(function(data){
var span = el.parent().find("span"),
label = el.parent().find("label");
if(checked){
span.removeClass("deadline");
span.addClass("completed");
label.addClass("strikethrough");
span.text(data.time + " by " + data.name);
}else{
span.removeClass("completed");
span.addClass("deadline");
label.removeClass("strikethrough");
span.text(data.time);
}
})
})
var timelineBox = $("#timeline-box"),
expandBtn = $("#timeline-expand-btn");
expandBtn.on("click",function(){
if(timelineBox.hasClass("collapsed")){
timelineBox.removeClass("collapsed");
expandBtn.find("i").removeClass("icons-plus");
expandBtn.find("i").addClass("icons-minus");
$("#timeline-chart").show();
}else{
timelineBox.addClass("collapsed");
expandBtn.find("i").removeClass("icons-minus");
expandBtn.find("i").addClass("icons-plus");
$("#timeline-chart").hide();
}
})
var timelineHash = <%= @timeline.to_json.html_safe %>,
dataTable = null,
chart = null,
counter = 0,
titles = {
"test_site_creation_start" : "Test Site Creation",
"template_design_images_start" : "Template Images",
"template_html_css_start" : "Template HTML & CSS",
"customized_module_start" : "Customized Module",
"data_migration_start" : "Data Migration",
"site_structure_start" : "Structure & Data Finalizing ",
"site_migration_start" : "Site Migration"
}
google.charts.load("current", {packages:["timeline"]});
google.charts.setOnLoadCallback(drawChart);
var timelineOptions = {
timeline: { showRowLabels: true }
};
function drawChart() {
var container = document.getElementById('timeline-chart');
chart = new google.visualization.Timeline(container);
dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Term' });
dataTable.addColumn({ type: 'string', id: 'Name' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
$.each(timelineHash,function(i, tm){
var hs = tm[0],
keys = Object.keys(hs),
enddt = new Date(hs[keys[1]]),
startdt = new Date(hs[keys[0]]);
counter++;
console.log(hs[keys[1]]);
dataTable.addRow([counter.toString(), titles[keys[0]], startdt, enddt]);
})
chart.draw(dataTable, timelineOptions);
$("#timeline-chart").hide();
}
</script> </script>

View File

@ -28,6 +28,8 @@ Rails.application.routes.draw do
patch "update_receipt" patch "update_receipt"
get "project_dashboard" get "project_dashboard"
patch "update_site_request" patch "update_site_request"
post "create_project_post"
post "timeline_update"
end end
collection do collection do
get "completed_requests" get "completed_requests"