mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
CST-12174 added isNew Check for patterns deeltion
This commit is contained in:
@@ -200,23 +200,6 @@ export class LdnServiceFormEditComponent implements OnInit {
|
|||||||
notifyServiceOutboundPatternsArray.push(this.createOutboundPatternFormGroup());
|
notifyServiceOutboundPatternsArray.push(this.createOutboundPatternFormGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
removeOutboundPattern(index: number): void {
|
|
||||||
const patternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
|
|
||||||
const patternGroup = patternsArray.at(index) as FormGroup;
|
|
||||||
const patternValue = patternGroup.value;
|
|
||||||
|
|
||||||
if (index < 0 || index >= patternsArray.length || patternValue.isNew) {
|
|
||||||
patternsArray.removeAt(index);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this.deletedOutboundPatterns.push(index);
|
|
||||||
|
|
||||||
patternsArray.removeAt(index);
|
|
||||||
this.cdRef.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
toggleAutomatic(i: number) {
|
toggleAutomatic(i: number) {
|
||||||
const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
|
const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
|
||||||
@@ -316,22 +299,34 @@ export class LdnServiceFormEditComponent implements OnInit {
|
|||||||
|
|
||||||
for (const index of this.markedForDeletionInboundPattern) {
|
for (const index of this.markedForDeletionInboundPattern) {
|
||||||
if (index >= 0 && index < patternsArray.length) {
|
if (index >= 0 && index < patternsArray.length) {
|
||||||
this.deletedInboundPatterns.push(index);
|
const patternGroup = patternsArray.at(index) as FormGroup;
|
||||||
patternsArray.removeAt(index);
|
const patternValue = patternGroup.value;
|
||||||
|
if (patternValue.isNew) {
|
||||||
|
patternsArray.removeAt(index);
|
||||||
|
} else {
|
||||||
|
this.deletedInboundPatterns.push(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.markedForDeletionInboundPattern = [];
|
this.markedForDeletionInboundPattern = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
deleteMarkedOutboundPatterns() {
|
deleteMarkedOutboundPatterns() {
|
||||||
this.markedForDeletionOutboundPattern.sort((a, b) => b - a);
|
this.markedForDeletionOutboundPattern.sort((a, b) => b - a);
|
||||||
const patternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
|
const patternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
|
||||||
|
|
||||||
for (const index of this.markedForDeletionOutboundPattern) {
|
for (const index of this.markedForDeletionOutboundPattern) {
|
||||||
if (index >= 0 && index < patternsArray.length) {
|
if (index >= 0 && index < patternsArray.length) {
|
||||||
this.deletedOutboundPatterns.push(index);
|
const patternGroup = patternsArray.at(index) as FormGroup;
|
||||||
patternsArray.removeAt(index);
|
const patternValue = patternGroup.value;
|
||||||
|
if (patternValue.isNew) {
|
||||||
|
patternsArray.removeAt(index);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
this.deletedOutboundPatterns.push(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user