Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
Fix couple of bugs due to previous PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed May 2, 2018
1 parent 3c4aece commit ca1246b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 34 deletions.
53 changes: 31 additions & 22 deletions Assets/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,7 @@ Gantt.prototype.addBlocks = function(slider, start) {
}).append(text);

if (series.type === 'task') {
if (size >= 4) {
text.append($('<span>', {title: "test"}).text(series.progress + ' - #' + series.id + ' ' + series.title));
}
else if (size >= 2) {
text.append($('<span>').text(series.progress));
}
this.addTaskBarText(text, series, size);
}

block.data("record", series);
Expand All @@ -221,6 +216,15 @@ Gantt.prototype.addBlocks = function(slider, start) {
}
};

Gantt.prototype.addTaskBarText = function(container, record, size) {
if (size >= 4) {
container.html($('<span>').text(record.progress + ' - #' + record.id + ' ' + record.title));
}
else if (size >= 2) {
container.html($('<span>').text(record.progress));
}
};

// Get tooltip for vertical header
Gantt.prototype.getVerticalHeaderTooltip = function(record) {
if (record.type === 'task') {
Expand Down Expand Up @@ -282,28 +286,31 @@ Gantt.prototype.getTooltipFooter = function(record, tooltip) {
Gantt.prototype.setBarColor = function(block, record) {
block.css("background-color", record.color.background);
block.css("border-color", record.color.border);

if (record.not_defined) {
block.addClass("ganttview-block-not-defined");
if (record.date_started_not_defined) {
block.css("border-left", "2px solid gray");
block.css("border-left", "2px solid #000");
}

if (record.date_due_not_defined) {
block.css("border-right", "2px solid gray");
block.css("border-right", "2px solid #000");
}
}

if (record.progress != "0%") {
block.append(jQuery("<div>", {
"css": {
"z-index": 0,
"position": "absolute",
"top": 0,
"bottom": 0,
"background-color": record.color.border,
"width": record.progress,
"opacity": 0.4
}
}));
var progressBar = $(block).find(".ganttview-progress-bar");

if (progressBar.length) {
progressBar.css("width", record.progress);
} else {
block.append(jQuery("<div>", {
"class": "ganttview-progress-bar",
"css": {
"background-color": record.color.border,
"width": record.progress,
}
}));
}
}
};

Expand Down Expand Up @@ -354,7 +361,8 @@ Gantt.prototype.updateDataAndPosition = function(block, startDate) {
var daysFromStart = Math.round(offset / this.options.cellWidth);
var newStart = this.addDays(this.cloneDate(startDate), daysFromStart);
if (!record.date_started_not_defined || this.compareDate(newStart, record.start)) {
record.start = this.addDays(this.cloneDate(startDate), daysFromStart+1);
record.start = this.addDays(this.cloneDate(startDate), daysFromStart);
record.date_started_not_defined = true;
}
else if (record.date_started_not_defined) {
delete record.start;
Expand All @@ -366,13 +374,14 @@ Gantt.prototype.updateDataAndPosition = function(block, startDate) {
var newEnd = this.addDays(this.cloneDate(newStart), numberOfDays);
if (!record.date_due_not_defined || this.compareDate(newEnd, record.end)) {
record.end = newEnd;
record.date_due_not_defined = true;
}
else if (record.date_due_not_defined) {
delete record.end;
}

if (record.type === "task" && numberOfDays > 0) {
jQuery("div.ganttview-block-text", block).text(record.progress);
this.addTaskBarText(jQuery("div.ganttview-block-text", block), record, numberOfDays);
}

block.data("record", record);
Expand Down
8 changes: 8 additions & 0 deletions Assets/gantt.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ div.ganttview-block-text {
div.ganttview-block div.ui-resizable-handle.ui-resizable-s {
bottom: 0;
}

div.ganttview-progress-bar {
z-index: 0;
position: absolute;
top: 0;
bottom: 0;
opacity: 0.4;
}
28 changes: 19 additions & 9 deletions Controller/TaskGanttController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,28 @@ public function show()
public function save()
{
$this->getProject();
$values = $this->request->getJson();
$changes = $this->request->getJson();
$values = [];

$result = $this->taskModificationModel->update(array(
'id' => $values['id'],
'date_started' => strtotime($values['start']),
'date_due' => strtotime($values['end']),
));
if (! empty($changes['start'])) {
$values['date_started'] = strtotime($changes['start']);
}

if (! empty($changes['end'])) {
$values['date_due'] = strtotime($changes['end']);
}

if (! empty($values)) {
$values['id'] = $changes['id'];
$result = $this->taskModificationModel->update($values);

if (! $result) {
$this->response->json(array('message' => 'Unable to save task'), 400);
if (! $result) {
$this->response->json(array('message' => 'Unable to save task'), 400);
} else {
$this->response->json(array('message' => 'OK'), 201);
}
} else {
$this->response->json(array('message' => 'OK'), 201);
$this->response->json(array('message' => 'Ignored'), 200);
}
}
}
4 changes: 2 additions & 2 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '1.0.3';
return '1.0.4';
}

public function getPluginHomepage()
Expand All @@ -65,6 +65,6 @@ public function getPluginHomepage()

public function getCompatibleVersion()
{
return '>=1.0.43';
return '>1.2.3';
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Author
Requirements
------------

- Kanboard >= 1.0.43
- Kanboard > 1.2.3

Installation
------------
Expand Down

0 comments on commit ca1246b

Please sign in to comment.