Skip to content

Commit 022e24c

Browse files
committed
implemented delete timeline feature
1 parent 5d2843b commit 022e24c

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

appinfo/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@
5353
['name' => 'ajax#get_timelines_admin', 'url' => '/ajax/timelines-admin', 'verb' => 'GET'],
5454
['name' => 'ajax#download_timeline', 'url' => '/ajax/download-timeline/{id}', 'verb' => 'GET'],
5555
['name' => 'ajax#edit_timeline', 'url' => '/ajax/edit-timeline/{id}', 'verb' => 'POST'],
56+
['name' => 'ajax#delete_timeline', 'url' => '/ajax/delete-timeline/{id}', 'verb' => 'POST'],
5657
]
5758
];

js/timelines.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,38 @@
277277
return '<a href="'+baseUrl+'">'+"Download"+'</a>';
278278

279279
}},
280+
{formatter:"buttonCross", width:40, align:"center", cellClick:function(e, cell){
281+
$("#dialog-confirm").dialog({
282+
buttons : {
283+
"Confirm" : {click: function() {
284+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/delete-timeline/'+cell.getRow().getData().id);
285+
var jqxhr = $.post( baseUrl, function() {
286+
getTimelines();
287+
$("#dialog-confirm").dialog("close");
288+
})
289+
.done(function(data, status, jqXHR) {
290+
var response = data;
291+
if ('Error' in response){
292+
alert(response.Error);
293+
}
294+
})
295+
.fail(function() {
296+
alert( "error" );
297+
})
298+
return false;
299+
},
300+
text: 'Confirm',
301+
class:'primary'
302+
},
303+
"Cancel" : function() {
304+
$(this).dialog("close");
305+
}
306+
}
307+
});
308+
$("#dialog-confirm").dialog('open');
309+
310+
//cell.getRow().delete();
311+
}},
280312

281313
],
282314
ajaxResponse:function(url, params, response){

lib/Controller/AjaxController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,5 +953,19 @@ public function editTimeline($id){
953953
return new JSONResponse(["Timeline" => $timeline]);
954954
}
955955

956+
/**
957+
*
958+
* @NoAdminRequired
959+
*/
960+
961+
public function deleteTimeline($id) {
962+
$tl = $this->timelineMapper->find($id);
963+
if ($tl->userUid == $this->userId){
964+
$this->timelineMapper->delete($tl);
965+
}
966+
967+
return new JSONResponse(["Timeline" => $timeline]);
968+
}
969+
956970

957971
}

0 commit comments

Comments
 (0)