Skip to content
Snippets Groups Projects
Commit 216668ba authored by OZGCloud's avatar OZGCloud
Browse files

OZG-157 OZG-156 OZG-159 fix spinner in buttons; change css -> scss

parent 9c1c7c82
No related branches found
No related tags found
No related merge requests found
Showing
with 154 additions and 113 deletions
......@@ -7,7 +7,6 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule, Routes } from '@angular/router';
import { ApiRootModule } from '@goofy-client/api-root-shared';
import { AppSharedModule } from '@goofy-client/app-shared';
import { CommandSharedModule } from '@goofy-client/command-shared';
import { EnvironmentModule } from '@goofy-client/environment-shared';
import { NavigationModule } from '@goofy-client/navigation';
import { UiModule } from '@goofy-client/ui';
......@@ -41,8 +40,7 @@ const routes: Routes = [
}),
ApiRootModule,
NavigationModule,
AppSharedModule,
CommandSharedModule
AppSharedModule
],
providers: [
{ provide: LOCALE_ID, useValue: 'de' }
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AppService } from './app.service';
import { NgModule } from '@angular/core';
import { RestModule } from '@ngxp/rest';
import { AppService } from './app.service';
@NgModule({
imports: [
......
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { CommandRepository } from './command.repository';
import { CommandService } from './command.service';
@NgModule({
imports: [CommonModule],
providers: [
CommandService,
CommandRepository
]
imports: [CommonModule]
})
export class CommandSharedModule { }
......@@ -4,7 +4,7 @@ import { Observable } from "rxjs";
import { CommandLinkRel } from "./command.linkrel";
import { Command, CommandResource, CommandStatus } from "./command.model";
@Injectable()
@Injectable({ providedIn: 'root' })
export class CommandRepository {
constructor(private resourceFacotry: ResourceFactory) { }
......
......@@ -7,7 +7,7 @@ import { Command, CommandResource } from './command.model';
import { CommandRepository } from './command.repository';
import { isPending } from './command.util';
@Injectable()
@Injectable({ providedIn: 'root' })
export class CommandService {
intervalTimer: number = 500;
......
......@@ -10,6 +10,6 @@ function getDebugElementFromFixtureByType<T>(fixture: ComponentFixture<any>, com
return fixture.debugElement.query(By.directive(component));
}
export function getElementFromFixtureByCss(fixture: ComponentFixture<any>, query: string) {
export function getElementFromFixtureByCss(fixture: ComponentFixture<any>, query: string): DebugElement {
return fixture.debugElement.query(By.css(query));
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ import { CommandResource } from 'libs/command-shared/src/lib/command.model';
import { Observable, of } from 'rxjs';
@Component({
selector: '[goofy-client-vorgang-detail-page]',
selector: 'goofy-client-vorgang-detail-page',
templateUrl: './vorgang-detail-page.component.html',
styleUrls: ['./vorgang-detail-page.component.scss']
})
......@@ -22,18 +22,23 @@ export class VorgangDetailPageComponent implements OnInit {
ngOnInit(): void {
this.vorgangStateResource$ = this.vorgangService.getVorgangMitEingang();
this.annehmenCommandStateResource$ = this.vorgangService.getAnnehmenCommand();
this.verwerfenCommandStateResource$ = this.vorgangService.getVerwerfenCommand();
this.zurueckholenCommandStateResource$ = this.vorgangService.getZurueckholenCommand();
this.revokeCommandStateResource$ = this.vorgangService.getRevokeCommand();
}
annehmen(vorgang: VorgangResource): void {
this.annehmenCommandStateResource$ = this.vorgangService.vorgangAnnehmen(vorgang);
this.vorgangService.vorgangAnnehmen(vorgang);
}
verwerfen(vorgang: VorgangResource): void {
this.verwerfenCommandStateResource$ = this.vorgangService.vorgangVerwerfen(vorgang);
this.vorgangService.vorgangVerwerfen(vorgang);
}
zurueckholen(vorgang: VorgangResource): void {
this.zurueckholenCommandStateResource$ = this.vorgangService.vorgangZurueckholen(vorgang);
this.vorgangService.vorgangZurueckholen(vorgang);
}
}
......@@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TechSharedModule } from '@goofy-client/tech-shared';
import { UiModule } from '@goofy-client/ui';
import { VorgangSharedModule } from '@goofy-client/vorgang-shared';
import { VorgangDetailActionButtonsComponent } from './vorgang-detail-page/vorgang-detail-container/vorgang-detail-action-buttons/vorgang-detail-action-buttons.component';
import { AntragstellerComponent } from './vorgang-detail-page/vorgang-detail-container/vorgang-detail-body/antragsteller/antragsteller.component';
import { EingangHeaderComponent } from './vorgang-detail-page/vorgang-detail-container/vorgang-detail-body/eingang-header/eingang-header.component';
......@@ -12,7 +13,6 @@ import { VorgangDetailContainerComponent } from './vorgang-detail-page/vorgang-d
import { VorgangDetailFormularButtonsComponent } from './vorgang-detail-page/vorgang-detail-container/vorgang-detail-formular-buttons/vorgang-detail-formular-buttons.component';
import { VorgangDetailHeaderComponent } from './vorgang-detail-page/vorgang-detail-container/vorgang-detail-header/vorgang-detail-header.component';
import { VorgangDetailPageComponent } from './vorgang-detail-page/vorgang-detail-page.component';
import { VorgangSharedModule } from '@goofy-client/vorgang-shared';
const routes: Routes = [
{
......
export * from './lib/aktenzeichen/aktenzeichen.component';
export * from './lib/status-dot/status-dot.component';
export * from './lib/vorgang-shared.module';
export * from './lib/vorgang.linkrels';
export * from './lib/vorgang.messages';
......
{{ aktenzeichen }}
<span data-test-id="aktenzeichen">{{ getAktenzeichen() }}</span>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AktenzeichenComponent } from './aktenzeichen.component';
import { createVorgangResource } from '../../../test/vorgang';
import { VorgangResource } from '../vorgang.model';
import { AktenzeichenComponent } from './aktenzeichen.component';
describe('AktenzeichenComponent', () => {
let component: AktenzeichenComponent;
let fixture: ComponentFixture<AktenzeichenComponent>;
const vorgang: VorgangResource = createVorgangResource();
const aktenzeichen: string = '[data-test-id="aktenzeichen"]';
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AktenzeichenComponent]
})
.compileComponents();
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AktenzeichenComponent);
component = fixture.componentInstance;
component.vorgang = createVorgangResource();
component.vorgang = vorgang;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
describe('aktenzeichen', () => {
it('should show default message', () => {
component.vorgang = { ...createVorgangResource(), aktenzeichen: null };
fixture.detectChanges();
const aktenzeichenMessage: HTMLElement = fixture.nativeElement.querySelector(aktenzeichen);
expect(aktenzeichenMessage.innerHTML).toBe(component.noAktenzeichenMessage);
})
it('should show aktenzeichen', () => {
component.vorgang = vorgang;
fixture.detectChanges();
const aktenzeichenMessage: HTMLElement = fixture.nativeElement.querySelector(aktenzeichen);
expect(aktenzeichenMessage.textContent).toBe(vorgang.aktenzeichen);
})
})
});
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input } from '@angular/core';
import { Vorgang } from '@goofy-client/vorgang-shared';
@Component({
......@@ -6,15 +6,13 @@ import { Vorgang } from '@goofy-client/vorgang-shared';
templateUrl: './aktenzeichen.component.html',
styleUrls: ['./aktenzeichen.component.scss']
})
export class AktenzeichenComponent implements OnInit {
export class AktenzeichenComponent {
@Input() vorgang: Vorgang;
@Input() noAktenzeichenMessage: string = 'kein Aktenzeichen zugewiesen';
aktenzeichen: string;
readonly noAktenzeichenMessage: string = 'kein Aktenzeichen zugewiesen';
ngOnInit(): void {
this.vorgang.aktenzeichen ? this.aktenzeichen = this.vorgang.aktenzeichen : this.aktenzeichen = 'kein Aktenzeichen zugewiesen';
getAktenzeichen(): string {
return this.vorgang.aktenzeichen ? this.vorgang.aktenzeichen : this.noAktenzeichenMessage;
}
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StatusDotComponent } from './status-dot.component';
import { EnumToLabelPipe } from 'libs/tech-shared/src/lib/pipes/enum-to-label';
import { VorgangStatus } from '@goofy-client/vorgang-shared';
import { EnumToLabelPipe } from 'libs/tech-shared/src/lib/pipes/enum-to-label';
import { StatusDotComponent } from './status-dot.component';
describe('StatusDotComponent', () => {
let component: StatusDotComponent;
......@@ -14,8 +13,7 @@ describe('StatusDotComponent', () => {
StatusDotComponent,
EnumToLabelPipe
]
})
.compileComponents();
}).compileComponents();
});
beforeEach(() => {
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RestModule } from '@ngxp/rest';
import { VorgangRepository } from './vorgang.repository';
import { StatusDotComponent } from './status-dot/status-dot.component';
import { NgModule } from '@angular/core';
import { CommandSharedModule } from '@goofy-client/command-shared';
import { TechSharedModule } from '@goofy-client/tech-shared';
import { RestModule } from '@ngxp/rest';
import { AktenzeichenComponent } from './aktenzeichen/aktenzeichen.component';
import { StatusDotComponent } from './status-dot/status-dot.component';
@NgModule({
imports: [
CommonModule,
RestModule,
TechSharedModule
],
providers: [
VorgangRepository
TechSharedModule,
CommandSharedModule
],
declarations: [
StatusDotComponent,
......
......@@ -302,13 +302,6 @@ describe('VorgangService', () => {
expect(commandService.createCommand).toHaveBeenCalledWith(vorgangMitEingangResource, VorgangMitEingangLinkRel.ANNEHMEN, { order: VorgangOrder.ANNEHMEN });
})
it('should return value', () => {
const result = service.vorgangAnnehmen(vorgangMitEingangResource);
expect(result).toBeObservable(hot('b', { b: commandStateResource }));
})
})
describe('vorgang verwerfen', () => {
......@@ -325,13 +318,22 @@ describe('VorgangService', () => {
expect(commandService.createCommand).toHaveBeenCalledWith(vorgangMitEingangResource, VorgangMitEingangLinkRel.VERWERFEN, { order: VorgangOrder.VERWERFEN });
})
})
it('should return value', () => {
const result = service.vorgangVerwerfen(vorgangMitEingangResource);
describe('vorgang zurueckholen', () => {
expect(result).toBeObservable(hot('b', { b: commandStateResource }));
const vorgangMitEingangResource: VorgangMitEingangResource = createVorgangMitEingangResource();
const commandStateResource: StateResource<CommandResource> = createStateResource(createCommandResource(), true);
beforeEach(() => {
commandService.createCommand.mockReturnValue(cold('a', { a: commandStateResource }));
})
it('should call commandService', () => {
service.vorgangZurueckholen(vorgangMitEingangResource);
expect(commandService.createCommand).toHaveBeenCalledWith(vorgangMitEingangResource, VorgangMitEingangLinkRel.ZURUECKHOLEN, { order: VorgangOrder.ZURUECKHOLEN });
})
})
describe('reload vorgang', () => {
......@@ -360,7 +362,7 @@ describe('VorgangService', () => {
it('should call snackBarService when command is done', () => {
const commandResource: CommandResource = createCommandResource();
service.proceedWithCommand(commandResource, snackBarMessage);
service.proceedWithCommand(commandResource, snackBarMessage, () => null);
expect(snackBarService.showSnackbar).not.toHaveBeenCalled();
expect(service.reloadVorgang).not.toHaveBeenCalled();
......@@ -369,7 +371,7 @@ describe('VorgangService', () => {
it('should not snackBarService when command is pending', () => {
const commandResource: CommandResource = createCommandResource([CommandLinkRel.EFFECTED_RESOURCE]);
service.proceedWithCommand(commandResource, snackBarMessage);
service.proceedWithCommand(commandResource, snackBarMessage, () => null);
expect(snackBarService.showSnackbar).toHaveBeenCalled();
expect(service.reloadVorgang).toHaveBeenCalled();
......
......@@ -10,7 +10,7 @@ import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel';
import { Command, CommandResource } from 'libs/command-shared/src/lib/command.model';
import { isNil } from 'lodash-es';
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
import { filter, first, flatMap, tap } from 'rxjs/operators';
import { filter, first, flatMap } from 'rxjs/operators';
import { VorgangListLinkRel, VorgangMitEingangLinkRel } from './vorgang.linkrels';
import { VorgangMessages } from './vorgang.messages';
import { VorgangListResource, VorgangMitEingangResource, VorgangOrder, VorgangResource } from './vorgang.model';
......@@ -23,6 +23,11 @@ export class VorgangService {
private readonly vorgaenge$: BehaviorSubject<VorgangResource[]> = new BehaviorSubject([]);
private readonly vorgangMitEingang$: BehaviorSubject<StateResource<VorgangMitEingangResource>> = new BehaviorSubject(createEmptyStateResource());
private readonly hasNextPage$: BehaviorSubject<boolean> = new BehaviorSubject(false);
annehmenCommand$: BehaviorSubject<StateResource<CommandResource>> = new BehaviorSubject(createEmptyStateResource());
verwerfenCommand$: BehaviorSubject<StateResource<CommandResource>> = new BehaviorSubject(createEmptyStateResource());
zurueckholenCommand$: BehaviorSubject<StateResource<CommandResource>> = new BehaviorSubject(createEmptyStateResource());
private readonly revokeCommand$: BehaviorSubject<StateResource<CommandResource>> = new BehaviorSubject(createEmptyStateResource());
private subscription: Subscription;
......@@ -62,13 +67,6 @@ export class VorgangService {
this.subscription = this.navigationService.getUrl().subscribe(urlSegements => this.clearStateOnNavigation(urlSegements));
}
private isNotVorgangDetailPage(urlSegements: UrlSegment[]) {
return (urlSegements.length < 2) || (urlSegements[0].path !== 'vorgang')
}
private isNotVorgangListPage(urlSegements: UrlSegment[]) {
return urlSegements.length !== 0;
}
clearStateOnNavigation(urlSegements: UrlSegment[]): void {
if (this.isNotVorgangDetailPage(urlSegements)) {
......@@ -79,6 +77,14 @@ export class VorgangService {
}
}
private isNotVorgangDetailPage(urlSegements: UrlSegment[]): boolean {
return (urlSegements.length < 2) || (urlSegements[0].path !== 'vorgang')
}
private isNotVorgangListPage(urlSegements: UrlSegment[]): boolean {
return urlSegements.length !== 0;
}
private clearVorgangList() {
this.currentList$.next({ ...this.currentList$.value, reload: true });
}
......@@ -159,49 +165,72 @@ export class VorgangService {
this.vorgaenge$.next(vorgaenge);
}
public vorgangAnnehmen(vorgang: VorgangResource): Observable<StateResource<CommandResource>> {
return this.commandService.createCommand(vorgang, VorgangMitEingangLinkRel.ANNEHMEN, this.createAnnehmenCommand()).pipe(
tap(commandStateResource => this.proceedWithCommand(commandStateResource.resource, VorgangMessages.VORGANG_ANGENOMMEN))
)
public getAnnehmenCommand(): Observable<StateResource<CommandResource>> {
return this.annehmenCommand$;
}
public vorgangAnnehmen(vorgang: VorgangResource): void {
this.annehmenCommand$.next({ ...this.annehmenCommand$.value, loading: true });
this.commandService.createCommand(vorgang, VorgangMitEingangLinkRel.ANNEHMEN, this.createAnnehmenCommand()).pipe(first()).subscribe(commandStateResource => {
this.proceedWithCommand(commandStateResource.resource, VorgangMessages.VORGANG_ANGENOMMEN, () => this.annehmenCommand$.next(commandStateResource));
})
}
private createAnnehmenCommand(): Command {
return <any>{ order: VorgangOrder.ANNEHMEN };
}
public vorgangVerwerfen(vorgang: VorgangResource): Observable<StateResource<CommandResource>> {
return this.commandService.createCommand(vorgang, VorgangMitEingangLinkRel.VERWERFEN, this.createVerwerfenCommand()).pipe(
tap(commandStateResource => this.proceedWithCommand(commandStateResource.resource, VorgangMessages.VORGANG_VERWORFEN))
)
public getVerwerfenCommand(): Observable<StateResource<CommandResource>> {
return this.verwerfenCommand$;
}
public vorgangVerwerfen(vorgang: VorgangResource): void {
this.verwerfenCommand$.next({ ...this.verwerfenCommand$.value, loading: true });
this.commandService.createCommand(vorgang, VorgangMitEingangLinkRel.VERWERFEN, this.createVerwerfenCommand()).pipe(first()).subscribe(commandStateResource => {
this.proceedWithCommand(commandStateResource.resource, VorgangMessages.VORGANG_VERWORFEN, () => this.verwerfenCommand$.next(commandStateResource))
})
}
private createVerwerfenCommand(): Command {
return <any>{ order: VorgangOrder.VERWERFEN };
}
public vorgangZurueckholen(vorgang: VorgangResource) {
return this.commandService.createCommand(vorgang, VorgangMitEingangLinkRel.ZURUECKHOLEN, this.createZurueckholenCommand()).pipe(
tap(commandStateResource => this.proceedWithCommand(commandStateResource.resource, VorgangMessages.VORGANG_ZURUECKGEHOLT))
)
public getZurueckholenCommand(): Observable<StateResource<CommandResource>> {
return this.zurueckholenCommand$;
}
public vorgangZurueckholen(vorgang: VorgangResource): void {
this.zurueckholenCommand$.next({ ...this.zurueckholenCommand$.value, loading: true });
this.commandService.createCommand(vorgang, VorgangMitEingangLinkRel.ZURUECKHOLEN, this.createZurueckholenCommand()).pipe(first()).subscribe(commandStateResource => {
this.proceedWithCommand(commandStateResource.resource, VorgangMessages.VORGANG_ZURUECKGEHOLT, () => this.zurueckholenCommand$.next(commandStateResource))
})
}
private createZurueckholenCommand(): Command {
return <any>{ order: VorgangOrder.ZURUECKHOLEN };
}
proceedWithCommand(commandResource: CommandResource, snackBarMessage: string): void {
proceedWithCommand(commandResource: CommandResource, snackBarMessage: string, afterCommandIsDone: () => void): void {
if (isDone(commandResource)) {
this.reloadVorgang(commandResource)
this.snackBarService.showSnackbar(commandResource, snackBarMessage, () => this.handleRevokeCommand(commandResource));
afterCommandIsDone();
}
}
public getRevokeCommand(): Observable<StateResource<CommandResource>> {
return this.revokeCommand$;
}
private handleRevokeCommand(commandResource: CommandResource): void {
this.revokeCommand$.next(createEmptyStateResource(true));
const subscr: Subscription = this.commandService.revokeCommand(commandResource).subscribe(commandResource => {
const subscription: Subscription = this.commandService.revokeCommand(commandResource).subscribe(commandResource => {
this.proceedWithRevokeCommand(commandResource);
subscr.unsubscribe();
subscription.unsubscribe();
});
}
......@@ -217,10 +246,6 @@ export class VorgangService {
this.loadVorgangMitEingang(getUrl(commandResource, CommandLinkRel.EFFECTED_RESOURCE));
}
public getRevokeCommand(): Observable<StateResource<CommandResource>> {
return this.revokeCommand$;
}
ngOnDestroy(): void {
this.unsubscribe();
}
......
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
@Component({
selector: 'goofy-client-vorgang-list-page',
templateUrl: './vorgang-list-page.component.html',
styleUrls: ['./vorgang-list-page.component.css']
styleUrls: ['./vorgang-list-page.component.scss']
})
export class VorgangListPageComponent { }
import { NgModule } from '@angular/core';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { CommonModule } from '@angular/common';
import { VorgangSharedModule } from '@goofy-client/vorgang-shared';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TechSharedModule } from '@goofy-client/tech-shared';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { UiModule } from '@goofy-client/ui';
import { VorgangSharedModule } from '@goofy-client/vorgang-shared';
import { VorgangListContainerComponent } from './vorgang-list-container/vorgang-list-container.component';
import { RouterModule } from '@angular/router';
import { VorgangListComponent } from './vorgang-list-container/vorgang-list/vorgang-list.component';
import { VorgangListItemComponent } from './vorgang-list-container/vorgang-list/vorgang-list-item/vorgang-list-item.component';
import { Routes } from '@angular/router';
import { VorgangListComponent } from './vorgang-list-container/vorgang-list/vorgang-list.component';
import { VorgangListPageComponent } from './vorgang-list-page/vorgang-list-page.component';
const routes: Routes = [
......@@ -25,11 +24,11 @@ const routes: Routes = [
@NgModule({
imports: [
CommonModule,
VorgangSharedModule,
TechSharedModule,
ScrollingModule,
UiModule,
RouterModule.forChild(routes)
RouterModule.forChild(routes),
VorgangSharedModule
],
declarations: [
VorgangListComponent,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment