From 834680107474580e30d080cd3ff015dc26ad91d1 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 22 Jun 2020 17:12:09 +0200 Subject: [PATCH] added related user story --- src/app/task-form/task-form.component.html | 9 +- src/app/task-form/task-form.component.ts | 110 +++++++++++---------- src/assets/env.js | 12 +-- 3 files changed, 66 insertions(+), 65 deletions(-) diff --git a/src/app/task-form/task-form.component.html b/src/app/task-form/task-form.component.html index 6bb32ef..d63239f 100644 --- a/src/app/task-form/task-form.component.html +++ b/src/app/task-form/task-form.component.html @@ -1,4 +1,3 @@ - - + + - - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/task-form/task-form.component.ts b/src/app/task-form/task-form.component.ts index 635191e..4c4ca34 100644 --- a/src/app/task-form/task-form.component.ts +++ b/src/app/task-form/task-form.component.ts @@ -1,70 +1,72 @@ import { Component, OnInit, Input } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { - BackendService, - ScrumTask, - Priority, - ScrumStatus, - ScrumCategory, - ScrumUser, - ScrumProject, - ScrumUserstory + BackendService, + ScrumTask, + Priority, + ScrumStatus, + ScrumCategory, + ScrumUser, + ScrumProject, + ScrumUserstory, } from '../services/backend.service'; import { Observable } from 'rxjs'; import { HttpResponse } from '@angular/common/http'; @Component({ - selector: 'app-task-form', - templateUrl: './task-form.component.html', - styleUrls: [ './task-form.component.css' ] + selector: 'app-task-form', + templateUrl: './task-form.component.html', + styleUrls: ['./task-form.component.css'], }) export class TaskFormComponent implements OnInit { - @Input() public task: ScrumTask; - public editing: Boolean; + @Input() public task: ScrumTask; + public editing: Boolean; + public userstoryId: string; - constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {} + constructor( + private backendService: BackendService, + private activeModalService: NgbActiveModal + ) {} - ngOnInit(): void { - if (this.task === null || this.task === undefined) { - this.task = { title: '' }; - this.editing = false; - } else { - this.editing = true; - } - document.getElementById('titleField').focus(); + ngOnInit(): void { + if (this.task === null || this.task === undefined) { + this.task = { title: '' }; + this.editing = false; + } else { + this.editing = true; + } + document.getElementById('titleField').focus(); + this.getRelatedStory(); + } - this.getRelatedStory(); - } + onSubmit() { + if (this.editing) { + this.backendService.putTask(this.task).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } else { + this.backendService.postTask(this.task).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + this.activeModalService.close(this.task); + } - onSubmit() { - if (this.editing) { - this.backendService.putTask(this.task).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } else { - this.backendService.postTask(this.task).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } - this.activeModalService.close(this.task); - } + onClose() { + this.activeModalService.dismiss(this.task); + } - onClose() { - this.activeModalService.dismiss(this.task); - } - - getRelatedStory(): any{ - this.backendService.getUserstory(1).subscribe(response => { - if (response.status > 399) { - alert('Fehler'); - } - else { - console.log(response); - } - }); - } + getRelatedStory() { + this.backendService.getUserstory(2).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.userstoryId = response.body.title; + } + }); + } } diff --git a/src/assets/env.js b/src/assets/env.js index 5b334ef..38fc952 100644 --- a/src/assets/env.js +++ b/src/assets/env.js @@ -1,7 +1,7 @@ (function(window) { - window["env"] = window["env"] || {}; - - // Environment variables - window["env"]["apiUrl"] = "http://localhost:5001"; - window["env"]["debug"] = false; - })(this); \ No newline at end of file + window['env'] = window['env'] || {}; + + // Environment variables + window['env']['apiUrl'] = 'http://taskboard.dev.nig.gl/api'; + window['env']['debug'] = false; +})(this);