Changeset 1465 for tupper


Ignore:
Timestamp:
2010-03-18 14:39:32 (2 years ago)
Author:
karel
Message:

Added button to delete tasks

Location:
tupper/trunk/tupper-site/src/main
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • tupper/trunk/tupper-site/src/main/java/org/kauriproject/tupper/resource/TaskResource.java

    r1336 r1465  
    88import java.util.ArrayList; 
    99import java.util.List; 
     10 
    1011import net.sf.json.JSONObject; 
    1112import net.sf.json.JSONSerializer; 
     13 
    1214import org.kauriproject.tupper.api.Tupper; 
    1315import org.kauriproject.tupper.api.manager.TaskManager; 
     
    241243            try { 
    242244                tupper.begin(); 
     245                List<Performance> performances = tupper.getPerformanceManager().findByTask(task); 
     246                if (performances.size() > 0) { 
     247                    throw new TupperException("Can't delete task: there are performances"); 
     248                } 
     249                List<Task> subtasks = tm.findByParentTask(task); 
     250                if (subtasks.size() > 0) { 
     251                    JSONObject json = new JSONObject(); 
     252                    throw new TupperException("Can't delete task: there are subtasks"); 
     253                } 
    243254                tm.destroy(task); 
    244255                tupper.commit(); 
  • tupper/trunk/tupper-site/src/main/kauri/pages/{user}/projects..xml

    r1424 r1465  
    238238                                <input type="button" value="Edit" id="edit_task_button"/> 
    239239                            </div> 
     240                            <div> 
     241                                <input type="button" value="Delete" id="delete_task_button"/> 
     242                            </div> 
    240243                        </div> 
    241244                    </div> 
  • tupper/trunk/tupper-site/src/main/kauri/representations.groovy

    r1269 r1465  
    1010    } 
    1111 
     12    exceptions(media:"json") { 
     13        exception(classes: ["java.lang.RuntimeException"]) { 
     14            jsonStatus(); 
     15        } 
     16        exception { 
     17            jsonStatus(); 
     18        } 
     19    } 
     20 
    1221    exceptions { 
     22        exception(classes: ["java.lang.RuntimeException"]) { 
     23            jsonStatus(); 
     24        } 
    1325        exception { 
    1426            template(src: "clap://thread/org/kauriproject/representation/defaulterrorpage.xml") 
  • tupper/trunk/tupper-site/src/main/kauri/static/js/popups.js

    r1269 r1465  
    283283    loadValues(); 
    284284  }); 
     285  $("#delete_task_button").click(function(){ 
     286      taskForm.setCreateMode(false); 
     287    //alert(JSON.stringify(detailJSON)); 
     288    if (confirm('Are you sure?')) { 
     289      $.ajax({type:"POST", url:"/data/task/"+detailJSON.id+"?method=DELETE&kauri-error-media=json", 
     290        success:function(a,b,c) { 
     291          alert('The task is now gone (refresh!)'); 
     292          // if delete is confirmed, simulate click on the parent of selected node (need to add parentId to the detailJSON) 
     293        }, 
     294        error:function(a,b,c) { 
     295          var jsonStatus = JSON.parse(a.responseText); 
     296          var m = jsonStatus.throwable.cause.message; 
     297          alert(m); 
     298        } 
     299      }); 
     300    } 
     301  }); 
    285302  //closing popup 
    286303  $(".popup_submit").click(function(){ 
Note: See TracChangeset for help on using the changeset viewer.