Skip to content

Commit a7036a5

Browse files
authored
Merge pull request #153 from 0x41head/angular-ui
Angular UI
2 parents dc07064 + d77c4f0 commit a7036a5

File tree

4 files changed

+42
-52
lines changed

4 files changed

+42
-52
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

Development.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22

33
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.3.6.
44

5-
## Development server
5+
### Development server
66

77
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
88

9-
## Code scaffolding
9+
### Code scaffolding
1010

1111
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
1212

13-
## Build
13+
### Build
1414

1515
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
1616

17-
## Running unit tests
17+
### Running unit tests
1818

1919
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
2020

21-
## Running end-to-end tests
21+
## Coding Style Conventions
2222

23-
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
23+
- We follow the coding style defined by [ESLint](https://eslint.org/).
24+
- We also use [Prettier](https://prettier.io/docs/en/index.html) as our opinionated code formatter.
2425

25-
## Further help
2626

27-
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

src/app/component/mapping/mapping.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<mat-form-field class="filterSection" appearance="fill">
55
<mat-label>Filter</mat-label>
66
<mat-chip-list #chipList aria-label="Filter" color="primary">
7-
<mat-chip *ngFor="let chip of currentChip" (removed)="remove(chip)">
7+
<mat-chip *ngFor="let chip of currentChip" (removed)="removeChip(chip)">
88
{{ chip }}
99
<button matChipRemove>
1010
<mat-icon>cancel</mat-icon>
@@ -19,7 +19,7 @@
1919
</mat-chip-list>
2020
<mat-autocomplete
2121
#auto="matAutocomplete"
22-
(optionSelected)="selected($event)">
22+
(optionSelected)="addChip($event)">
2323
<mat-option
2424
*ngFor="let filter of filteredChips | async"
2525
[value]="filter">

src/app/component/mapping/mapping.component.ts

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -320,18 +320,17 @@ export class MappingComponent implements OnInit {
320320
//console.log(this.temp)
321321
}
322322

323-
// remong filter chip
324-
remove(chip: string): void {
323+
// remove filter chip
324+
removeChip(chip: string): void {
325325
const index = this.currentChip.indexOf(chip);
326-
//console.log(fruit)
327326
if (index >= 0) {
328327
this.currentChip.splice(index, 1);
329328
}
330329
this.changeTableBasedOnCurrentFilter();
331330
}
332331

333332
//adding filter chip
334-
selected(event: MatAutocompleteSelectedEvent): void {
333+
addChip(event: MatAutocompleteSelectedEvent): void {
335334
this.currentChip.push(event.option.viewValue);
336335
this.changeTableBasedOnCurrentFilter();
337336
}
@@ -344,38 +343,47 @@ export class MappingComponent implements OnInit {
344343
);
345344
}
346345

346+
//check sort value and change table data accordingly
347+
checkSortValueAndChangeTableData(
348+
taskData: any,
349+
ISOData: any,
350+
SAMMData: any
351+
): void {
352+
if (this.currentlySortingByTask) {
353+
this.dataSource = taskData;
354+
} else if (this.currentlySortingByISO) {
355+
this.dataSource = ISOData;
356+
} else {
357+
this.dataSource = SAMMData;
358+
}
359+
}
360+
347361
changeTableBasedOnCurrentFilter() {
348362
if (this.currentChip.length > 1 || this.currentChip.length == 0) {
349363
// both planned and performed actvities are selected
350364

351365
//Check current sort value
352-
if (this.currentlySortingByTask) {
353-
this.dataSource = this.allMappingDataSortedByTask;
354-
} else if (this.currentlySortingByISO) {
355-
this.dataSource = this.allMappingDataSortedByISO;
356-
} else {
357-
this.dataSource = this.allMappingDataSortedBySAMM;
358-
}
366+
this.checkSortValueAndChangeTableData(
367+
this.allMappingDataSortedByTask,
368+
this.allMappingDataSortedByISO,
369+
this.allMappingDataSortedBySAMM
370+
);
359371
} else if (this.currentChip[0] == 'Planned Activities') {
360372
// planned actvities shows planned data
361373

362374
//Check current sort value
363-
if (this.currentlySortingByTask) {
364-
this.dataSource = this.plannedMappingDataSortedByTask;
365-
} else if (this.currentlySortingByISO) {
366-
this.dataSource = this.plannedMappingDataSortedByISO;
367-
} else {
368-
this.dataSource = this.plannedMappingDataSortedBySAMM;
369-
}
375+
this.checkSortValueAndChangeTableData(
376+
this.plannedMappingDataSortedByTask,
377+
this.plannedMappingDataSortedByISO,
378+
this.plannedMappingDataSortedBySAMM
379+
);
370380
} else {
371381
//Check current sort value
372-
if (this.currentlySortingByTask) {
373-
this.dataSource = this.performedMappingDataSortedByTask;
374-
} else if (this.currentlySortingByISO) {
375-
this.dataSource = this.performedMappingDataSortedByISO;
376-
} else {
377-
this.dataSource = this.performedMappingDataSortedBySAMM;
378-
}
382+
this.checkSortValueAndChangeTableData(
383+
this.performedMappingDataSortedByTask,
384+
this.performedMappingDataSortedByISO,
385+
this.performedMappingDataSortedBySAMM
386+
);
379387
}
380388

381389
this.chipInput.nativeElement.value = '';

0 commit comments

Comments
 (0)