Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
fix(progress): Change way truncated tasks are displayed to fix progre…
Browse files Browse the repository at this point in the history
…ss width

Close #262
  • Loading branch information
Toilal committed Feb 4, 2017
1 parent 00a5f81 commit 4ec4212
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 81 deletions.
73 changes: 46 additions & 27 deletions assets/angular-gantt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 46 additions & 27 deletions demo/dist/scripts/vendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -55962,29 +55962,36 @@ Github: https://github.com/angular-gantt/angular-gantt.git
modelWidth = this.rowsManager.gantt.getPositionByDate(moment(this.model.to).endOf('day')) - modelLeft;
}

if (modelLeft === undefined || modelWidth === undefined ||
modelLeft + modelWidth < 0 || modelLeft > maxModelLeft) {
var minModelLeft = -modelWidth;
if (modelLeft < minModelLeft) {
modelLeft = minModelLeft;
}

if (modelLeft > maxModelLeft) {
modelLeft = maxModelLeft;
}

if (modelLeft === undefined || modelWidth === undefined) {
this.left = undefined;
this.width = undefined;
} else {
this.left = Math.min(Math.max(modelLeft, 0), this.rowsManager.gantt.width);
this.left = modelLeft;
this.width = modelWidth;
if (modelLeft < 0) {
this.truncatedLeft = true;
if (modelWidth + modelLeft > this.rowsManager.gantt.width) {
this.truncatedRight = true;
this.width = this.rowsManager.gantt.width;
} else {
this.truncatedRight = false;
this.width = modelWidth + modelLeft;
}
this.truncatedLeftOffset = -modelLeft;
this.truncatedRight = false;
this.truncatedRightOffset = undefined;
} else if (modelWidth + modelLeft > this.rowsManager.gantt.width) {
this.truncatedRight = true;
this.truncatedRightOffset = modelWidth + modelLeft - this.rowsManager.gantt.width;
this.truncatedLeft = false;
this.width = this.rowsManager.gantt.width - modelLeft;
this.truncatedLeftOffset = undefined;
} else {
this.truncatedLeft = false;
this.truncatedLeftOffset = undefined;
this.truncatedRight = false;
this.width = modelWidth;
this.truncatedRightOffset = modelWidth + modelLeft - this.rowsManager.gantt.width;
}

if (this.width < 0) {
Expand Down Expand Up @@ -56361,28 +56368,40 @@ Github: https://github.com/angular-gantt/angular-gantt.git
var lastColumn = this.gantt.columnsManager.getLastColumn();
var maxModelLeft = lastColumn ? lastColumn.left + lastColumn.width : 0;

if (this.modelLeft + this.modelWidth < 0 || this.modelLeft > maxModelLeft) {
var modelLeft = this.modelLeft;
var modelWidth = this.modelWidth;

var minModelLeft = -modelWidth;
if (modelLeft < minModelLeft) {
modelLeft = minModelLeft;
}

if (modelLeft > maxModelLeft) {
modelLeft = maxModelLeft;
}


if (modelLeft === undefined || modelWidth === undefined) {
this.left = undefined;
this.width = undefined;
} else {
this.left = Math.min(Math.max(this.modelLeft, 0), this.gantt.width);
if (this.modelLeft < 0) {
this.left = modelLeft;
this.width = modelWidth;
if (modelLeft < 0) {
this.truncatedLeft = true;
if (this.modelWidth + this.modelLeft > this.gantt.width) {
this.truncatedRight = true;
this.width = this.gantt.width;
} else {
this.truncatedRight = false;
this.width = this.modelWidth + this.modelLeft;
}
} else if (this.modelWidth + this.modelLeft > this.gantt.width) {
this.truncatedLeftOffset = -modelLeft;
this.truncatedRight = false;
this.truncatedRightOffset = undefined;
} else if (modelWidth + modelLeft > this.rowsManager.gantt.width) {
this.truncatedRight = true;
this.truncatedRightOffset = modelWidth + modelLeft - this.rowsManager.gantt.width;
this.truncatedLeft = false;
this.width = this.gantt.width - this.modelLeft;
this.truncatedLeftOffset = undefined;
} else {
this.truncatedLeft = false;
this.truncatedLeftOffset = undefined;
this.truncatedRight = false;
this.width = this.modelWidth;
this.truncatedRightOffset = modelWidth + modelLeft - this.rowsManager.gantt.width;
}

if (this.width < 0) {
Expand Down Expand Up @@ -58188,8 +58207,8 @@ angular.module('gantt.templates', []).run(['$templateCache', function ($template
'\n' +
' <script type="text/ng-template" id="template/ganttTaskForeground.tmpl.html">\n' +
' <div class="gantt-task-foreground">\n' +
' <div ng-if="task.truncatedRight" class="gantt-task-truncated-right">&gt;</div>\n' +
' <div ng-if="task.truncatedLeft" class="gantt-task-truncated-left">&lt;</div>\n' +
' <div ng-if="task.truncatedRight" class="gantt-task-truncated-right" ng-style="{\'padding-right\': task.truncatedRightOffset + \'px\'}">&gt;</div>\n' +
' <div ng-if="task.truncatedLeft" class="gantt-task-truncated-left" ng-style="{\'padding-left\': task.truncatedLeftOffset + \'px\'}">&lt;</div>\n' +
' </div>\n' +
' </script>\n' +
'\n' +
Expand Down
31 changes: 19 additions & 12 deletions src/core/logic/task/task.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,36 @@
modelWidth = this.rowsManager.gantt.getPositionByDate(moment(this.model.to).endOf('day')) - modelLeft;
}

if (modelLeft === undefined || modelWidth === undefined ||
modelLeft + modelWidth < 0 || modelLeft > maxModelLeft) {
var minModelLeft = -modelWidth;
if (modelLeft < minModelLeft) {
modelLeft = minModelLeft;
}

if (modelLeft > maxModelLeft) {
modelLeft = maxModelLeft;
}

if (modelLeft === undefined || modelWidth === undefined) {
this.left = undefined;
this.width = undefined;
} else {
this.left = Math.min(Math.max(modelLeft, 0), this.rowsManager.gantt.width);
this.left = modelLeft;
this.width = modelWidth;
if (modelLeft < 0) {
this.truncatedLeft = true;
if (modelWidth + modelLeft > this.rowsManager.gantt.width) {
this.truncatedRight = true;
this.width = this.rowsManager.gantt.width;
} else {
this.truncatedRight = false;
this.width = modelWidth + modelLeft;
}
this.truncatedLeftOffset = -modelLeft;
this.truncatedRight = false;
this.truncatedRightOffset = undefined;
} else if (modelWidth + modelLeft > this.rowsManager.gantt.width) {
this.truncatedRight = true;
this.truncatedRightOffset = modelWidth + modelLeft - this.rowsManager.gantt.width;
this.truncatedLeft = false;
this.width = this.rowsManager.gantt.width - modelLeft;
this.truncatedLeftOffset = undefined;
} else {
this.truncatedLeft = false;
this.truncatedLeftOffset = undefined;
this.truncatedRight = false;
this.width = modelWidth;
this.truncatedRightOffset = modelWidth + modelLeft - this.rowsManager.gantt.width;
}

if (this.width < 0) {
Expand Down
38 changes: 25 additions & 13 deletions src/core/logic/timespan/timespan.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,40 @@
var lastColumn = this.gantt.columnsManager.getLastColumn();
var maxModelLeft = lastColumn ? lastColumn.left + lastColumn.width : 0;

if (this.modelLeft + this.modelWidth < 0 || this.modelLeft > maxModelLeft) {
var modelLeft = this.modelLeft;
var modelWidth = this.modelWidth;

var minModelLeft = -modelWidth;
if (modelLeft < minModelLeft) {
modelLeft = minModelLeft;
}

if (modelLeft > maxModelLeft) {
modelLeft = maxModelLeft;
}


if (modelLeft === undefined || modelWidth === undefined) {
this.left = undefined;
this.width = undefined;
} else {
this.left = Math.min(Math.max(this.modelLeft, 0), this.gantt.width);
if (this.modelLeft < 0) {
this.left = modelLeft;
this.width = modelWidth;
if (modelLeft < 0) {
this.truncatedLeft = true;
if (this.modelWidth + this.modelLeft > this.gantt.width) {
this.truncatedRight = true;
this.width = this.gantt.width;
} else {
this.truncatedRight = false;
this.width = this.modelWidth + this.modelLeft;
}
} else if (this.modelWidth + this.modelLeft > this.gantt.width) {
this.truncatedLeftOffset = -modelLeft;
this.truncatedRight = false;
this.truncatedRightOffset = undefined;
} else if (modelWidth + modelLeft > this.gantt.width) {
this.truncatedRight = true;
this.truncatedRightOffset = modelWidth + modelLeft - this.gantt.width;
this.truncatedLeft = false;
this.width = this.gantt.width - this.modelLeft;
this.truncatedLeftOffset = undefined;
} else {
this.truncatedLeft = false;
this.truncatedLeftOffset = undefined;
this.truncatedRight = false;
this.width = this.modelWidth;
this.truncatedRightOffset = modelWidth + modelLeft - this.gantt.width;
}

if (this.width < 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/template/gantt.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@

<script type="text/ng-template" id="template/ganttTaskForeground.tmpl.html">
<div class="gantt-task-foreground">
<div ng-if="task.truncatedRight" class="gantt-task-truncated-right">&gt;</div>
<div ng-if="task.truncatedLeft" class="gantt-task-truncated-left">&lt;</div>
<div ng-if="task.truncatedRight" class="gantt-task-truncated-right" ng-style="{'padding-right': task.truncatedRightOffset + 'px'}">&gt;</div>
<div ng-if="task.truncatedLeft" class="gantt-task-truncated-left" ng-style="{'padding-left': task.truncatedLeftOffset + 'px'}">&lt;</div>
</div>
</script>

Expand Down

0 comments on commit 4ec4212

Please sign in to comment.