mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
DURACOM-235 Lint fix
This commit is contained in:
@@ -1,33 +1,54 @@
|
|||||||
import { AsyncPipe, NgClass, NgIf, } from '@angular/common';
|
import {
|
||||||
import { ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChange, SimpleChanges, } from '@angular/core';
|
AsyncPipe,
|
||||||
|
NgClass,
|
||||||
|
NgIf,
|
||||||
|
} from '@angular/common';
|
||||||
|
import {
|
||||||
|
ChangeDetectorRef,
|
||||||
|
Component,
|
||||||
|
Input,
|
||||||
|
OnChanges,
|
||||||
|
OnInit,
|
||||||
|
SimpleChange,
|
||||||
|
SimpleChanges,
|
||||||
|
} from '@angular/core';
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {
|
import {
|
||||||
DynamicFormControlModel,
|
DynamicFormControlModel,
|
||||||
DynamicFormOptionConfig,
|
DynamicFormOptionConfig,
|
||||||
DynamicFormService,
|
DynamicFormService,
|
||||||
DynamicSelectModel,
|
DynamicSelectModel,
|
||||||
} from '@ng-dynamic-forms/core';
|
} from '@ng-dynamic-forms/core';
|
||||||
import { TranslateModule, TranslateService, } from '@ngx-translate/core';
|
import {
|
||||||
|
TranslateModule,
|
||||||
|
TranslateService,
|
||||||
|
} from '@ngx-translate/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { hasNoValue, isNotNull, } from 'src/app/shared/empty.util';
|
import {
|
||||||
|
hasNoValue,
|
||||||
|
isNotNull,
|
||||||
|
} from 'src/app/shared/empty.util';
|
||||||
|
|
||||||
import { Collection } from '../../core/shared/collection.model';
|
|
||||||
import { ComColFormComponent } from '../../shared/comcol/comcol-forms/comcol-form/comcol-form.component';
|
|
||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
|
||||||
import { CollectionDataService } from '../../core/data/collection-data.service';
|
|
||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
import { ObjectCacheService } from '../../core/cache/object-cache.service';
|
import { ObjectCacheService } from '../../core/cache/object-cache.service';
|
||||||
|
import { CollectionDataService } from '../../core/data/collection-data.service';
|
||||||
import { EntityTypeDataService } from '../../core/data/entity-type-data.service';
|
import { EntityTypeDataService } from '../../core/data/entity-type-data.service';
|
||||||
import { RequestService } from '../../core/data/request.service';
|
import { RequestService } from '../../core/data/request.service';
|
||||||
|
import { Collection } from '../../core/shared/collection.model';
|
||||||
import { ItemType } from '../../core/shared/item-relationships/item-type.model';
|
import { ItemType } from '../../core/shared/item-relationships/item-type.model';
|
||||||
import { NONE_ENTITY_TYPE } from '../../core/shared/item-relationships/item-type.resource-type';
|
import { NONE_ENTITY_TYPE } from '../../core/shared/item-relationships/item-type.resource-type';
|
||||||
import { MetadataValue } from '../../core/shared/metadata.models';
|
import { MetadataValue } from '../../core/shared/metadata.models';
|
||||||
import { getFirstSucceededRemoteListPayload } from '../../core/shared/operators';
|
import { getFirstSucceededRemoteListPayload } from '../../core/shared/operators';
|
||||||
import { collectionFormEntityTypeSelectionConfig, collectionFormModels, } from './collection-form.models';
|
import { ComColFormComponent } from '../../shared/comcol/comcol-forms/comcol-form/comcol-form.component';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
|
import { ComcolPageLogoComponent } from '../../shared/comcol/comcol-page-logo/comcol-page-logo.component';
|
||||||
import { FormComponent } from '../../shared/form/form.component';
|
import { FormComponent } from '../../shared/form/form.component';
|
||||||
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { UploaderComponent } from '../../shared/upload/uploader/uploader.component';
|
import { UploaderComponent } from '../../shared/upload/uploader/uploader.component';
|
||||||
import { VarDirective } from '../../shared/utils/var.directive';
|
import { VarDirective } from '../../shared/utils/var.directive';
|
||||||
|
import {
|
||||||
|
collectionFormEntityTypeSelectionConfig,
|
||||||
|
collectionFormModels,
|
||||||
|
} from './collection-form.models';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form used for creating and editing collections
|
* Form used for creating and editing collections
|
||||||
|
@@ -10,6 +10,7 @@ import {
|
|||||||
SimpleChange,
|
SimpleChange,
|
||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {
|
import {
|
||||||
DynamicFormControlModel,
|
DynamicFormControlModel,
|
||||||
DynamicFormService,
|
DynamicFormService,
|
||||||
@@ -33,7 +34,6 @@ import { FormComponent } from '../../shared/form/form.component';
|
|||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { UploaderComponent } from '../../shared/upload/uploader/uploader.component';
|
import { UploaderComponent } from '../../shared/upload/uploader/uploader.component';
|
||||||
import { VarDirective } from '../../shared/utils/var.directive';
|
import { VarDirective } from '../../shared/utils/var.directive';
|
||||||
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form used for creating and editing communities
|
* Form used for creating and editing communities
|
||||||
|
@@ -29,17 +29,12 @@ import { hasValue } from '../../../empty.util';
|
|||||||
import { FormComponent } from '../../../form/form.component';
|
import { FormComponent } from '../../../form/form.component';
|
||||||
import { AuthServiceMock } from '../../../mocks/auth.service.mock';
|
import { AuthServiceMock } from '../../../mocks/auth.service.mock';
|
||||||
import { NotificationsService } from '../../../notifications/notifications.service';
|
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||||
import {
|
import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils';
|
||||||
createFailedRemoteDataObject$,
|
|
||||||
createSuccessfulRemoteDataObject$,
|
|
||||||
} from '../../../remote-data.utils';
|
|
||||||
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../testing/notifications-service.stub';
|
||||||
import { UploaderComponent } from '../../../upload/uploader/uploader.component';
|
import { UploaderComponent } from '../../../upload/uploader/uploader.component';
|
||||||
import { VarDirective } from '../../../utils/var.directive';
|
import { VarDirective } from '../../../utils/var.directive';
|
||||||
import { ComcolPageLogoComponent } from '../../comcol-page-logo/comcol-page-logo.component';
|
import { ComcolPageLogoComponent } from '../../comcol-page-logo/comcol-page-logo.component';
|
||||||
import { ComColFormComponent } from './comcol-form.component';
|
import { ComColFormComponent } from './comcol-form.component';
|
||||||
import { Operation } from 'fast-json-patch';
|
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../remote-data.utils';
|
|
||||||
|
|
||||||
describe('ComColFormComponent', () => {
|
describe('ComColFormComponent', () => {
|
||||||
let comp: ComColFormComponent<any>;
|
let comp: ComColFormComponent<any>;
|
||||||
@@ -82,7 +77,7 @@ describe('ComColFormComponent', () => {
|
|||||||
const dsoService = Object.assign({
|
const dsoService = Object.assign({
|
||||||
getLogoEndpoint: () => observableOf(logoEndpoint),
|
getLogoEndpoint: () => observableOf(logoEndpoint),
|
||||||
deleteLogo: () => createSuccessfulRemoteDataObject$({}),
|
deleteLogo: () => createSuccessfulRemoteDataObject$({}),
|
||||||
findById: () => createSuccessfulRemoteDataObject$({})
|
findById: () => createSuccessfulRemoteDataObject$({}),
|
||||||
});
|
});
|
||||||
const notificationsService = new NotificationsServiceStub();
|
const notificationsService = new NotificationsServiceStub();
|
||||||
|
|
||||||
@@ -92,7 +87,7 @@ describe('ComColFormComponent', () => {
|
|||||||
|
|
||||||
const requestServiceStub = jasmine.createSpyObj('requestService', {
|
const requestServiceStub = jasmine.createSpyObj('requestService', {
|
||||||
removeByHrefSubstring: {},
|
removeByHrefSubstring: {},
|
||||||
setStaleByHrefSubstring: {}
|
setStaleByHrefSubstring: {},
|
||||||
});
|
});
|
||||||
const objectCacheStub = jasmine.createSpyObj('objectCache', {
|
const objectCacheStub = jasmine.createSpyObj('objectCache', {
|
||||||
remove: {},
|
remove: {},
|
||||||
|
@@ -13,6 +13,10 @@ import {
|
|||||||
ViewChild,
|
ViewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { UntypedFormGroup } from '@angular/forms';
|
import { UntypedFormGroup } from '@angular/forms';
|
||||||
|
import {
|
||||||
|
NgbModal,
|
||||||
|
NgbModalRef,
|
||||||
|
} from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {
|
import {
|
||||||
DynamicFormControlModel,
|
DynamicFormControlModel,
|
||||||
DynamicFormService,
|
DynamicFormService,
|
||||||
@@ -27,10 +31,15 @@ import { FileUploader } from 'ng2-file-upload';
|
|||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
BehaviorSubject,
|
||||||
combineLatest as observableCombineLatest,
|
combineLatest as observableCombineLatest,
|
||||||
|
Observable,
|
||||||
Subscription,
|
Subscription,
|
||||||
|
switchMap,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
|
import {
|
||||||
|
filter,
|
||||||
|
take,
|
||||||
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable, Subscription, switchMap } from 'rxjs';
|
|
||||||
import { AuthService } from '../../../../core/auth/auth.service';
|
import { AuthService } from '../../../../core/auth/auth.service';
|
||||||
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
|
||||||
import { ComColDataService } from '../../../../core/data/comcol-data.service';
|
import { ComColDataService } from '../../../../core/data/comcol-data.service';
|
||||||
@@ -46,6 +55,7 @@ import {
|
|||||||
import { NoContent } from '../../../../core/shared/NoContent.model';
|
import { NoContent } from '../../../../core/shared/NoContent.model';
|
||||||
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../../core/shared/operators';
|
||||||
import { ResourceType } from '../../../../core/shared/resource-type';
|
import { ResourceType } from '../../../../core/shared/resource-type';
|
||||||
|
import { ConfirmationModalComponent } from '../../../confirmation-modal/confirmation-modal.component';
|
||||||
import {
|
import {
|
||||||
hasValue,
|
hasValue,
|
||||||
isNotEmpty,
|
isNotEmpty,
|
||||||
@@ -54,12 +64,9 @@ import { FormComponent } from '../../../form/form.component';
|
|||||||
import { NotificationsService } from '../../../notifications/notifications.service';
|
import { NotificationsService } from '../../../notifications/notifications.service';
|
||||||
import { UploaderComponent } from '../../../upload/uploader/uploader.component';
|
import { UploaderComponent } from '../../../upload/uploader/uploader.component';
|
||||||
import { UploaderOptions } from '../../../upload/uploader/uploader-options.model';
|
import { UploaderOptions } from '../../../upload/uploader/uploader-options.model';
|
||||||
|
import { followLink } from '../../../utils/follow-link-config.model';
|
||||||
import { VarDirective } from '../../../utils/var.directive';
|
import { VarDirective } from '../../../utils/var.directive';
|
||||||
import { ComcolPageLogoComponent } from '../../comcol-page-logo/comcol-page-logo.component';
|
import { ComcolPageLogoComponent } from '../../comcol-page-logo/comcol-page-logo.component';
|
||||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { followLink } from '../../../utils/follow-link-config.model';
|
|
||||||
import { ConfirmationModalComponent } from '../../../confirmation-modal/confirmation-modal.component';
|
|
||||||
import { filter, take } from 'rxjs/operators';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A form for creating and editing Communities or Collections
|
* A form for creating and editing Communities or Collections
|
||||||
@@ -220,7 +227,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
|
|||||||
this.refreshDSO$.pipe(
|
this.refreshDSO$.pipe(
|
||||||
switchMap(() => this.refreshDsoCache()),
|
switchMap(() => this.refreshDsoCache()),
|
||||||
filter(rd => rd.hasSucceeded),
|
filter(rd => rd.hasSucceeded),
|
||||||
).subscribe(({ payload }) => this.dso = payload)
|
).subscribe(({ payload }) => this.dso = payload),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -324,7 +331,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
|
|||||||
*/
|
*/
|
||||||
subscribeToConfirmationResponse(modalRef: NgbModalRef): void {
|
subscribeToConfirmationResponse(modalRef: NgbModalRef): void {
|
||||||
modalRef.componentInstance.response.pipe(
|
modalRef.componentInstance.response.pipe(
|
||||||
take(1)
|
take(1),
|
||||||
).subscribe((confirmed: boolean) => {
|
).subscribe((confirmed: boolean) => {
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
this.handleLogoDeletion();
|
this.handleLogoDeletion();
|
||||||
@@ -338,7 +345,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
|
|||||||
handleLogoDeletion(): void {
|
handleLogoDeletion(): void {
|
||||||
if (hasValue(this.dso.id) && hasValue(this.dso._links.logo)) {
|
if (hasValue(this.dso.id) && hasValue(this.dso._links.logo)) {
|
||||||
this.dsoService.deleteLogo(this.dso).pipe(
|
this.dsoService.deleteLogo(this.dso).pipe(
|
||||||
getFirstCompletedRemoteData()
|
getFirstCompletedRemoteData(),
|
||||||
).subscribe((response: RemoteData<NoContent>) => {
|
).subscribe((response: RemoteData<NoContent>) => {
|
||||||
const successMessageKey = `${this.type.value}.edit.logo.notifications.delete.success`;
|
const successMessageKey = `${this.type.value}.edit.logo.notifications.delete.success`;
|
||||||
const errorMessageKey = `${this.type.value}.edit.logo.notifications.delete.error`;
|
const errorMessageKey = `${this.type.value}.edit.logo.notifications.delete.error`;
|
||||||
@@ -362,7 +369,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
|
|||||||
this.refreshDSO$.next();
|
this.refreshDSO$.next();
|
||||||
this.notificationsService.success(
|
this.notificationsService.success(
|
||||||
this.translate.get(`${successMessageKey}.title`),
|
this.translate.get(`${successMessageKey}.title`),
|
||||||
this.translate.get(`${successMessageKey}.content`)
|
this.translate.get(`${successMessageKey}.content`),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +381,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
|
|||||||
private handleFailedDeletion(errorMessageKey: string, errorMessage: string): void {
|
private handleFailedDeletion(errorMessageKey: string, errorMessage: string): void {
|
||||||
this.notificationsService.error(
|
this.notificationsService.error(
|
||||||
this.translate.get(`${errorMessageKey}.title`),
|
this.translate.get(`${errorMessageKey}.title`),
|
||||||
errorMessage
|
errorMessage,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +406,7 @@ export class ComColFormComponent<T extends Collection | Community> implements On
|
|||||||
*/
|
*/
|
||||||
private fetchUpdatedDso(): Observable<RemoteData<T>> {
|
private fetchUpdatedDso(): Observable<RemoteData<T>> {
|
||||||
return this.dsoService.findById(this.dso.id, false, true, followLink('logo')).pipe(
|
return this.dsoService.findById(this.dso.id, false, true, followLink('logo')).pipe(
|
||||||
getFirstCompletedRemoteData()
|
getFirstCompletedRemoteData(),
|
||||||
) as Observable<RemoteData<T>>;
|
) as Observable<RemoteData<T>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -195,12 +195,12 @@ describe('ComColMetadataComponent', () => {
|
|||||||
dso: new Community(),
|
dso: new Community(),
|
||||||
uploader: {
|
uploader: {
|
||||||
options: {
|
options: {
|
||||||
url: ''
|
url: '',
|
||||||
},
|
},
|
||||||
queue: [],
|
queue: [],
|
||||||
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
|
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
|
||||||
uploadAll: () => {
|
uploadAll: () => {
|
||||||
}
|
},
|
||||||
/* eslint-enable no-empty,@typescript-eslint/no-empty-function */
|
/* eslint-enable no-empty,@typescript-eslint/no-empty-function */
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -15,10 +15,6 @@ import {
|
|||||||
|
|
||||||
import { ComColDataService } from '../../../../../core/data/comcol-data.service';
|
import { ComColDataService } from '../../../../../core/data/comcol-data.service';
|
||||||
import { RemoteData } from '../../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../../core/data/remote-data';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
|
||||||
import { map, take } from 'rxjs/operators';
|
|
||||||
import { getFirstCompletedRemoteData, getFirstSucceededRemoteData } from '../../../../../core/shared/operators';
|
|
||||||
import { isEmpty } from '../../../../empty.util';
|
|
||||||
import { Collection } from '../../../../../core/shared/collection.model';
|
import { Collection } from '../../../../../core/shared/collection.model';
|
||||||
import { Community } from '../../../../../core/shared/community.model';
|
import { Community } from '../../../../../core/shared/community.model';
|
||||||
import { DSpaceObject } from '../../../../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../../../../core/shared/dspace-object.model';
|
||||||
@@ -27,10 +23,7 @@ import {
|
|||||||
getFirstSucceededRemoteData,
|
getFirstSucceededRemoteData,
|
||||||
} from '../../../../../core/shared/operators';
|
} from '../../../../../core/shared/operators';
|
||||||
import { ResourceType } from '../../../../../core/shared/resource-type';
|
import { ResourceType } from '../../../../../core/shared/resource-type';
|
||||||
import {
|
import { isEmpty } from '../../../../empty.util';
|
||||||
hasValue,
|
|
||||||
isEmpty,
|
|
||||||
} from '../../../../empty.util';
|
|
||||||
import { NotificationsService } from '../../../../notifications/notifications.service';
|
import { NotificationsService } from '../../../../notifications/notifications.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -72,9 +65,9 @@ export class ComcolMetadataComponent<TDomain extends Community | Collection> imp
|
|||||||
onSubmit(event) {
|
onSubmit(event) {
|
||||||
if (!isEmpty(event.operations)) {
|
if (!isEmpty(event.operations)) {
|
||||||
this.dsoDataService.patch(event.dso, event.operations).pipe(getFirstCompletedRemoteData())
|
this.dsoDataService.patch(event.dso, event.operations).pipe(getFirstCompletedRemoteData())
|
||||||
.subscribe(async (response: RemoteData<DSpaceObject>) => {
|
.subscribe( (response: RemoteData<DSpaceObject>) => {
|
||||||
if (response.hasSucceeded) {
|
if (response.hasSucceeded) {
|
||||||
await this.router.navigate([this.frontendURL, event.dso.uuid]); // todo: ok not to await this?
|
this.router.navigate([this.frontendURL, event.dso.uuid]); // todo: ok not to await this?
|
||||||
this.notificationsService.success(null, this.translate.get(`${this.type.value}.edit.notifications.success`));
|
this.notificationsService.success(null, this.translate.get(`${this.type.value}.edit.notifications.success`));
|
||||||
} else if (response.statusCode === 403) {
|
} else if (response.statusCode === 403) {
|
||||||
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.unauthorized`));
|
this.notificationsService.error(null, this.translate.get(`${this.type.value}.edit.notifications.unauthorized`));
|
||||||
|
Reference in New Issue
Block a user