TSK-454 Domain switching bug
This commit is contained in:
parent
fdfb9b65d0
commit
cb20dd1ccb
|
@ -26,9 +26,9 @@
|
|||
<div class="col-md-6">
|
||||
<div class="form-group required">
|
||||
<label for="classification-key" class="control-label">Key</label>
|
||||
<input type="text" required #key="ngModel" class="form-control" id="classification-key" placeholder="Key" [(ngModel)]="classification.key"
|
||||
name="classification.key">
|
||||
<div *ngIf="!key.valid" class="required-text">
|
||||
<input type="text" required #key="ngModel" [disabled]="action!== 'CREATE'? true : false" class="form-control" id="classification-key"
|
||||
placeholder="Key" [(ngModel)]="classification.key" name="classification.key">
|
||||
<div *ngIf="!key.valid && action === 'CREATE'" class="required-text">
|
||||
* Key is required
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -45,6 +45,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
private classificationRemoveSubscription: Subscription;
|
||||
private selectedClassificationSubscription: Subscription;
|
||||
private categoriesSubscription: Subscription;
|
||||
private domainSubscription: Subscription;
|
||||
|
||||
constructor(private classificationsService: ClassificationsService,
|
||||
private route: ActivatedRoute,
|
||||
|
@ -66,7 +67,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
.subscribe(classificationIdSelected => {
|
||||
this.classification = undefined;
|
||||
if (classificationIdSelected) {
|
||||
this.getClassificationInformation(classificationIdSelected);
|
||||
this.fillClassificationInformation(classificationIdSelected);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -80,7 +81,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
if (id === 'undefined') {
|
||||
id = undefined;
|
||||
}
|
||||
this.getClassificationInformation(id);
|
||||
this.fillClassificationInformation(id);
|
||||
}
|
||||
|
||||
if (id && id !== '') {
|
||||
|
@ -111,6 +112,11 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
removeClassification() {
|
||||
if (!this.classification || !this.classification.classificationId) {
|
||||
this.errorModalService.triggerError(
|
||||
new ErrorModel('There is no classification selected', 'Please check if you are creating a classification'));
|
||||
return false;
|
||||
}
|
||||
this.requestInProgressService.setRequestInProgress(true);
|
||||
this.treeService.setRemovedNodeId(this.classification.classificationId);
|
||||
|
||||
|
@ -147,6 +153,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
.putClassification(this.classification._links.self.href, this.classification)
|
||||
.subscribe((classification: ClassificationDefinition) => {
|
||||
this.classification = classification;
|
||||
this.classificationsService.selectClassification(classification.classificationId);
|
||||
this.afterRequest();
|
||||
this.alertService.triggerAlert(new AlertModel(AlertType.SUCCESS, `Classification ${classification.key} was saved successfully`));
|
||||
}, error => {
|
||||
|
@ -176,7 +183,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
this.classificationsService.selectClassification(id);
|
||||
}
|
||||
|
||||
private getClassificationInformation(classificationIdSelected: string) {
|
||||
private fillClassificationInformation(classificationIdSelected: string) {
|
||||
if (this.action === ACTION.CREATE) { // CREATE
|
||||
this.initClassificationCreation(classificationIdSelected);
|
||||
} else {
|
||||
|
@ -186,6 +193,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
this.classification = classification;
|
||||
this.classificationClone = { ...this.classification };
|
||||
this.requestInProgress = false;
|
||||
this.checkDomainAndRedirect();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -208,6 +216,14 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
this.classificationClone = { ...this.classification };
|
||||
}
|
||||
|
||||
private checkDomainAndRedirect() {
|
||||
this.domainSubscription = this.domainService.getSelectedDomain().subscribe(domain => {
|
||||
if (this.classification && this.classification.domain !== domain) {
|
||||
this.backClicked();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
||||
if (this.masterAndDetailSubscription) { this.masterAndDetailSubscription.unsubscribe(); }
|
||||
|
@ -218,6 +234,6 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
|
|||
if (this.classificationRemoveSubscription) { this.classificationRemoveSubscription.unsubscribe(); }
|
||||
if (this.selectedClassificationSubscription) { this.selectedClassificationSubscription.unsubscribe(); }
|
||||
if (this.categoriesSubscription) { this.categoriesSubscription.unsubscribe(); }
|
||||
|
||||
if (this.domainSubscription) { this.domainSubscription.unsubscribe(); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,9 +84,6 @@ export class ClassificationListComponent implements OnInit, OnDestroy {
|
|||
this.classificationServiceSubscription = this.classificationService.getClassifications(true)
|
||||
.subscribe((classifications: Array<TreeNodeModel>) => {
|
||||
this.requestInProgress = false;
|
||||
if (!classifications.length) {
|
||||
return null;
|
||||
}
|
||||
this.classifications = classifications;
|
||||
this.classificationTypeServiceSubscription = this.classificationTypeService.getClassificationTypes()
|
||||
.subscribe((classificationsTypes: Array<string>) => {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<taskana-spinner [isRunning]="requestInProgress" isModal="true"
|
||||
class="floating"></taskana-spinner>
|
||||
<div *ngIf="workbasket" id="wb-information" class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<div class="pull-right">
|
||||
|
|
|
@ -47,7 +47,6 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
|||
distributionTargetsClone: Array<WorkbasketSummary>;
|
||||
distributionTargetsSelectedClone: Array<WorkbasketSummary>;
|
||||
|
||||
requestInProgress = false;
|
||||
requestInProgressLeft = false;
|
||||
requestInProgressRight = false;
|
||||
modalErrorMessage: string;
|
||||
|
@ -119,10 +118,9 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
|||
|
||||
onSave() {
|
||||
this.requestInProgressService.setRequestInProgress(true);
|
||||
this.requestInProgress = true;
|
||||
this.workbasketService.updateWorkBasketsDistributionTargets(
|
||||
this.distributionTargetsSelectedResource._links.self.href, this.getSeletedIds()).subscribe(response => {
|
||||
this.requestInProgress = false;
|
||||
this.requestInProgressService.setRequestInProgress(false);
|
||||
this.distributionTargetsSelected = response._embedded ? response._embedded.distributionTargets : [];
|
||||
this.distributionTargetsSelectedClone = Object.assign([], this.distributionTargetsSelected);
|
||||
this.distributionTargetsClone = Object.assign([], this.distributionTargetsLeft);
|
||||
|
@ -132,7 +130,7 @@ export class DistributionTargetsComponent implements OnChanges, OnDestroy {
|
|||
},
|
||||
error => {
|
||||
this.errorModalService.triggerError(new ErrorModel(`There was error while saving your workbasket's distribution targets`, error))
|
||||
this.requestInProgress = false;
|
||||
this.requestInProgressService.setRequestInProgress(false);
|
||||
return false;
|
||||
}
|
||||
)
|
||||
|
|
|
@ -37,6 +37,7 @@ export class WorkbasketDetailsComponent implements OnInit, OnDestroy {
|
|||
private routeSubscription: Subscription;
|
||||
private masterAndDetailSubscription: Subscription;
|
||||
private permissionSubscription: Subscription;
|
||||
private domainSubscription: Subscription;
|
||||
|
||||
constructor(private service: WorkbasketService,
|
||||
private route: ActivatedRoute,
|
||||
|
@ -104,7 +105,9 @@ export class WorkbasketDetailsComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (!workbasketIdSelected && this.action === ACTION.CREATE) { // CREATE
|
||||
this.workbasket = new Workbasket(undefined);
|
||||
this.workbasket.domain = this.domainService.getSelectedDomainValue();
|
||||
this.domainSubscription = this.domainService.getSelectedDomain().subscribe(domain => {
|
||||
this.workbasket.domain = domain;
|
||||
});
|
||||
this.requestInProgress = false;
|
||||
} else if (!workbasketIdSelected && this.action === ACTION.COPY) { // COPY
|
||||
this.workbasket = { ...this.workbasketCopy };
|
||||
|
@ -115,15 +118,25 @@ export class WorkbasketDetailsComponent implements OnInit, OnDestroy {
|
|||
this.workbasketSubscription = this.service.getWorkBasket(workbasketIdSelected).subscribe(workbasket => {
|
||||
this.workbasket = workbasket;
|
||||
this.requestInProgress = false;
|
||||
this.checkDomainAndRedirect();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private checkDomainAndRedirect() {
|
||||
this.domainSubscription = this.domainService.getSelectedDomain().subscribe(domain => {
|
||||
if (this.workbasket && this.workbasket.domain !== domain) {
|
||||
this.backClicked();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.workbasketSelectedSubscription) { this.workbasketSelectedSubscription.unsubscribe(); }
|
||||
if (this.workbasketSubscription) { this.workbasketSubscription.unsubscribe(); }
|
||||
if (this.routeSubscription) { this.routeSubscription.unsubscribe(); }
|
||||
if (this.masterAndDetailSubscription) { this.masterAndDetailSubscription.unsubscribe(); }
|
||||
if (this.permissionSubscription) { this.permissionSubscription.unsubscribe(); }
|
||||
if (this.domainSubscription) { this.domainSubscription.unsubscribe(); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
<taskana-icon-type class="vertical-align" [type]="workbasket.type" [selected]="workbasket.workbasketId === selectedId"></taskana-icon-type>
|
||||
</dl>
|
||||
<dl class="col-xs-10">
|
||||
<dt>{{workbasket.name}},
|
||||
<i>{{workbasket.key}} </i>
|
||||
<dt data-toggle="tooltip" title="{{workbasket.name}}">{{workbasket.name}},
|
||||
<i data-toggle="tooltip" title="{{workbasket.key}}">{{workbasket.key}} </i>
|
||||
</dt>
|
||||
<dd>{{workbasket.description}} </dd>
|
||||
<dd>{{workbasket.owner}} </dd>
|
||||
<dd data-toggle="tooltip" title="{{workbasket.description}}">{{workbasket.description}} </dd>
|
||||
<dd data-toggle="tooltip" title="{{workbasket.owner}}">{{workbasket.owner}} </dd>
|
||||
</dl>
|
||||
</div>
|
||||
</li>
|
||||
|
|
|
@ -9,12 +9,13 @@ import { NoAccessComponent } from './administration/workbasket/details/noAccess/
|
|||
import { ClassificationListComponent } from './administration/classification/master/list/classification-list.component';
|
||||
import { ClassificationDetailsComponent } from 'app/administration/classification/details/classification-details.component';
|
||||
import { EnvironmentUrlGuard } from 'app/guards/environment-url-guard';
|
||||
import { DomainGuard } from 'app/guards/domain-guard';
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
path: 'administration/workbaskets',
|
||||
component: MasterAndDetailComponent,
|
||||
canActivate: [EnvironmentUrlGuard],
|
||||
canActivate: [EnvironmentUrlGuard, DomainGuard],
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
|
@ -41,7 +42,7 @@ const appRoutes: Routes = [
|
|||
{
|
||||
path: 'administration/classifications',
|
||||
component: MasterAndDetailComponent,
|
||||
canActivate: [EnvironmentUrlGuard],
|
||||
canActivate: [EnvironmentUrlGuard, DomainGuard],
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
|
|
|
@ -73,6 +73,7 @@ import { DomainService } from './services/domain/domain.service';
|
|||
* Guards
|
||||
*/
|
||||
import { EnvironmentUrlGuard } from './guards/environment-url-guard';
|
||||
import { DomainGuard } from './guards/domain-guard';
|
||||
|
||||
const MODULES = [
|
||||
BrowserModule,
|
||||
|
@ -142,7 +143,8 @@ const DECLARATIONS = [
|
|||
TreeService,
|
||||
ClassificationTypesService,
|
||||
ClassificationCategoriesService,
|
||||
EnvironmentUrlGuard
|
||||
EnvironmentUrlGuard,
|
||||
DomainGuard
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import { Observable } from 'rxjs/Observable';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { CanActivate } from '@angular/router';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { DomainService } from 'app/services/domain/domain.service';
|
||||
import { ErrorModalService } from 'app/services/errorModal/error-modal.service';
|
||||
import { ErrorModel } from 'app/models/modal-error';
|
||||
|
||||
@Injectable()
|
||||
export class DomainGuard implements CanActivate {
|
||||
constructor(private domainService: DomainService, private errorModalService: ErrorModalService) { }
|
||||
|
||||
canActivate() {
|
||||
return this.domainService.getDomains().map(domain => {
|
||||
return true;
|
||||
}).catch(() => {
|
||||
this.errorModalService.triggerError(new ErrorModel(
|
||||
'There was an error, please contact with your administrator', 'There was an error getting Domains'))
|
||||
return Observable.of(false)
|
||||
});
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|||
import { Injectable } from '@angular/core';
|
||||
import { environment } from 'environments/environment';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
||||
@Injectable()
|
||||
export class ClassificationCategoriesService {
|
||||
|
||||
|
@ -14,10 +14,21 @@ export class ClassificationCategoriesService {
|
|||
'Authorization': 'Basic VEVBTUxFQURfMTpURUFNTEVBRF8x'
|
||||
})
|
||||
};
|
||||
private dataObs$ = new ReplaySubject<Array<string>>(1);
|
||||
|
||||
constructor(private httpClient: HttpClient) { }
|
||||
|
||||
getCategories(): Observable<Array<string>> {
|
||||
return this.httpClient.get<Array<string>>(this.url, this.httpOptions);
|
||||
getCategories(forceRefresh = false): Observable<Array<string>> {
|
||||
if (!this.dataObs$.observers.length || forceRefresh) {
|
||||
this.httpClient.get<Array<string>>(this.url, this.httpOptions).subscribe(
|
||||
data => this.dataObs$.next(data),
|
||||
error => {
|
||||
this.dataObs$.error(error);
|
||||
this.dataObs$ = new ReplaySubject(1);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return this.dataObs$;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import { Observable } from 'rxjs/Observable';
|
|||
import { Subject } from 'rxjs/Subject';
|
||||
import { environment } from 'environments/environment';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
||||
|
||||
@Injectable()
|
||||
export class ClassificationTypesService {
|
||||
|
@ -16,11 +17,23 @@ export class ClassificationTypesService {
|
|||
};
|
||||
private classificationTypeSelectedValue = 'TASK';
|
||||
private classificationTypeSelected = new BehaviorSubject<string>(this.classificationTypeSelectedValue);
|
||||
private dataObs$ = new ReplaySubject<Array<string>>(1);
|
||||
|
||||
constructor(private httpClient: HttpClient) { }
|
||||
|
||||
getClassificationTypes(): Observable<Array<string>> {
|
||||
return this.httpClient.get<Array<string>>(this.url, this.httpOptions);
|
||||
getClassificationTypes(forceRefresh = false): Observable<Array<string>> {
|
||||
|
||||
if (!this.dataObs$.observers.length || forceRefresh) {
|
||||
this.httpClient.get<Array<string>>(this.url, this.httpOptions).subscribe(
|
||||
data => this.dataObs$.next(data),
|
||||
error => {
|
||||
this.dataObs$.error(error);
|
||||
this.dataObs$ = new ReplaySubject(1);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return this.dataObs$;
|
||||
};
|
||||
|
||||
selectClassificationType(id: string) {
|
||||
|
|
|
@ -29,7 +29,6 @@ export class ClassificationsService {
|
|||
})
|
||||
};
|
||||
|
||||
private classificationRef: Observable<ClassificationResource>;
|
||||
private classificationTypes: Array<string>;
|
||||
|
||||
constructor(
|
||||
|
@ -42,14 +41,9 @@ export class ClassificationsService {
|
|||
getClassifications(forceRequest = false): Observable<any> {
|
||||
return this.domainService.getSelectedDomain().mergeMap(domain => {
|
||||
const classificationTypes = this.classificationTypeService.getSelectedClassificationType();
|
||||
if (!forceRequest && this.classificationRef) {
|
||||
return this.getClassificationObservable(this.classificationRef)
|
||||
}
|
||||
this.classificationRef = this.httpClient.get<ClassificationResource>(
|
||||
return this.getClassificationObservable(this.httpClient.get<ClassificationResource>(
|
||||
`${environment.taskanaRestUrl}/v1/classifications/?domain=${domain}`,
|
||||
this.httpOptions)
|
||||
|
||||
return this.getClassificationObservable(this.classificationRef);
|
||||
this.httpOptions));
|
||||
|
||||
}).do(() => {
|
||||
this.domainService.domainChangedComplete();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
|
||||
@Injectable()
|
||||
export class DomainServiceMock {
|
||||
|
@ -8,6 +9,7 @@ export class DomainServiceMock {
|
|||
|
||||
private domainSelectedValue;
|
||||
private domainSelected = new BehaviorSubject<string>('DOMAIN_A');
|
||||
private domainSwitched = new Subject<string>();
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
@ -32,6 +34,12 @@ export class DomainServiceMock {
|
|||
getSelectedDomainValue() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
getSwitchedDomain(): Observable<string> {
|
||||
return this.domainSwitched.asObservable();
|
||||
}
|
||||
|
||||
switchDomain(value: string) {
|
||||
this.selectDomain(value)
|
||||
this.domainSwitched.next(value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import { environment } from '../../../environments/environment';
|
|||
import { Router } from '@angular/router';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { RequestInProgressService } from '../requestInProgress/request-in-progress.service';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
|
||||
@Injectable()
|
||||
export class DomainService {
|
||||
|
@ -19,6 +20,7 @@ export class DomainService {
|
|||
};
|
||||
private domainSelectedValue;
|
||||
private domainSelected = new BehaviorSubject<string>('');
|
||||
private domainSwitched = new Subject<string>();
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
|
@ -40,13 +42,22 @@ export class DomainService {
|
|||
return this.domainSelected.asObservable();
|
||||
}
|
||||
|
||||
getSwitchedDomain(): Observable<string> {
|
||||
return this.domainSwitched.asObservable();
|
||||
}
|
||||
|
||||
selectDomain(value: string) {
|
||||
this.requestInProgressService.setRequestInProgress(true);
|
||||
// this.router.navigate(['']);
|
||||
this.domainSelectedValue = value;
|
||||
this.domainSelected.next(value);
|
||||
}
|
||||
|
||||
switchDomain(value: string) {
|
||||
this.selectDomain(value);
|
||||
this.domainSwitched.next(value);
|
||||
this.router.navigate([this.getNavigationUrl()]);
|
||||
}
|
||||
|
||||
domainChangedComplete() {
|
||||
this.requestInProgressService.setRequestInProgress(false);
|
||||
}
|
||||
|
@ -54,4 +65,12 @@ export class DomainService {
|
|||
getSelectedDomainValue() {
|
||||
return this.domainSelectedValue;
|
||||
}
|
||||
|
||||
private getNavigationUrl(): string {
|
||||
if (this.router.url.indexOf('workbaskets') !== -1) {
|
||||
return 'administration/workbaskets';
|
||||
} else if (this.router.url.indexOf('classifications') !== -1) {
|
||||
return 'administration/classifications';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { ErrorModel } from 'app/models/modal-error';
|
|||
@Injectable()
|
||||
export class ErrorModalService {
|
||||
|
||||
public errorTriggered = new Subject<ErrorModel>();
|
||||
private errorTriggered = new Subject<ErrorModel>();
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu" aria-labelledby="dropdownMenu">
|
||||
<li>
|
||||
<a *ngFor="let domain of domains" (click)="selectDomain(domain)">
|
||||
<a *ngFor="let domain of domains" (click)="switchDomain(domain)">
|
||||
{{domain}}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -54,8 +54,8 @@ export class NavBarComponent implements OnInit, OnDestroy {
|
|||
});
|
||||
}
|
||||
|
||||
selectDomain(domain) {
|
||||
this.domainService.selectDomain(domain);
|
||||
switchDomain(domain) {
|
||||
this.domainService.switchDomain(domain);
|
||||
}
|
||||
|
||||
toogleNavBar() {
|
||||
|
|
Loading…
Reference in New Issue