@@ -92,7 +92,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
9292 public inboundPatterns : string [ ] = notifyPatterns ;
9393 public isNewService : boolean ;
9494 public areControlsInitialized : boolean ;
95- public itemfiltersRD $ : Observable < RemoteData < PaginatedList < Itemfilter > > > ;
95+ public itemFiltersRD $ : Observable < RemoteData < PaginatedList < Itemfilter > > > ;
9696 public config : FindListOptions = Object . assign ( new FindListOptions ( ) , {
9797 elementsPerPage : 20 ,
9898 } ) ;
@@ -104,12 +104,12 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
104104 private deletedInboundPatterns : number [ ] = [ ] ;
105105 private modalRef : any ;
106106 private ldnService : LdnService ;
107- private selectPatternDefaultLabeli18Key = 'ldn-service.form.label.placeholder.default-select' ;
107+ private selectPatternDefaultLabelI18Key = 'ldn-service.form.label.placeholder.default-select' ;
108108 private routeSubscription : Subscription ;
109109
110110 constructor (
111111 protected ldnServicesService : LdnServicesService ,
112- private ldnItemfiltersService : LdnItemfiltersService ,
112+ private ldnItemFiltersService : LdnItemfiltersService ,
113113 private formBuilder : FormBuilder ,
114114 private router : Router ,
115115 private route : ActivatedRoute ,
@@ -147,7 +147,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
147147 this . fetchServiceData ( this . serviceId ) ;
148148 }
149149 } ) ;
150- this . setItemfilters ( ) ;
150+ this . setItemFilters ( ) ;
151151 }
152152
153153 ngOnDestroy ( ) : void {
@@ -157,8 +157,8 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
157157 /**
158158 * Sets item filters using LDN item filters service
159159 */
160- setItemfilters ( ) {
161- this . itemfiltersRD $ = this . ldnItemfiltersService . findAll ( ) . pipe (
160+ setItemFilters ( ) {
161+ this . itemFiltersRD $ = this . ldnItemFiltersService . findAll ( ) . pipe (
162162 getFirstCompletedRemoteData ( ) ) ;
163163 }
164164
@@ -168,21 +168,12 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
168168 */
169169 createService ( ) {
170170 this . formModel . markAllAsTouched ( ) ;
171- const notifyServiceInboundPatterns = this . formModel . get ( 'notifyServiceInboundPatterns' ) as FormArray ;
172- const hasInboundPattern = notifyServiceInboundPatterns ?. length > 0 ? this . checkPatterns ( notifyServiceInboundPatterns ) : false ;
173171
174172 if ( this . formModel . invalid ) {
175173 this . closeModal ( ) ;
176174 return ;
177175 }
178176
179- if ( ! hasInboundPattern ) {
180- this . notificationService . warning ( this . translateService . get ( 'ldn-service-notification.created.warning.title' ) ) ;
181- this . closeModal ( ) ;
182- return ;
183- }
184-
185-
186177 this . formModel . value . notifyServiceInboundPatterns = this . formModel . value . notifyServiceInboundPatterns . map ( ( pattern : {
187178 pattern : string ;
188179 patternLabel : string ,
@@ -272,20 +263,24 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
272263 }
273264
274265 /**
275- * Filters pattern objects, initializes form groups, assigns labels, and adds them to the specified form array so the correct string is shown in the dropdown..
266+ * Filters pattern objects, initializes form groups, assigns labels, and adds them to the specified form array so the correct string is shown in the dropdown.
276267 * @param formArrayName - The name of the form array to be populated
277268 */
278269 filterPatternObjectsAndAssignLabel ( formArrayName : string ) {
279270 const PatternsArray = this . formModel . get ( formArrayName ) as FormArray ;
280271 PatternsArray . clear ( ) ;
281272
282- const servicesToUse = this . ldnService . notifyServiceInboundPatterns ;
273+ const servicesToUse = [ ...this . ldnService . notifyServiceInboundPatterns ] ;
274+ if ( servicesToUse . length === 0 ) {
275+ servicesToUse . push ( { pattern : '' , constraint : '' , automatic : 'false' } ) ;
276+ }
283277
284278 servicesToUse . forEach ( ( patternObj : NotifyServicePattern ) => {
285279 const patternFormGroup = this . initializeInboundPatternFormGroup ( ) ;
280+ const patternLabel = patternObj ?. pattern ? 'ldn-service.form.pattern.' + patternObj ?. pattern + '.label' : 'ldn-service.form.label.placeholder.default-select' ;
286281 const newPatternObjWithLabel = Object . assign ( new NotifyServicePattern ( ) , {
287282 ...patternObj ,
288- patternLabel : this . translateService . instant ( 'ldn-service.form.pattern.' + patternObj ?. pattern + '.label' ) ,
283+ patternLabel : this . translateService . instant ( patternLabel ) ,
289284 } ) ;
290285 patternFormGroup . patchValue ( newPatternObjWithLabel ) ;
291286
@@ -412,7 +407,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
412407 }
413408
414409 /**
415- * Patches the LDN service by retrieving and sending patch operations geenrated in generatePatchOperations()
410+ * Patches the LDN service by retrieving and sending patch operations generated in generatePatchOperations()
416411 */
417412 patchService ( ) {
418413 this . deleteMarkedInboundPatterns ( ) ;
@@ -425,17 +420,6 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
425420 return ;
426421 }
427422
428- const notifyServiceInboundPatterns = this . formModel . get ( 'notifyServiceInboundPatterns' ) as FormArray ;
429- const deletedInboundPatternsLength = this . deletedInboundPatterns . length ;
430- // If no inbound patterns are specified, close the modal and return
431- // notify the user that no patterns are specified
432- if ( notifyServiceInboundPatterns . length === deletedInboundPatternsLength ) {
433- this . notificationService . warning ( this . translateService . get ( 'ldn-service-notification.created.warning.title' ) ) ;
434- this . deletedInboundPatterns = [ ] ;
435- this . closeModal ( ) ;
436- return ;
437- }
438-
439423 this . ldnServicesService . patch ( this . ldnService , patchOperations ) . pipe (
440424 getFirstCompletedRemoteData ( ) ,
441425 ) . subscribe (
@@ -571,7 +555,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
571555 private createInboundPatternFormGroup ( ) : FormGroup {
572556 const inBoundFormGroup = {
573557 pattern : '' ,
574- patternLabel : this . translateService . instant ( this . selectPatternDefaultLabeli18Key ) ,
558+ patternLabel : this . translateService . instant ( this . selectPatternDefaultLabelI18Key ) ,
575559 constraint : '' ,
576560 constraintFormatted : '' ,
577561 automatic : false ,
0 commit comments