Skip to content

Commit 11daf27

Browse files
Save work
1 parent eb298e4 commit 11daf27

18 files changed

+359
-117
lines changed

src/app/elements/charts/resultResolutions/resultResolutions.charts.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ export class ResultResolutionsChartsComponent implements OnChanges, OnInit, OnDe
112112
for (const resultResolution of this.listOfResultResolutions) {
113113
this.doughnutChartData.push(
114114
this.shownTestResults.filter(
115-
x => x.test_resolution.name === resultResolution.name
115+
x => x.issue.resolution.name === resultResolution.name
116116
).length
117117
);
118118
}
119119
}
120120

121121
calculatePrecentageAndCount(resultResolution: String): String {
122122
const num = this.shownTestResults.filter(
123-
x => x.test_resolution.name === resultResolution
123+
x => x.issue.resolution.name === resultResolution
124124
).length;
125125
const percentage = (num / this.shownTestResults.length) * 100;
126126
return ` | ${percentage.toFixed(1)}% | ${num}`;

src/app/elements/lookup/baseLookup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class BaseLookupComponent implements OnInit, OnChanges, A1qaLookup {
120120
}
121121
itemValue = itemValue[prop];
122122
});
123-
if (typeof itemValue === 'number') {
123+
if (typeof itemValue === 'number' && itemValue.toString().length < 14 && itemValue.toString().length > 9 ) {
124124
itemValue = this.datepipe.transform(new Date(itemValue), 'yyyy-MM-dd hh:mm:ss a');
125125
}
126126
textToShow = `${textToShow} ${itemValue}`;
@@ -130,7 +130,7 @@ export class BaseLookupComponent implements OnInit, OnChanges, A1qaLookup {
130130
}
131131
return textToShow.trim();
132132
}
133-
return '';
133+
return this.placeholder;
134134
}
135135

136136
sort() {

src/app/elements/lookup/colored/lookupColors.component.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
.button-text {
77
overflow: hidden;
88
text-overflow: ellipsis;
9-
width: calc(100% - 12px);
9+
width: calc(100% - 15px);
1010
margin: 0;
1111
}

src/app/elements/table/table.filter.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,13 @@
286286

287287
<lookup-autocomplete *ngIf="col.type === 'lookup-autocomplete'" [cutLongText]="true"
288288
[small]="true" [allowEmptyValue]="col.lookup.allowEmpty"
289+
[allowCreation]="col.lookup.allowCreation"
289290
[propertiesToShow]="col.lookup.propToShow" [array]="col.lookup.values"
290291
[model]="transformationsService.getPropertyValue(entity, col.lookup.entity)"
291292
[disabled]="!col.editable || entity.constantRow || notEditableByProperty(entity, col)"
292293
placeholder="Not Assigned"
293-
(modelChange)="setPropertyValue(entity, col.lookup.entity, $event)">
294+
(modelChange)="setPropertyValue(entity, col.lookup.entity, $event)"
295+
(searchText)="handleLookupCreation($event, col, entity)">
294296
</lookup-autocomplete>
295297

296298
<lookup-colored *ngIf="col.type === 'lookup-colored'" [cutLongText]="true" [small]="true"

src/app/elements/table/table.filter.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class TableFilterComponent implements OnInit, AfterViewInit, OnDestroy, O
5454
@Output() shownData = new EventEmitter();
5555
@Output() refresh = new EventEmitter();
5656
@Output() bulkChanges = new EventEmitter();
57+
@Output() lookupCreation = new EventEmitter<{value: string, column: TFColumn, entity: any}>();
5758

5859
@ViewChild(DataTable) datatable: DataTable;
5960

@@ -168,6 +169,10 @@ export class TableFilterComponent implements OnInit, AfterViewInit, OnDestroy, O
168169
return undefined;
169170
}
170171

