Permalink
Browse files

Can now edit Short Term Goals from the MyGuide Interface.

Added edit functionality from the my guide interface and touched up the short term goal admin interface.
  • Loading branch information...
1 parent 79522b5 commit 28134ecd6add8b99f1d77228db922d4d25f219ea @kcalmes kcalmes committed Mar 23, 2012
@@ -86,7 +86,7 @@ def create
@short_term_goal = ShortTermGoal.new(params[:short_term_goal])
respond_to do |format|
if @short_term_goal.save
- format.html { redirect_to(@short_term_goal, :notice => 'Short term goal was successfully created.') }
+ format.html { redirect_to(myguide_path(@current_user), :notice => 'Short term goal was successfully created.') }
format.xml { render :xml => @short_term_goal, :status => :created, :location => @short_term_goal }
else
format.html { render :action => "new" }
@@ -115,7 +115,7 @@ def update
respond_to do |format|
if @short_term_goal.update_attributes(params[:short_term_goal])
- format.html { redirect_to(@short_term_goal, :notice => 'Short term goal was successfully updated.') }
+ format.html { redirect_to(myguide_path(@current_user), :notice => 'Short term goal was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
@@ -9,19 +9,31 @@
<% end %>
</div>
<div class="grid_5">
- <div class="button year">FIRST YEAR</div>
+ <div class="button year">
+ FIRST YEAR
+ <img class="add" src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Add_64x64.png">
+ </div>
<div class="progressbar year1"></div>
</div>
<div class="grid_5">
- <div class="button year">SECOND YEAR</div>
+ <div class="button year">
+ SECOND YEAR
+ <img class="add" src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Add_64x64.png">
+ </div>
<div class="progressbar year2"></div>
</div>
<div class="grid_5">
- <div class="button year">THIRD YEAR</div>
+ <div class="button year">
+ THIRD YEAR
+ <img class="add" src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Add_64x64.png">
+ </div>
<div class="progressbar year3"></div>
</div>
<div class="grid_5">
- <div class="button year">FOURTH YEAR</div>
+ <div class="button year">
+ FOURTH YEAR
+ <img class="add" src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Add_64x64.png">
+ </div>
<div class="progressbar year4"></div>
</div>
@@ -46,6 +58,14 @@
#active_user{
width: 100%;
}
+<% if cannot? :manage, :myguide %>
+ .stg .edit {
+ display: none;
+ }
+ .year img.add {
+ display: none;
+ }
+<% end %>
</style>
<script>
$('#active_user').change(function(){
@@ -3,7 +3,7 @@
$(function(){
$(".add_new_task").click(function(){
- $(".field .tasks_input").append('<div id="task['+number_of_tasks+']" class="task_wrapper"><input class="task" name="task['+number_of_tasks+']" size="180" type="text" /><img src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Delete_64x64.png" width="15"></div>');
+ $(".field .tasks_input").append('<div id="task['+number_of_tasks+']" class="task_wrapper clearfix"><input class="task" name="task['+number_of_tasks+']" size="180" type="text" /><img src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Delete_64x64.png" width="15"></div>');
setDeleteClick();
number_of_tasks++;
return false;
@@ -68,6 +68,13 @@
.task_wrapper{
cursor: pointer;
}
+ .task_wrapper input{
+ float: left;
+ }
+ .task_wrapper img{
+ float: left;
+ margin: 5px 10px;
+ }
</style>
<%= form_for(@short_term_goal) do |f| %>
@@ -113,7 +120,7 @@
<div class="tasks_input">
<% count = 0 %>
<% @short_term_goal.tasks.each do |task| %>
- <div id="task[<%= count %>]" class="task_wrapper">
+ <div id="task[<%= count %>]" class="task_wrapper clearfix">
<input class="task" name="task[<%= count %>]" size="180" type="text" value="<%= task.name %>" />
<img src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Delete_64x64.png" width="15">
</div>
@@ -1,8 +1,7 @@
<div class="flat_area grid_16">
<h2>Editing Short Term Goal</h2>
<span class="edit_links">
- <%= link_to 'Show', @short_term_goal %> |
- <%= link_to 'Back', short_term_goals_path %>
+ <%= link_to 'Back', myguide_path(@current_user) %>
</span>
</div><br />
<%= render 'form' %>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -167,3 +167,31 @@ div.button.year{
.flat_area #myguide ul li input{
position: relative;
}
+select, input {
+ width: auto;
+}
+.stg .edit {
+ position: absolute;
+ top: 5px;
+ right: 0px;
+ cursor: pointer;
+}
+.year img.add {
+ width:26px;
+ position: absolute;
+ top: 5px;
+ right: 15px;
+ cursor: pointer;
+}
+/* Special Chosen Overides */
+.flat_area #myguide ul.chzn-results li {
+ color: #666;
+ padding: 7px 7px 8px;
+ margin: 0px;
+}
+.flat_area #myguide ul.chzn-results li.highlighted {
+ color: white;
+}
+.flat_area #myguide ul.chzn-results li:first-child {
+padding-top: 7px;
+}
@@ -14,6 +14,8 @@ var unchecked_icon = 'http://humadvisement.byu.edu/sites/default/files/menu_icon
var tag = 'all';
$(function(){
+ //set the chosen dropdown
+ $('select.chosen').chosen();
//set the active user
user_data.user_id = parseInt($('#myguide').attr('user_id'));
$.ajax({
@@ -51,13 +53,16 @@ function setupGoals(){
$.each(data,function(){
var html = '<div class="button stg ' + this.tag;
- html += '"><img src="' + unchecked_icon + '" />' + this.name + '<div class="tasks hidden"><ul>';
+ html += '" stg_id="'+ this.id +'"><img src="' + unchecked_icon + '" />' + this.name + '<div class="edit"><img class="edit_img" src="http://humadvisement.byu.edu/sites/default/files/menu_icons/Pencil_64x64.png"></div><div class="tasks hidden"><ul>';
$.each(this.tasks,function(){
html +='<li><input type="checkbox" name="task[name]" task_id="'+this.id+'" /><label>'+ this.name +'</label></li>';
});
html += '</ul></div></div>';
$('#year'+this.school_year+'_col').append(html);
});
+ $(".year img.add").click(function(event){
+ window.location.href = "/short_term_goals/new";
+ });
$(".stg").click(function(event){
var target = $(event.target);
if(target.is('li')){
@@ -67,13 +72,18 @@ function setupGoals(){
} else {
target.attr('checked', 'checked')
}
- } else if(target.is('label')){
+ } else if(target.is('label')) {
target = target.parent('li').children('input');
if(target.is(':checked')){
target.removeAttr('checked');
} else {
target.attr('checked', 'checked');
}
+ } else if(target.is('.edit_img')) {
+ var stg_id = target.parents('.stg').attr('stg_id');
+ window.location.href = '/short_term_goals/'+ stg_id +'/edit';
+ exit();
+
}/* else if((target.is('input')) {
//check the box
}*/

0 comments on commit 28134ec

Please sign in to comment.