Skip to content

Commit 25e9205

Browse files
committed
Changed variable names for cleaner code
1 parent b2da34c commit 25e9205

4 files changed

Lines changed: 56 additions & 56 deletions

File tree

src/app/component/circular-heatmap/circular-heatmap.component.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
</div>
55
<div class="col-md-6">
66
<div id="chart" class="abc">
7-
<mat-card class="example-card" *ngIf="show">
7+
<mat-card class="example-card" *ngIf="showTaskCard">
88
<mat-card-title-group>
9-
<mat-card-title>{{header}}</mat-card-title>
10-
<mat-card-subtitle>{{subheader}}</mat-card-subtitle>
9+
<mat-card-title>{{taskHeader}}</mat-card-title>
10+
<mat-card-subtitle>{{taskSubheader}}</mat-card-subtitle>
1111
</mat-card-title-group>
12-
<mat-card-content *ngFor="let task of tasks;index as i">
13-
<div *ngIf="task.done; then trueBlock else falseBlock"></div>
12+
<mat-card-content *ngFor="let task of tasksData;index as i">
13+
<div *ngIf="task.ifTaskDone; then trueBlock else falseBlock"></div>
1414
<p>
1515
<ng-template #trueBlock>
16-
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="true" color="primary">
17-
{{task["name"]}}
16+
<mat-checkbox (click)="this.toggleCheckbox(i)" [checked]="true" color="primary">
17+
{{task["taskName"]}}
1818
</mat-checkbox>
1919
</ng-template>
2020
<ng-template #falseBlock>
21-
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="false" color="primary">
22-
{{task["name"]}}
21+
<mat-checkbox (click)="this.toggleCheckbox(i)" [checked]="false" color="primary">
22+
{{task["taskName"]}}
2323
</mat-checkbox>
2424
</ng-template>
2525
</p>

src/app/component/circular-heatmap/circular-heatmap.component.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { ymlService } from '../../service/yaml-parser/yaml-parser.service';
33
import * as d3 from 'd3';
44

55
export interface taskSchema{
6-
name:string
7-
done:boolean
6+
taskName:string
7+
ifTaskDone:boolean
88
}
99

1010
export interface cardSchema{
@@ -20,12 +20,12 @@ export interface cardSchema{
2020
styleUrls: ['./circular-heatmap.component.css']
2121
})
2222
export class CircularHeatmapComponent implements OnInit {
23-
maxLevel:number=-1
24-
show:boolean=false
25-
header:string=''
26-
subheader:string=''
27-
tasks:any[]=[]
28-
data:cardSchema[] =[];
23+
maxLevelOfTasks:number=-1
24+
showTaskCard:boolean=false
25+
taskHeader:string=''
26+
taskSubheader:string=''
27+
tasksData:any[]=[]
28+
ALL_CARD_DATA:cardSchema[] =[];
2929
radial_labels:string[]= [];
3030
YamlObject:any;
3131
segment_labels:string[] = [];
@@ -41,7 +41,7 @@ export class CircularHeatmapComponent implements OnInit {
4141
for(let x in this.YamlObject['strings']['en']['maturity_levels']){
4242
var y=parseInt(x)+1
4343
this.radial_labels.push('Level '+y)
44-
this.maxLevel=y
44+
this.maxLevelOfTasks=y
4545
}
4646

4747
});
@@ -55,7 +55,7 @@ export class CircularHeatmapComponent implements OnInit {
5555
for(var x in this.YamlObject['dimension']){
5656
this.segment_labels.push(this.YamlObject['dimension'][x]['subdimension']['name'])
5757
}
58-
for(var l=0 ; l<this.maxLevel; l++){
58+
for(var l=0 ; l<this.maxLevelOfTasks; l++){
5959
for(var x in this.YamlObject['dimension']){
6060
var tempdata:cardSchema={
6161
"Name": "",
@@ -73,53 +73,53 @@ export class CircularHeatmapComponent implements OnInit {
7373
if(Status){
7474
totalImplemented+=1
7575
}
76-
tempdata["Task"].push({"name":nameOfTask,"done":Status})
76+
tempdata["Task"].push({"taskName":nameOfTask,"ifTaskDone":Status})
7777
}
7878
tempdata["Done%"]=totalImplemented/this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)].length
7979
}
8080
catch{
8181
tempdata["Done%"]=-1
8282
}
83-
this.data.push(tempdata)
83+
this.ALL_CARD_DATA.push(tempdata)
8484
}
8585
}
86-
console.log(this.data)
87-
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
86+
console.log(this.ALL_CARD_DATA)
87+
this.loadCircularHeatMap(this.ALL_CARD_DATA, "#chart", this.radial_labels, this.segment_labels);
8888
this.noTasktoGrey()
8989
})
9090
}
9191