172+
handleLookupCreation(value: string, column: TFColumn, entity: any) {
173+
this.lookupCreation.emit({ value, column, entity });
174+
}
175+
171176
applyFilters() {
172177
if (this.data) {
173178
this.filteredData = this.filterHelper.applyFilters(this.appliedFilters, this.data);

src/app/elements/table/tfColumn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class TFLookup {
4848
placeholder?: string;
4949
propToShow: string[];
5050
allowEmpty?= false;
51+
allowCreation?= false;
5152
}
5253

5354
export class TFDots {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.mt-overlay {
2+
display: block;
3+
}
4+
5+
.show-modal {
6+
opacity: 1;
7+
}
8+
9+
.modal-dialog {
10+
margin: 9rem auto !important;
11+
max-width: 800px !important;
12+
}
13+
14+
.issue-fields > div:not(:last-child) {
15+
margin-bottom: 5px;
16+
}
17+
18+
.modal-footer {
19+
margin-top: 5px;
20+
}
21+
22+
.update-results-label {
23+
position: absolute;
24+
top: 0;
25+
left: 60;
26+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<div [hidden]="isHidden" class="overlay mt-overlay modal fade" [ngClass]="{'show-modal': !this.isHidden}">
2+
<div class="modal-dialog" role="document">
3+
<div class="modal-content">
4+
5+
<div class="modal-header">
6+
<h4 class="modal-title">Create Issue</h4>
7+
<button type="button" class="close" aria-label="Close" (click)="hideModal()">
8+
<span aria-hidden="true">&times;</span>
9+
</button>
10+
</div>
11+
12+
<div class="modal-body">
13+
<div class="row">
14+
<div class="col-sm-12">
15+
<input type="text" class="form-control" placeholder="Title" [(ngModel)]="issue.title">
16+
</div>
17+
</div>
18+
19+
<div class="row">
20+
<br class="col-sm-12">
21+
</div>
22+
23+
<div class="row">
24+
<div *ngIf="issue.expression" class="col-sm-12">
25+
<ui-switch class="clearfix" size="small" [(ngModel)]="updateResults" id="update-results"></ui-switch>
26+
<label class="update-results-label" for="update-results">Assigne to Results that fit the expression</label>
27+
</div>
28+
<div class="col-sm-8">
29+
<label for="issue-description">Description:</label>
30+
<textarea id="issue-description" class="form-control" placeholder="Description" name="description"
31+
id="issue-desciption" cols="30" rows="12" [(ngModel)]="issue.description"></textarea>
32+
</div>
33+
<div class="col-sm-4 issue-fields">
34+
<div class="col-sm-12 no-padding">
35+
<label for="issue-resolution">Resolution*:</label>
36+
<lookup-colored *ngIf="resolutions" id="issue-resolution" [cutLongText]="true" [colorProperty]="'color'"
37+
[propertiesToShow]="['name']" [array]="resolutions" placeholder="Resolution" [allowEmptyValue]="false"
38+
[model]="issue.resolution" (modelChange)="updateResolution($event)">
39+
</lookup-colored>
40+
</div>
41+
<div class="col-sm-12 no-padding">
42+
<label for="issue-assignee">Assignee:</label>
43+
<lookup-autocomplete *ngIf="users" id="issue-assignee" [cutLongText]="true"
44+
[propertiesToShow]="['first_name', 'second_name']" [array]="users" placeholder="Assignee"
45+
[allowEmptyValue]="true" [model]="issue.assignee" (modelChange)="updateAssignee($event)">
46+
</lookup-autocomplete>
47+
</div>
48+
<div class="col-sm-12 no-padding">
49+
<label for="issue-expression">Regular Expression:</label>
50+
<input id="issue-expression" type="text" class="form-control" placeholder="Regular Expression"
51+
[(ngModel)]="issue.expression">
52+
</div>
53+
<div class="col-sm-12 no-padding">
54+
<label for="issue-external-url">External Issue:</label>
55+
<input id="issue-external-url" type="text" class="form-control" placeholder="External Issue"
56+
[(ngModel)]="issue.external_url">
57+
</div>
58+
</div>
59+
</div>
60+
61+
<div class="col-sm-12 modal-footer modal-buttons">
62+
<div class="modal-buttons-form">
63+
<button *ngFor="let button of buttons" type="button" autofocus (click)="doAction(button.execute)"
64+
class="btn btn-sm btn-secondary" [ngClass]="{
65+
'btn-secondary': !button.execute,
66+
'btn-success': button.execute
67+
}">{{button.name}}</button>
68+
</div>
69+
</div>
70+
</div>
71+
</div>
72+
</div>
73+
</div>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { Component, OnInit, Input } from '@angular/core';
2+
import { BasePopupComponent } from '../../../../elements/modals/basePopup.component';
3+
import { Issue } from '../../../../shared/models/issue';
4+
import { ResultResolution } from '../../../../shared/models/result_resolution';
5+
import { User } from '../../../../shared/models/user';
6+
import { IssueService } from '../../../../services/issue.service';
7+
import { ActivatedRoute } from '@angular/router';
8+
import { UserService } from '../../../../services/user.services';
9+
10+
@Component({
11+
selector: 'issue-create-modal',
12+
templateUrl: './issue-create.modal.component.html',
13+
styleUrls: ['./issue-create.modal.component.css']
14+
})
15+
export class CreateIssueModalComponent extends BasePopupComponent implements OnInit {
16+
@Input() resolutions: ResultResolution[];
17+
@Input() users: User[];
18+
@Input() title: string;
19+
issue: Issue;
20+
updateResults = true;
21+
22+
constructor(
23+
public userService: UserService,
24+
private route: ActivatedRoute,
25+
private issueService: IssueService
26+
) {
27+
super();
28+
}
29+
30+
ngOnInit() {
31+
this.buttons = [{
32+
name: 'Create',
33+
execute: true
34+
}, {
35+
name: 'Cancel',
36+
execute: false
37+
}];
38+
this.issue = new Issue();
39+
if (this.title) {
40+
this.issue.title = this.title;
41+
}
42+
this.issue.project_id = this.route.snapshot.params.projectId;
43+
this.issue.creator_id = this.userService.currentUser().id;
44+
this.issue.status_id = 1;
45+
this.updateResolution(this.resolutions.find(x => x.id === 1));
46+
}
47+
48+
updateResolution(resolution: ResultResolution) {
49+
this.issue.resolution = resolution;
50+
this.issue.resolution_id = resolution.id;
51+
}
52+
53+
updateAssignee(user: User) {
54+
this.issue.assignee = user;
55+
this.issue.assignee_id = user.id;
56+
}
57+
58+
async doAction(execute: boolean) {
59+
if (execute) {
60+
if (this.isIssueValid()) {
61+
const issue = await this.issueService.createIssue(this.issue, this.updateResults);
62+
this.execute.emit({ executed: true, result: issue });
63+
} else {
64+
this.issueService.handleSimpleError('Fill all required fields!', 'You should fill Title and Resolution fields!');
65+
}
66+
} else {
67+
this.execute.emit({ executed: false });
68+
}
69+
}
70+
71+
isIssueValid(): boolean {
72+
if (!this.issue.title || !this.issue.resolution_id) {
73+
return false;
74+
}
75+
76+
return true;
77+
}
78+
}

src/app/pages/project/issue/issue-list/issue-list.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
<h2 id="issues-list">Issues</h2>
55
</div>
66
<div *ngIf="canEdit" class="col-sm-6">
7-
<button class="btn btn-primary pull-right" id="create-issue-button">Create Issue</button>
7+
<button class="btn btn-primary pull-right" id="create-issue-button" (click)="showCreate()">Create Issue</button>
88
</div>
99
</div>
1010
</div>
1111

1212
<div class="panel-body">
13+
<issue-create-modal *ngIf="!hideCreateModal" (execute)="execute($event)" (closed)="wasClosed()" [resolutions]="resolutions" [users]="users" ></issue-create-modal>
1314
<table-filter id="issues-table" *ngIf="issues && columns" [data]="issues" [columns]="columns"
1415
[hiddenColumns]="hiddenColumns" [defaultSortBy]="defSort" (action)="handleAction($event)" [queryParams]="true"
1516
(dataChange)="updateIssue($event)" (rowClick)="rowClicked($event)" rowsOnPage="20">

0 commit comments

Comments
 (0)