Commit ddb3b854 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add list wrapper to process patterns

parent d60ff2f6
Pipeline #137913 failed with stages
in 11 minutes and 12 seconds
......@@ -28,16 +28,14 @@
Methods
</div>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2">Method Patterns</h6>
<div *ngIf="!processPatternList">Loading...</div>
<div *ngIf="processPatternList && processPatternList.length === 0">
No Method Patterns defined.
</div>
<ul
class="list-group"
*ngIf="processPatternList && processPatternList.length > 0"
>
<app-list-wrapper
listTitle="Method Patterns"
[reloading]="reloading"
[loading]="loading"
[noResults]="noResults"
>
<div noResults>No Method Patterns defined.</div>
<ul results class="list-group">
<li
class="
d-flex
......@@ -68,7 +66,7 @@
</div>
</li>
</ul>
</div>
</app-list-wrapper>
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0">Add Method Pattern</h6>
......
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, ViewChild } from '@angular/core';
import { ProcessPattern } from '../../development-process-registry/process-pattern/process-pattern';
import { ProcessPatternService } from '../../development-process-registry/process-pattern/process-pattern.service';
import { FormBuilder, Validators } from '@angular/forms';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { ELEMENT_SERVICE, ListService } from '../../shared/list.service';
@Component({
selector: 'app-process-patterns',
templateUrl: './process-patterns.component.html',
styleUrls: ['./process-patterns.component.css'],
providers: [
ListService,
{ provide: ELEMENT_SERVICE, useExisting: ProcessPatternService },
],
})
export class ProcessPatternsComponent implements OnInit {
processPatternList: ProcessPattern[];
export class ProcessPatternsComponent {
processPatternForm = this.fb.group({
name: ['', Validators.required],
});
......@@ -23,21 +27,10 @@ export class ProcessPatternsComponent implements OnInit {
constructor(
private fb: FormBuilder,
private modalService: NgbModal,
private processPatternService: ProcessPatternService
private listService: ListService<ProcessPattern>,
private modalService: NgbModal
) {}
ngOnInit() {
this.loadProcessPatterns();
}
private loadProcessPatterns() {
this.processPatternService
.getList()
.then((list) => (this.processPatternList = list.docs))
.catch((error) => console.log('LoadProcessPatterns: ' + error));
}
openDeleteProcessPatternModal(processPattern: ProcessPattern) {
this.modalProcessPattern = processPattern;
this.modalReference = this.modalService.open(
......@@ -48,20 +41,28 @@ export class ProcessPatternsComponent implements OnInit {
);
}
deleteProcessPattern(id: string) {
this.processPatternService
.delete(id)
.then(() => this.loadProcessPatterns())
.catch((error) => console.log('DeleteProcessPattern: ' + error));
async deleteProcessPattern(id: string) {
await this.listService.delete(id);
}
async addProcessPattern(processPatternForm: any) {
await this.listService.add({ name: processPatternForm.value.name });
this.processPatternForm.reset();
}
get processPatternList(): ProcessPattern[] {
return this.listService.elements;
}
get noResults(): boolean {
return this.listService.noResults;
}
get loading(): boolean {
return this.listService.loading;
}
addProcessPattern(processPatternForm: any) {
this.processPatternService
.add({ name: processPatternForm.value.name })
.then(() => {
this.processPatternForm.reset();
this.loadProcessPatterns();
})
.catch((error) => console.log('AddProcessPattern: ' + error));
get reloading(): boolean {
return this.listService.reloading;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment