Skip to content

Commit

Permalink
Fixed #3837
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Sep 11, 2017
1 parent 1242880 commit 6cc99a7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/app/components/common/messageservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export class MessageService {
this.messageSource.next(messages);
}
}

clear() {
this.messageSource.next(null);
}
}
13 changes: 9 additions & 4 deletions src/app/components/growl/growl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ export class Growl implements AfterViewInit,DoCheck,OnDestroy {

if(messageService) {
this.subscription = messageService.messageObserver.subscribe(messages => {
if(messages instanceof Array)
this.value = messages;
else
this.value = [messages];
if(messages) {
if(messages instanceof Array)
this.value = messages;
else
this.value = [messages];
}
else {
this.value = null;
}
});
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/app/components/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ export class Messages implements OnDestroy {
constructor(@Optional() public messageService: MessageService) {
if(messageService) {
this.subscription = messageService.messageObserver.subscribe(messages => {
if(messages instanceof Array)
this.value = messages;
else
this.value = [messages];
if(messages) {
if(messages instanceof Array)
this.value = messages;
else
this.value = [messages];
}
else {
this.value = null;
}
});
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/app/showcase/components/growl/growldemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ <h3 class="first">Basic</h3>
</div>

<h3>Message Service</h3>
<button type="button" pButton (click)="showViaService()" label="Use Service"></button>
<button type="button" pButton (click)="showViaService()" label="Add with Service"></button>
<button type="button" pButton (click)="clearViaService()" label="Clear with Service"></button>
</div>

<div class="content-section documentation">
Expand Down Expand Up @@ -85,6 +86,10 @@ <h3>Message Service</h3>
this.messageService.addAdd([&#123;severity:'success', summary:'Service Message', detail:'Via MessageService'&#125;,
&#123;severity:'info', summary:'Info Message', detail:'Via MessageService'&#125;]);
&#125;

clear() &#123;
this.messageService.clear();
&#125;
&#125;
</code>
</pre>
Expand Down Expand Up @@ -276,7 +281,8 @@ <h3>Dependencies</h3>
&lt;/div&gt;

&lt;h3&gt;Message Service&lt;/h3&gt;
&lt;button type="button" pButton (click)="showViaService()" label="Use Service"&gt;&lt;/button&gt;
&lt;button type="button" pButton (click)="showViaService()" label="Add with Service"&gt;&lt;/button&gt;
&lt;button type="button" pButton (click)="clearViaService()" label="Clear with Service"&gt;&lt;/button&gt;
</code>
</pre>

Expand Down Expand Up @@ -327,6 +333,10 @@ <h3>Dependencies</h3>
showViaService() &#123;
this.messageService.add(&#123;severity:'success', summary:'Service Message', detail:'Via MessageService'&#125;);
&#125;

clearViaService() &#123;
this.messageService.clear();
&#125;

clear() &#123;
this.msgs = [];
Expand All @@ -336,4 +346,4 @@ <h3>Dependencies</h3>
</pre>
</p-tabPanel>
</p-tabView>
</div>
</div>
4 changes: 4 additions & 0 deletions src/app/showcase/components/growl/growldemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class GrowlDemo {
showViaService() {
this.messageService.add({severity:'success', summary:'Service Message', detail:'Via MessageService'});
}

clearViaService() {
this.messageService.clear();
}

clear() {
this.msgs = [];
Expand Down
4 changes: 4 additions & 0 deletions src/app/showcase/components/messages/messagesdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ <h3>Message Service</h3>
this.messageService.addAdd([&#123;severity:'success', summary:'Service Message', detail:'Via MessageService'&#125;,
&#123;severity:'info', summary:'Info Message', detail:'Via MessageService'&#125;]);
&#125;

clear() &#123;
this.messageService.clear();
&#125;
&#125;
</code>
</pre>
Expand Down

0 comments on commit 6cc99a7

Please sign in to comment.