mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
CST-12174 Updated delete services to mark for deletion on outboundpatterns as well
This commit is contained in:
@@ -2,7 +2,6 @@ import { NgModule } from '@angular/core';
|
|||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { I18nBreadcrumbResolver } from 'src/app/core/breadcrumbs/i18n-breadcrumb.resolver';
|
import { I18nBreadcrumbResolver } from 'src/app/core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
import { LdnServicesOverviewComponent } from './ldn-services-directory/ldn-services-directory.component';
|
import { LdnServicesOverviewComponent } from './ldn-services-directory/ldn-services-directory.component';
|
||||||
import { LdnServicesGuard } from './ldn-services-guard/ldn-services-guard.service';
|
|
||||||
import { LdnServiceNewComponent } from './ldn-service-new/ldn-service-new.component';
|
import { LdnServiceNewComponent } from './ldn-service-new/ldn-service-new.component';
|
||||||
import { LdnServiceFormEditComponent } from './ldn-service-form-edit/ldn-service-form-edit.component';
|
import { LdnServiceFormEditComponent } from './ldn-service-form-edit/ldn-service-form-edit.component';
|
||||||
|
|
||||||
@@ -15,7 +14,6 @@ import { LdnServiceFormEditComponent } from './ldn-service-form-edit/ldn-service
|
|||||||
component: LdnServicesOverviewComponent,
|
component: LdnServicesOverviewComponent,
|
||||||
resolve: {breadcrumb: I18nBreadcrumbResolver},
|
resolve: {breadcrumb: I18nBreadcrumbResolver},
|
||||||
data: {title: 'ldn-registered-services.title', breadcrumbKey: 'ldn-registered-services.new'},
|
data: {title: 'ldn-registered-services.title', breadcrumbKey: 'ldn-registered-services.new'},
|
||||||
canActivate: [LdnServicesGuard]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'new',
|
path: 'new',
|
||||||
|
@@ -84,7 +84,7 @@
|
|||||||
<ng-container [formGroupName]="i">
|
<ng-container [formGroupName]="i">
|
||||||
|
|
||||||
|
|
||||||
<div [class.marked-for-deletion]="markedForDeletion.includes(i)" class="row mb-1">
|
<div [class.marked-for-deletion]="markedForDeletionInboundPattern.includes(i)" class="row mb-1">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}"
|
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}"
|
||||||
name="additionalInboundPattern{{i}}" required>
|
name="additionalInboundPattern{{i}}" required>
|
||||||
@@ -116,10 +116,10 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="col-sm-1 btn-group">
|
<div class="col-sm-1 btn-group">
|
||||||
<button (click)="markForDeletion(i)" class="btn btn-outline-dark trash-button" type="button">
|
<button (click)="markForInboundPatternDeletion(i)" class="btn btn-outline-dark trash-button" type="button">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
<button (click)="unmarkForDeletion(i)" *ngIf="markedForDeletion.includes(i)" class="btn btn-outline-dark undo-button"
|
<button (click)="unmarkForInboundPatternDeletion(i)" *ngIf="markedForDeletionInboundPattern.includes(i)" class="btn btn-outline-dark undo-button"
|
||||||
type="button">
|
type="button">
|
||||||
<i class="fas fa-undo"></i>
|
<i class="fas fa-undo"></i>
|
||||||
</button>
|
</button>
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
<ng-container [formGroupName]="i">
|
<ng-container [formGroupName]="i">
|
||||||
|
|
||||||
<!-- Input elements in a separate row -->
|
<!-- Input elements in a separate row -->
|
||||||
<div class="row mb-1">
|
<div [class.marked-for-deletion]="markedForDeletionOutboundPattern.includes(i)" class="row mb-1">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}"
|
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}"
|
||||||
name="additionalOutboundPattern{{i}}"
|
name="additionalOutboundPattern{{i}}"
|
||||||
@@ -185,11 +185,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1 btn-group">
|
||||||
<button (click)="removeOutboundPattern(i)" class="btn btn-outline-dark trash-button"
|
<button (click)="markForOutboundPatternDeletion(i)" class="btn btn-outline-dark trash-button" type="button">
|
||||||
type="button">
|
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
|
<button (click)="unmarkForOutboundPatternDeletion(i)" *ngIf="markedForDeletionOutboundPattern.includes(i)" class="btn btn-outline-dark undo-button"
|
||||||
|
type="button">
|
||||||
|
<i class="fas fa-undo"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -56,7 +56,8 @@ export class LdnServiceFormEditComponent implements OnInit {
|
|||||||
@Input() public constraint: string;
|
@Input() public constraint: string;
|
||||||
@Input() public automatic: boolean;
|
@Input() public automatic: boolean;
|
||||||
@Input() public headerKey: string;
|
@Input() public headerKey: string;
|
||||||
markedForDeletion: number[] = [];
|
markedForDeletionInboundPattern: number[] = [];
|
||||||
|
markedForDeletionOutboundPattern: number[] = [];
|
||||||
protected serviceId: string;
|
protected serviceId: string;
|
||||||
private originalInboundPatterns: any[] = [];
|
private originalInboundPatterns: any[] = [];
|
||||||
private originalOutboundPatterns: any[] = [];
|
private originalOutboundPatterns: any[] = [];
|
||||||
@@ -259,7 +260,8 @@ export class LdnServiceFormEditComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
patchService() {
|
patchService() {
|
||||||
this.deleteMarkedPatterns();
|
this.deleteMarkedInboundPatterns();
|
||||||
|
this.deleteMarkedOutboundPatterns();
|
||||||
const patchOperations = this.generatePatchOperations();
|
const patchOperations = this.generatePatchOperations();
|
||||||
|
|
||||||
|
|
||||||
@@ -282,31 +284,58 @@ export class LdnServiceFormEditComponent implements OnInit {
|
|||||||
this.closeModal();
|
this.closeModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
markForDeletion(index: number) {
|
markForInboundPatternDeletion(index: number) {
|
||||||
if (!this.markedForDeletion.includes(index)) {
|
if (!this.markedForDeletionInboundPattern.includes(index)) {
|
||||||
this.markedForDeletion.push(index);
|
this.markedForDeletionInboundPattern.push(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unmarkForDeletion(index: number) {
|
unmarkForInboundPatternDeletion(index: number) {
|
||||||
const i = this.markedForDeletion.indexOf(index);
|
const i = this.markedForDeletionInboundPattern.indexOf(index);
|
||||||
if (i !== -1) {
|
if (i !== -1) {
|
||||||
this.markedForDeletion.splice(i, 1);
|
this.markedForDeletionInboundPattern.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMarkedPatterns() {
|
markForOutboundPatternDeletion(index: number) {
|
||||||
this.markedForDeletion.sort((a, b) => b - a);
|
if (!this.markedForDeletionOutboundPattern.includes(index)) {
|
||||||
|
this.markedForDeletionOutboundPattern.push(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unmarkForOutboundPatternDeletion(index: number) {
|
||||||
|
const i = this.markedForDeletionOutboundPattern.indexOf(index);
|
||||||
|
if (i !== -1) {
|
||||||
|
this.markedForDeletionOutboundPattern.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteMarkedInboundPatterns() {
|
||||||
|
this.markedForDeletionInboundPattern.sort((a, b) => b - a);
|
||||||
const patternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
|
const patternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
|
||||||
|
|
||||||
for (const index of this.markedForDeletion) {
|
for (const index of this.markedForDeletionInboundPattern) {
|
||||||
if (index >= 0 && index < patternsArray.length) {
|
if (index >= 0 && index < patternsArray.length) {
|
||||||
this.deletedInboundPatterns.push(index);
|
this.deletedInboundPatterns.push(index);
|
||||||
patternsArray.removeAt(index);
|
patternsArray.removeAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.markedForDeletion = [];
|
this.markedForDeletionInboundPattern = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteMarkedOutboundPatterns() {
|
||||||
|
this.markedForDeletionOutboundPattern.sort((a, b) => b - a);
|
||||||
|
const patternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
|
||||||
|
|
||||||
|
for (const index of this.markedForDeletionOutboundPattern) {
|
||||||
|
if (index >= 0 && index < patternsArray.length) {
|
||||||
|
this.deletedOutboundPatterns.push(index);
|
||||||
|
patternsArray.removeAt(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.markedForDeletionOutboundPattern = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private createReplaceOperation(patchOperations: any[], formControlName: string, path: string): void {
|
private createReplaceOperation(patchOperations: any[], formControlName: string, path: string): void {
|
||||||
|
Reference in New Issue
Block a user