add project subtraction amounts.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-04-05 23:59:27 +02:00
parent 01bc6a8e55
commit c5af5860bf
9 changed files with 97 additions and 49 deletions
+38 -31
View File
@@ -28,39 +28,46 @@
let title = "";
$: {
let level = Math.floor(count / target);
if (level >= COLORS.length - 1 || (level > 1 && green)) {
offs = 0;
ons = target;
offClass = "gold";
onClass = "diamond";
} else {
if (count > 0 && count == (level * target)) {
level -= 1;
if (count > 0 && target > 0) {
let level = Math.floor(count / target);
if (level >= COLORS.length - 1 || (level > 1 && green)) {
offs = 0;
ons = target;
offClass = "gold";
onClass = "diamond";
} else {
if (count > 0 && count == (level * target)) {
level -= 1;
}
ons = count - (level * target);
offs = target - ons;
offClass = COLORS[level];
onClass = COLORS[level + 1];
}
ons = count - (level * target);
offs = target - ons;
offClass = COLORS[level];
onClass = COLORS[level + 1];
}
if (green) {
onClass = "green"
offClass = "none"
}
if (gray) {
onClass = "gray"
offClass = "none"
}
if (contextColor) {
onClass = "sccpb"
offClass = "none"
}
if (green) {
onClass = "green"
offClass = "none"
// Mark it non-segmented if the target is too high. This prevents a clunky progress bar,
// or a browser freeze if you set the target very high.
nonSegmented = (target >= 60);
} else {
offClass = "none";
nonSegmented = false;
ons = 0;
offs = 1;
}
if (gray) {
onClass = "gray"
offClass = "none"
}
if (contextColor) {
onClass = "sccpb"
offClass = "none"
}
// Mark it non-segmented if the target is too high. This prevents a clunky progress bar,
// or a browser freeze if you set the target very high.
nonSegmented = (target >= 60);
}
$: {
@@ -94,10 +101,10 @@
<div style="flex: {offs}" class={"non-segmented off " + offClass}></div>
{/if}
{:else}
{#each {length: ons} as _}
{#each {length: Math.max(ons, 0)} as _}
<div class={"on " + onClass}></div>
{/each}
{#each {length: offs} as _}
{#each {length: Math.max(offs, 0)} as _}
<div class={"off " + offClass}></div>
{/each}
{/if}
@@ -23,6 +23,9 @@
progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * (t.item.groupWeight || 1)).reduce((n,m) => n+m, 0), 1);
progressAmount = Math.max(progressAmount - project.subtractAmount, 0);
progressTarget = Math.max(progressTarget - project.subtractAmount, 0);
if (project.endTime) {
const start = Date.parse(project.startTime || project.createdTime);
const end = Date.parse(project.endTime);
@@ -5,6 +5,7 @@
interface ProjectLike {
tasks?: TaskResult[]
statusTag?: string
subtractAmount?: number,
}
export let project: ProjectLike;
@@ -12,11 +13,16 @@
let progressAmount: number;
let progressTarget: number;
$: progressAmount = (project.tasks||[]).map(t => (t.active || t.statusTag === "to do" || t.statusTag === "on hold")
? Math.min(t.completedAmount, t.itemAmount) * (t.item.groupWeight || 1)
: t.itemAmount * (t.item.groupWeight || 1)
).reduce((n,m) => n+m, 0);
$: progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * (t.item.groupWeight || 1)).reduce((n,m) => n+m, 0), 1);
$: {
progressAmount = (project.tasks||[]).map(t => (t.active || t.statusTag === "to do" || t.statusTag === "on hold")
? Math.min(t.completedAmount, t.itemAmount) * (t.item.groupWeight || 1)
: t.itemAmount * (t.item.groupWeight || 1)
).reduce((n,m) => n+m, 0);
progressTarget = Math.max((project.tasks||[]).map(t => t.itemAmount * (t.item.groupWeight || 1)).reduce((n,m) => n+m, 0), 1);
progressAmount = Math.max(progressAmount - (project.subtractAmount||0), 0);
progressTarget = Math.max(progressTarget - (project.subtractAmount||0), 0);
}
</script>
<Progress thin contextColor count={progressAmount} target={progressTarget} />