92-
checkboxToggle(taskIndex:number){
92+
toggleCheckbox(taskIndex:number){
9393
//console.log('fo')
9494
let _self=this
9595
var index=0;
9696
var cnt=0;
97-
for(var i=0;i<this.data.length;i++){
98-
if(this.data[i]["Name"]===this.header&&this.data[i]["Level"]===this.subheader){
97+
for(var i=0;i<this.ALL_CARD_DATA.length;i++){
98+
if(this.ALL_CARD_DATA[i]["Name"]===this.taskHeader&&this.ALL_CARD_DATA[i]["Level"]===this.taskSubheader){
9999
index=i
100100
break;
101101
}
102102
}
103-
if(this.data[index]["Task"][taskIndex]["done"]){
104-
this.data[index]["Task"][taskIndex]["done"]=false
103+
if(this.ALL_CARD_DATA[index]["Task"][taskIndex]["ifTaskDone"]){
104+
this.ALL_CARD_DATA[index]["Task"][taskIndex]["ifTaskDone"]=false
105105
}
106106
else{
107-
this.data[index]["Task"][taskIndex]["done"]=true
107+
this.ALL_CARD_DATA[index]["Task"][taskIndex]["ifTaskDone"]=true
108108
}
109109
//console.log(this.data[i]["Task"][taskIndex]["done"])
110-
for(var i=0;i< this.data[index]["Task"].length;i++){
111-
console.log(this.data[index]["Task"][i]["done"])
112-
if(this.data[index]["Task"][i]["done"]){
110+
for(var i=0;i< this.ALL_CARD_DATA[index]["Task"].length;i++){
111+
console.log(this.ALL_CARD_DATA[index]["Task"][i]["ifTaskDone"])
112+
if(this.ALL_CARD_DATA[index]["Task"][i]["ifTaskDone"]){
113113
cnt+=1
114114
}
115115
}
116-
this.data[index]['Done%']=cnt/this.data[index]["Task"].length
116+
this.ALL_CARD_DATA[index]['Done%']=cnt/this.ALL_CARD_DATA[index]["Task"].length
117117
//console.log(this.data[index]['Done%'],cnt)
118118
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
119119

120-
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
121-
d3.selectAll("#segment-" + this.data[index]["Name"]+'-'+this.data[index]["Level"].replace(' ','-')).attr("fill", function(p) {
122-
return color(_self.data[index]["Done%"])
120+
this.loadCircularHeatMap(this.ALL_CARD_DATA, "#chart", this.radial_labels, this.segment_labels);
121+
d3.selectAll("#segment-" + this.ALL_CARD_DATA[index]["Name"]+'-'+this.ALL_CARD_DATA[index]["Level"].replace(' ','-')).attr("fill", function(p) {
122+
return color(_self.ALL_CARD_DATA[index]["Done%"])
123123
});
124124

125125
}
@@ -177,11 +177,11 @@ export class CircularHeatmapComponent implements OnInit {
177177

178178
svg.selectAll("path")
179179
.on('click', function(d) {
180-
_self.subheader=d.explicitOriginalTarget.__data__.Level
181-
_self.tasks=d.explicitOriginalTarget.__data__.Task;
182-
_self.header=d.explicitOriginalTarget.__data__.Name
183-
_self.show=true
184-
console.log(_self.tasks)
180+
_self.taskSubheader=d.explicitOriginalTarget.__data__.Level
181+
_self.tasksData=d.explicitOriginalTarget.__data__.Task;
182+
_self.taskHeader=d.explicitOriginalTarget.__data__.Name
183+
_self.showTaskCard=true
184+
console.log(_self.tasksData)
185185
})
186186
.on('mouseover', function(d) {
187187

@@ -384,9 +384,9 @@ export class CircularHeatmapComponent implements OnInit {
384384
}
385385

386386
noTasktoGrey():void{
387-
for (var x in this.data){
388-
if (this.data[x]["Done%"]==-1){
389-
d3.selectAll("#segment-" + this.data[x]["Name"]+'-'+this.data[x]["Level"].replace(' ','-')).attr("fill","#DCDCDC");
387+
for (var x in this.ALL_CARD_DATA){
388+
if (this.ALL_CARD_DATA[x]["Done%"]==-1){
389+
d3.selectAll("#segment-" + this.ALL_CARD_DATA[x]["Name"]+'-'+this.ALL_CARD_DATA[x]["Level"].replace(' ','-')).attr("fill","#DCDCDC");
390390
}
391391
}
392392
}

src/app/component/matrix/matrix.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<mat-chip-list #chipList aria-label="Filter" color="primary">
66
<mat-chip
77
color="primary"
8-
*ngFor="let row of rows"
8+
*ngFor="let row of rowsCurrentlyBeingShown"
99
(removed)="remove(row)"
1010
[selected]=true>
1111
{{row}}

src/app/component/matrix/matrix.component.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ export class MatrixComponent implements OnInit {
3636
lvlColumn: string[]=[];
3737
allRows:string[]=[];
3838
dataSource:any= new MatTableDataSource<MatrixElement>(this.MATRIX_DATA);
39-
rows: string[] = [];
39+
rowsCurrentlyBeingShown: string[] = [];
4040

4141
constructor(private yaml:ymlService,private router: Router) {
4242
this.filteredRows = this.rowCtrl.valueChanges.pipe(
4343
startWith(null),
44-
map((row: string | null) => (row ? this._filter(row) : this.autoCompeteRows.slice())),
44+
map((row: string | null) => (row ? this._filter(row) : this.autoCompeteResults.slice())),
4545
);
4646
}
4747

@@ -112,7 +112,7 @@ export class MatrixComponent implements OnInit {
112112
while(i<this.MATRIX_DATA.length){
113113
if(!this.allRows.includes(this.MATRIX_DATA[i].SubDimension)){
114114
this.allRows.push(this.MATRIX_DATA[i].SubDimension);
115-
this.rows.push(this.MATRIX_DATA[i].SubDimension);
115+
this.rowsCurrentlyBeingShown.push(this.MATRIX_DATA[i].SubDimension);
116116
}
117117
i++;
118118
}
@@ -123,27 +123,27 @@ export class MatrixComponent implements OnInit {
123123
rowCtrl = new FormControl('');
124124
filteredRows: Observable<string[]>;
125125

126-
autoCompeteRows: string[] = [];
126+
autoCompeteResults: string[] = [];
127127

128128
@ViewChild('rowInput') rowInput!: ElementRef<HTMLInputElement>;
129129

130130
//Remove chips
131131
remove(row: string): void {
132-
let index = this.rows.indexOf(row);
132+
let index = this.rowsCurrentlyBeingShown.indexOf(row);
133133
//console.log(this.allRows);
134134
if (index >= 0) {
135-
this.rows.splice(index, 1);
135+
this.rowsCurrentlyBeingShown.splice(index, 1);
136136
}
137-
this.autoCompeteRows.push(row);
137+
this.autoCompeteResults.push(row);
138138
this.dataSource.data.splice(index,1);
139139
this.dataSource._data.next(this.dataSource.data)
140140
}
141141

142142
//Add chips
143143
selected(event: MatAutocompleteSelectedEvent): void {
144-
let autoIndex = this.autoCompeteRows.indexOf(event.option.viewValue);
145-
this.autoCompeteRows.splice(autoIndex,1);
146-
this.rows.push(event.option.viewValue);
144+
let autoIndex = this.autoCompeteResults.indexOf(event.option.viewValue);
145+
this.autoCompeteResults.splice(autoIndex,1);
146+
this.rowsCurrentlyBeingShown.push(event.option.viewValue);
147147
this.rowInput.nativeElement.value = '';
148148
this.rowCtrl.setValue(null);
149149
//console.log(this.allRows,event.option.viewValue);
@@ -158,7 +158,7 @@ export class MatrixComponent implements OnInit {
158158
private _filter(value: string): string[] {
159159
const filterValue = value.toLowerCase();
160160

161-
return this.autoCompeteRows.filter(row => row.toLowerCase().includes(filterValue));
161+
return this.autoCompeteResults.filter(row => row.toLowerCase().includes(filterValue));
162162
}
163163

164164
// task description routing + providing parameters

0 commit comments

Comments
 (0)