Fix closing broadcast messages
This commit is contained in:
parent
ea88a6271a
commit
1570935099
|
@ -1,10 +1,13 @@
|
|||
`import Ember from 'ember'`
|
||||
`import LimitedArray from 'travis/utils/limited-array'`
|
||||
`import Broadcast from 'travis/models/broadcast'`
|
||||
|
||||
Controller = Ember.Controller.extend
|
||||
needs: ['currentUser']
|
||||
currentUserBinding: 'controllers.currentUser.model'
|
||||
FlashDisplayComponent = Ember.Component.extend
|
||||
auth: Ember.inject.service()
|
||||
store: Ember.inject.service()
|
||||
currentUserBinding: 'auth.currentUser'
|
||||
|
||||
classNames: ['flash']
|
||||
tagName: 'ul'
|
||||
|
||||
init: ->
|
||||
@_super.apply this, arguments
|
||||
|
@ -28,7 +31,7 @@ Controller = Ember.Controller.extend
|
|||
broadcasts = Ember.ArrayProxy.create(content: [])
|
||||
|
||||
if @get('currentUser.id')
|
||||
@store.find('broadcast').then (result) ->
|
||||
@get('store').find('broadcast').then (result) ->
|
||||
broadcasts.pushObjects(result.toArray())
|
||||
|
||||
broadcasts
|
||||
|
@ -42,14 +45,14 @@ Controller = Ember.Controller.extend
|
|||
Ember.run.later(this, (-> @get('flashes.content').removeObject(msg)), 15000)
|
||||
|
||||
close: (msg) ->
|
||||
if msg instanceof Broadcast
|
||||
if msg.constructor.modelName == "broadcast"
|
||||
msg.setSeen()
|
||||
@notifyPropertyChange('unseenBroadcasts')
|
||||
else
|
||||
@get('flashes').removeObject(msg)
|
||||
|
||||
actions:
|
||||
close: (msg) ->
|
||||
closeMessage: (msg) ->
|
||||
@close(msg)
|
||||
|
||||
`export default Controller`
|
||||
`export default FlashDisplayComponent`
|
|
@ -1,6 +1,6 @@
|
|||
`import BasicView from 'travis/views/basic'`
|
||||
`import Ember from 'ember'`
|
||||
|
||||
View = BasicView.extend
|
||||
FlashItemComponent = Ember.Component.extend
|
||||
tagName: 'li'
|
||||
classNameBindings: ['type']
|
||||
|
||||
|
@ -10,6 +10,6 @@ View = BasicView.extend
|
|||
|
||||
actions:
|
||||
close: ->
|
||||
@get('controller').close(@get('flash'))
|
||||
this.attrs.close(@get('flash'))
|
||||
|
||||
`export default View`
|
||||
`export default FlashItemComponent`
|
3
app/templates/components/flash-display.hbs
Normal file
3
app/templates/components/flash-display.hbs
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{#each flash in messages}}
|
||||
{{flash-item flash=flash close=(action 'closeMessage')}}
|
||||
{{/each}}
|
2
app/templates/components/flash-item.hbs
Normal file
2
app/templates/components/flash-item.hbs
Normal file
|
@ -0,0 +1,2 @@
|
|||
<p>{{{flash.message}}}</p>
|
||||
<a class="close" {{action "close"}}></a>
|
|
@ -1,6 +1 @@
|
|||
{{#each flash in messages}}
|
||||
{{#view "flash-item" flashBinding="flash"}}
|
||||
<p>{{{flash.message}}}</p>
|
||||
<a class="close" {{action "close" target=view}}></a>
|
||||
{{/view}}
|
||||
{{/each}}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{{render "top"}}
|
||||
</header>
|
||||
|
||||
{{render "flash"}}
|
||||
{{flash-display}}
|
||||
|
||||
<div class="wrapper-main">
|
||||
<div id="main" role="main">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{{render "top"}}
|
||||
</div>
|
||||
|
||||
{{render "flash"}}
|
||||
{{flash-display}}
|
||||
|
||||
{{yield}}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</header>
|
||||
|
||||
<div class="centered">
|
||||
{{render "flash"}}
|
||||
{{flash-display}}
|
||||
<div id="main" class="main" role="main">
|
||||
{{yield}}
|
||||
|
||||
|
@ -17,4 +17,4 @@
|
|||
|
||||
<footer>
|
||||
{{render "footer"}}
|
||||
</footer>
|
||||
</footer>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</header>
|
||||
|
||||
<div class="centered">
|
||||
{{render "flash"}}
|
||||
{{flash-display}}
|
||||
<div id="main" class="main" role="main">
|
||||
{{yield}}
|
||||
</div>
|
||||
|
@ -15,4 +15,4 @@
|
|||
|
||||
<footer>
|
||||
{{render "footer"}}
|
||||
</footer>
|
||||
</footer>
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
`import BasicView from 'travis/views/basic'`
|
||||
|
||||
View = BasicView.extend
|
||||
classNames: ['flash']
|
||||
tagName: 'ul'
|
||||
templateName: 'layouts/flash'
|
||||
|
||||
`export default View`
|
Loading…
Reference in New Issue
Block a user