Skip to content

Instantly share code, notes, and snippets.

@kmelkon
Last active December 20, 2015 12:29
Show Gist options
  • Save kmelkon/6131487 to your computer and use it in GitHub Desktop.
Save kmelkon/6131487 to your computer and use it in GitHub Desktop.
<div class="add-task arrow_box hide">
<%= form_for ([@company, @task]), :remote => true do |f| %>
<%= f.label :description %>
<%= f.text_field :description, :class => "input-width bottom-border" %>
<%= f.label :task_category_id, "Choose a category" %>
<%= f.collection_select(:task_category_id, TaskCategory.all, :id, :task_category) %>
<%= f.label :due_date %>
<%= f.select :due_date_word, ['Today', 'Tomorrow', 'Next Week']%>
<%= f.submit "Add this Task", class: "btn ss" %>
<% end %>
</div>
<%= form_for [@company, @deal], :remote=> true, :id => "form" do |f| %>
<%= f.label :background %>
<%= f.text_area :background, :class => "input-width bottom-border" %>
<%= f.label :value %>
<%= f.text_field :value, :class => "input-width bottom-border" %>
<%= f.submit "Add this Deal", class: "btn submit-deals" %>
<% end %>
<% current_task.todays_tasks.each_with_index do |task, i| %>
<% if i == 0 %><strong>Today</strong><% end %>
<%= task.description %>
<% end %>
<% current_task.tomorrows_tasks.each_with_index do |task, i| %>
<% if i == 0 %><strong>Tomorrow</strong><% end %>
<%= task.description %>
<% end %>
$('.deals-wrapper').append('<%= escape_javascript(render :partial => "deals/deal") %>');
$(':input')
.not(':button, :submit')
.val('');
$(".deal:even").addClass("background-gray deal-padding");
$.colorbox.close();
class DealsController < ApplicationController
def index
@deals=Deal.all
end
def create
@deal=Deal.new(params[:deal])
@deal.company_id = params[:company_id]
@company = Company.find_by_id(@deal.company_id)
respond_to do |format|
if @deal.save
format.html { render controller: "companies" , action: "show" }
format.js
else
render :json => { }, status => 500
end
end
end
def edit
end
def delete
end
end
def status
params[:task_ids].each do |check|
task_id = check
t = Task.find_by_id(task_id)
t.status = !t.status
t.save
end
end
$(this).closest("form").submit();
}
<% @tasks.each do |t| %>
<%= form_tag("tasks/status", :remote=>true, :id=>"task" + t.id.to_s) do %>
<ul style="list-style-type:none;">
<li>
<%= hidden_field_tag 'task_ids[]', t.id.to_s %>
<%= check_box_tag '', t.id.to_s, t.status, :class => 'checkbox' %> <%= t.description %>
</li>
</ul>
<%end%>
<%end %>
<div class="content pull-left">
<h2><%= @company.name %></h2>
<%= link_to "edit company", edit_company_path %>
<div class="margin-bottom">
<% for phone in @company.phone_numbers %>
<li><%= phone.number %> (<%= phone.place %>)</li>
<% end %>
</div>
<ul class="nav nav-tabs margin-top" id="company-tab">
<li class="active"><a href="#go-to-contacts" data-toggle="tab">Contacts</a></li>
<li><a href="#go-to-deals" data-toggle="tab">Deals</a></li>
<li><a href="#go-to-activities" data-toggle="tab">Activities</a></li>
<!-- <li> <%= link_to 'Deals', new_company_deal_path(@company), 'data-toggle' => 'tab'%></li> -->
</ul>
<div class="tab-content">
<div class="tab-pane active in" id="go-to-contacts">
<div>
<button class="btn btn-small btn-info" type="button">Select All</button>
<button class="btn btn-small btn-info" type="button">Delete</button>
<%= link_to "Add a person to this company", href="#new-contact-form", :class=>"pull-right inline"%>
</div>
<div class="x">
<% for contact in @company.contacts %>
<div class="contact-card">
<ul>
<%= link_to(company_contact_path(@company,contact)) do %>
<li><%= contact.first_name %> <%= contact.last_name %></li>
<% end %>
<li><%= contact.email %></li>
<% for phone in contact.phone_numbers %>
<li><%= phone.number %> (<%= phone.place %>)</li>
<% end %>
</ul>
</div>
<%= cycle('','<div class="clearfix"></div>'.html_safe, :name=>"clearfix") %>
<% end %>
</div>
</div>
<div class="tab-pane fade" id="go-to-deals">
<div class="deals-wrapper">
<% for deal in @company.deals %>
<div class="deal">
<ul>
<li><%= deal.value %></li>
<li><%= deal.background %></li>
</ul>
</div>
<% end %>
</div>
<div class="hide">
<div id="new-deal-form" >
<%= render 'deals/new_deal' %>
</div>
</div>
<div>
<% if @company.deals.blank? %>
<%= link_to "Add a deal", href="#new-deal-form", class: "pull-right inline" %>
<% else %>
<%= render 'deals/new_deal' %>
<% end %>
</div>
</div>
<div class="tab-pane fade" id="go-to-activities">
<div class="activities-wrapper">
<% @company.activities.each do |activity| %>
<%= content_tag(:p , activity.title) %>
<%= content_tag(:p , activity.background) %>
<% end %>
</div>
<%= render "activities/new_activity" %>
</div>
<!-- <div>
<button class="btn btn-small btn-info" type="button">Select All</button>
<button class="btn btn-small btn-info" type="button">Delete</button>
<%= link_to "Add a person to this company", href="#new-contact-form", :class=>"pull-right inline"%>
</div> -->
<div class="hide">
<div id="new-contact-form">
<%= render :partial => "contacts/newcontactform", :locals => {:contact => Contact.new} %>
</div>
</div>
</div>
<div class="sidebar pull-right">
<div class="well sidebar-width margin-right">
<%= link_to "Add a task", new_company_task_path(@company), :class=>'toggle' %>
<%= render "tasks/addtask" %>
<div id="tasklist">
<%= render "tasks/tasklist", :current_task=>@tasks %>
</div>
</div>
</div>
<div class="clearfix"></div>
class TasksController < ApplicationController
def index
@task= Task.all
end
def show
end
def new
@task = Task.new
end
def create
company_id = params[:company_id]
contact_id = params[:contact_id]
@task = Task.new(params[:task])
if company_id.nil? && !contact_id.nil?
@task.contact_id = contact_id
@task.company_id = 0
elsif contact_id.nil? && !company_id.nil?
@task.company_id = company_id
@task.contact_id = 0
else
@task.company_id = 0
@task.contact_id = 0
end
@company = Company.find(params[:company_id])
@tasks = @company.tasks
respond_to do |format|
if @task.save
format.js
else
render 'new'
end
end
end
def edit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment