Revision 51581
Added by Myrto Koukouli over 6 years ago
my-array.interface.ts | ||
---|---|---|
9 | 9 |
import { Description } from '../../../domain/oa-description'; |
10 | 10 |
import { Subject } from "rxjs/Subject"; |
11 | 11 |
import {ConfirmationDialogComponent} from "../confirmation-dialog.component"; |
12 |
import {nonRemovableInterface} from "../../../domain/shared-messages"; |
|
12 | 13 |
|
13 | 14 |
|
14 | 15 |
@Component({ |
... | ... | |
51 | 52 |
|
52 | 53 |
arrayData_ : Subject<any>[] = []; |
53 | 54 |
|
55 |
components : MyGroup[] = []; |
|
56 |
|
|
54 | 57 |
push() { |
55 | 58 |
this.createView(); |
56 | 59 |
} |
... | ... | |
65 | 68 |
let wrapperFactory = this._cfr.resolveComponentFactory(this.wrapper); |
66 | 69 |
let wrapperView = wrapperFactory.create(this.viewContainerRef.injector); |
67 | 70 |
let componentView = componentFactory.create(this.viewContainerRef.injector); |
68 |
|
|
71 |
this.components.push(componentView.instance); |
|
69 | 72 |
(<MyGroup>componentView.instance).index = this.viewContainerRef.length; |
70 | 73 |
(<MyGroup>componentView.instance).required = this.required; |
71 | 74 |
(<MyGroup>componentView.instance).data = this.data; |
... | ... | |
89 | 92 |
if (index>0){ |
90 | 93 |
this.curIntrf = <MyGroup>componentView.instance; |
91 | 94 |
this.curIndex = index; |
95 |
this.components.splice(index,1); |
|
92 | 96 |
this.confirmRemoveInterface(); |
93 |
} else { (<MyGroup>componentView.instance).groupErrorMessage = 'At least one interface must be present'; } |
|
97 |
} else { |
|
98 |
(<MyGroup>componentView.instance).groupErrorMessage = nonRemovableInterface; |
|
99 |
} |
|
94 | 100 |
/*(<MyGroup>componentView.instance).toBeDeleted = true; |
95 | 101 |
this.remove(index); |
96 | 102 |
(this.parentGroup as FormArray).controls[this.name].removeAt(index-1); |
... | ... | |
104 | 110 |
console.log("ADDED NEW GROUP IN CREATEVIEW"); |
105 | 111 |
} |
106 | 112 |
|
113 |
public checkIfOneElementExists() { |
|
114 |
console.log(`searching`); |
|
115 |
return this.components.some(data => data.wasSaved); |
|
116 |
} |
|
117 |
|
|
107 | 118 |
isModalShown: boolean = false; |
108 | 119 |
curIntrf: any; |
109 | 120 |
curIndex: number; |
Also available in: Unified diff
fixed checking if at least one interface was saved