Skip to content

Commit 8d24230

Browse files
committed
added work item details field
1 parent 2436128 commit 8d24230

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

appinfo/database.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@
196196
<notnull>true</notnull>
197197
<length>256</length>
198198
</field>
199+
<field>
200+
<name>details</name>
201+
<type>text</type>
202+
<notnull>true</notnull>
203+
<length>1024</length>
204+
</field>
199205
<field>
200206
<name>project_id</name>
201207
<type>integer</type>

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>Time Tracker</name>
66
<summary>Time Tracker App</summary>
77
<description><![CDATA[Time Tracker App]]></description>
8-
<version>0.0.36</version>
8+
<version>0.0.37</version>
99
<licence>agpl</licence>
1010
<author mail="[email protected]" >MTier Ltd.</author>
1111
<namespace>TimeTracker</namespace>

js/timer.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
text: "Confirm",
5454
click: function() {
5555
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/add-work-interval/'+$('#name-manual-entry').val());
56-
57-
var jqxhr = $.post( baseUrl,{start:picker.data('daterangepicker').startDate.format('DD/MM/YY HH:mm'), end:picker.data('daterangepicker').endDate.format('DD/MM/YY HH:mm'), tzoffset: new Date().getTimezoneOffset()} ,function() {
56+
57+
var jqxhr = $.post( baseUrl,{start:picker.data('daterangepicker').startDate.format('DD/MM/YY HH:mm'), end:picker.data('daterangepicker').endDate.format('DD/MM/YY HH:mm'), tzoffset: new Date().getTimezoneOffset(), details:$('#details-manual-entry').val()} ,function() {
5858
getWorkItems();
5959
$("#dialog-manual-entry").dialog("close");
6060
})
@@ -89,7 +89,7 @@
8989
form = dialogWorkItemEditForm.find( "form" );
9090
var id = $(target).data('myid');
9191
var baseUrl = OC.generateUrl("/apps/timetracker/ajax/update-work-interval/"+id);
92-
var jqxhr = $.post( baseUrl, {name:form.find("#name").val()},function() {
92+
var jqxhr = $.post( baseUrl, {name:form.find("#name").val(),details:form.find("#details").val()},function() {
9393
getWorkItems();
9494
$(dialogWorkItemEditForm).dialog("close");
9595
})
@@ -195,7 +195,8 @@
195195

196196
$.each(workItem.children, function (ckey, child){
197197
//debugger;
198-
children.push("<div class='wi-child'><li><div class='wi-child-element'><div class='wi-child-name clickable' data-myid="+child.id+" data-name='"+child.name+"'>"+cutString(child.name,64)+"</div>"+
198+
children.push("<div class='wi-child'><li><div class='wi-child-element'><div class='wi-child-name clickable' data-details='"+child.details+"' data-myid="+child.id+" data-name='"+child.name+"'>"+cutString(child.name,64)+
199+
"<div class='wi-child-details clickable' data-details='"+child.details+"' data-myid="+child.id+" data-name='"+child.name+"'>"+cutString(child.details,64)+"</div>"+"</div>"+
199200
"<span class='fas clickable fa-trash wi-trash' id="+child.id+"></span><span class='set-project' data-myid="+child.id+" data-projectid="+child.projectId+" data-projectname='"+child.projectName+"'></span>"+
200201
"<span class='set-tag' data-myid="+child.id+" data-tagids='"+child.tags.map(function(tag) {return tag.id}).join(',')+"' data-tagnames='"+child.tags.map(function(tag) {return tag.name}).join(',')+"'></span>"+
201202
"<div class='wi-child-hours' data-myid="+child.id+" data-start-date='"+child.start+"' data-end-date='"+(child.start+child.duration)+"'>"+tsToHour(child.start)+"&nbsp;-&nbsp;"+
@@ -258,6 +259,7 @@
258259

259260
form = dialogWorkItemEditForm.find( "form" )
260261
form.find("#name").val($(e.target).data("name"));
262+
form.find("#details").val($(e.target).data("details"));
261263
dialogWorkItemEditForm.dialog("open");
262264
return false;
263265

lib/Controller/AjaxController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public function workIntervals() {
104104
$wa = ['duration' => $wi->duration,
105105
'id' => $wi->id,
106106
'name' => $wi->name,
107+
'details' => $wi->details,
107108
'projectId' => $wi->projectId,
108109
'running' => $wi->running,
109110
'start' => $wi->start,
@@ -231,6 +232,12 @@ public function updateWorkInterval($id) {
231232
}
232233
$wi->setName($this->request->name);
233234
}
235+
if (isset($this->request->details)) {
236+
if (strlen($this->request->details) > 1024){
237+
return new JSONResponse(["Error" => "Details too long"]);
238+
}
239+
$wi->setDetails($this->request->details);
240+
}
234241
if (isset($this->request->projectId)) {
235242
$wi->setProjectId($this->request->projectId);
236243
if ($wi->projectId != null){
@@ -313,6 +320,12 @@ public function addWorkInterval() {
313320
if (isset($this->request->name)) {
314321
$wi->setName($this->request->name);
315322
}
323+
if (isset($this->request->details)) {
324+
if (strlen($this->request->details) > 1024){
325+
return new JSONResponse(["Error" => "Details too long"]);
326+
}
327+
$wi->setDetails($this->request->details);
328+
}
316329
if (isset($this->request->projectId)) {
317330
$wi->setProjectId($this->request->projectId);
318331
if ($wi->projectId != null){

lib/Db/WorkInterval.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class WorkInterval extends Entity {
88

99
public $id;
1010
public $name;
11+
public $details;
1112
public $projectId;
1213
public $userUid;
1314
public $start;
@@ -20,6 +21,7 @@ public function __construct() {
2021

2122
$this->addType('id', 'integer');
2223
$this->addType('name', 'string');
24+
$this->addType('details', 'string');
2325
$this->addType('projectId', 'integer');
2426
$this->addType('userUid', 'string');
2527
$this->addType('start', 'integer');

templates/content/index.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
<p class="validateTips">All form fields are required.</p>
2424
2525
<form>
26-
<fieldset>
26+
<fieldset >
2727
<label for="name">Name</label>
2828
<input type="text" name="name" id="name" value="" class="text ui-widget-content ui-corner-all">
29+
<div class="clear"></div>
30+
<label for="details">Details</label>
31+
<textarea style='vertical-align: middle;width:300px;' name="details" id="details" cols="40" rows="5" value="" id="details" class="text ui-widget-content ui-corner-all"></textarea>
2932
3033
<!-- Allow form submission with keyboard without duplicating the dialog button -->
3134
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
@@ -40,6 +43,9 @@
4043
<fieldset>
4144
<label for="name">Name</label>
4245
<input type="text" name="name" id="name-manual-entry" value="" class="text ui-widget-content ui-corner-all">
46+
<div class="clear"></div>
47+
<label for="details">Details</label>
48+
<textarea style='vertical-align: middle;width:250px;' name="details" cols="40" rows="5" value="" id="details-manual-entry" class="text ui-widget-content ui-corner-all"></textarea>
4349
<!-- <div id='hours-manual-entry'>&nbsp;</div> -->
4450
<label for="hours">Interval</label>
4551
<input type="text" name="hours" id="hours-manual-entry" value="" class="text ui-widget-content ui-corner-all">

0 commit comments

Comments
 (0)