Created
April 30, 2012 08:46
-
-
Save Znow/2556663 to your computer and use it in GitHub Desktop.
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
<div id="createTask" class="modal hide fade custom_modal" style="display: none;"> | |
<%= form_for [:admin, task], :url => admin_tasks_path, :remote => true, :html => { :id => 'new-task-form' } do |f| %> | |
<div class="modal-header"> | |
<h3> | |
Add New Task | |
<span class="pull-right"> | |
<%= submit_tag "Save", :class => 'btn btn-primary custom_button' %> | |
<a href="#" data-dismiss="modal" class="btn btn-small custom_button_dark">Cancel</a> | |
</span> | |
</h3> | |
</div> | |
<div class="modal-body"> | |
<%= render :partial => "admin/shared/ajax_loader" %> | |
<div class="modal-errors"></div> | |
<%= render :partial => "admin/tasks/task_form", :locals => { :f => f } %> | |
</div> | |
<div class="modal-footer"> | |
</div> | |
<% end %> | |
</div> |
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
<% | |
task_types = @task_types | |
responsible = @responsible | |
client = @client | |
%> | |
<%= debug task_types %> | |
<p> | |
<%= f.label :task_type, "Type <span class='required'>*</span>".html_safe %> | |
<%= f.select :task_type, options_for_select(@task_types), :class => "span4" %> | |
</p> | |
<p> | |
<%= f.label :subject, "Subject <span class='required'>*</span>".html_safe %> | |
<%= f.text_area :subject, :class => "input-xlarge span4" %> | |
</p> | |
<p> | |
<%= f.label :responsible, "Responsible <span class='required'>*</span>".html_safe %> | |
<%= f.select :responsible, options_for_select(@responsible), :class => "span4" %> | |
</p> | |
<p> | |
<%= f.label :client, "Client" %> | |
<%= f.select :client, options_for_select(@client), :class => "span4" %> | |
</p> | |
<p> | |
<%= f.label :deadline, "Deadline <span class='required'>*</span>".html_safe %> | |
<%= f.text_field :deadline, :id => "task-deadline" %> | |
</p> |
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
def create | |
@task = Task.new(params[:task]) | |
@task.merge!(params[:author] => current_user) | |
@client_tasks = @task.client_tasks.create(@client.id) | |
@client = Client.all.map(&:name) | |
@task_types = ['Follow-up', 'Meeting', 'Email', 'Contract', 'Conference call', 'Note'] | |
@responsible = User.all.map(&:name) | |
respond_to do |format| | |
if @task.save | |
flash[:success] = "<strong>Success!</strong> #{@task.subject} was successfully added.".html_safe | |
end | |
format.js { render :template => "admin/tasks/create.js.erb", | |
:locals => { | |
:task => @task, | |
:redirect_path => admin_tasks_path, | |
} | |
} # create.js.erb | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment