mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +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 { I18nBreadcrumbResolver } from 'src/app/core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||
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 { 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,
|
||||
resolve: {breadcrumb: I18nBreadcrumbResolver},
|
||||
data: {title: 'ldn-registered-services.title', breadcrumbKey: 'ldn-registered-services.new'},
|
||||
canActivate: [LdnServicesGuard]
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
|
@@ -84,7 +84,7 @@
|
||||
<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">
|
||||
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}"
|
||||
name="additionalInboundPattern{{i}}" required>
|
||||
@@ -116,10 +116,10 @@
|
||||
|
||||
|
||||
<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>
|
||||
</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">
|
||||
<i class="fas fa-undo"></i>
|
||||
</button>
|
||||
@@ -157,7 +157,7 @@
|
||||
<ng-container [formGroupName]="i">
|
||||
|
||||
<!-- 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">
|
||||
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}"
|
||||
name="additionalOutboundPattern{{i}}"
|
||||
@@ -185,11 +185,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-1">
|
||||
<button (click)="removeOutboundPattern(i)" class="btn btn-outline-dark trash-button"
|
||||
type="button">
|
||||
<div class="col-sm-1 btn-group">
|
||||
<button (click)="markForOutboundPatternDeletion(i)" class="btn btn-outline-dark trash-button" type="button">
|
||||
<i class="fas fa-trash"></i>
|
||||
</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>
|
||||
</ng-container>
|
||||
|
@@ -56,7 +56,8 @@ export class LdnServiceFormEditComponent implements OnInit {
|
||||
@Input() public constraint: string;
|
||||
@Input() public automatic: boolean;
|
||||
@Input() public headerKey: string;
|
||||
markedForDeletion: number[] = [];
|
||||
markedForDeletionInboundPattern: number[] = [];
|
||||
markedForDeletionOutboundPattern: number[] = [];
|
||||
protected serviceId: string;
|
||||
private originalInboundPatterns: any[] = [];
|
||||
private originalOutboundPatterns: any[] = [];
|
||||
@@ -259,7 +260,8 @@ export class LdnServiceFormEditComponent implements OnInit {
|
||||
}
|
||||
|
||||
patchService() {
|
||||
this.deleteMarkedPatterns();
|
||||
this.deleteMarkedInboundPatterns();
|
||||
this.deleteMarkedOutboundPatterns();
|
||||
const patchOperations = this.generatePatchOperations();
|
||||
|
||||
|
||||
@@ -282,31 +284,58 @@ export class LdnServiceFormEditComponent implements OnInit {
|
||||
this.closeModal();
|
||||
}
|
||||
|
||||
markForDeletion(index: number) {
|
||||
if (!this.markedForDeletion.includes(index)) {
|
||||
this.markedForDeletion.push(index);
|
||||
markForInboundPatternDeletion(index: number) {
|
||||
if (!this.markedForDeletionInboundPattern.includes(index)) {
|
||||
this.markedForDeletionInboundPattern.push(index);
|
||||
}
|
||||
}
|
||||
|
||||
unmarkForDeletion(index: number) {
|
||||
const i = this.markedForDeletion.indexOf(index);
|
||||
unmarkForInboundPatternDeletion(index: number) {
|
||||
const i = this.markedForDeletionInboundPattern.indexOf(index);
|
||||
if (i !== -1) {
|
||||
this.markedForDeletion.splice(i, 1);
|
||||
this.markedForDeletionInboundPattern.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
deleteMarkedPatterns() {
|
||||
this.markedForDeletion.sort((a, b) => b - a);
|
||||
markForOutboundPatternDeletion(index: number) {
|
||||
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;
|
||||
|
||||
for (const index of this.markedForDeletion) {
|
||||
for (const index of this.markedForDeletionInboundPattern) {
|
||||
if (index >= 0 && index < patternsArray.length) {
|
||||
this.deletedInboundPatterns.push(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 {
|
||||
|
Reference in New Issue
Block a user