Skip to content

Commit

Permalink
auto refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Aug 9, 2019
1 parent e2451a9 commit b050286
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 27 deletions.
23 changes: 17 additions & 6 deletions src/EMM-WebApplication/EMMListModule.class.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Class {
#name : #EMMListModule,
#superclass : #EMMModule,
#traits : 'TWithRootDialogComponent',
#classTraits : 'TWithRootDialogComponent classTrait',
#traits : 'TWithRootDialogComponent + EMMTDisplayList',
#classTraits : 'TWithRootDialogComponent classTrait + EMMTDisplayList classTrait',
#instVars : [
'datas'
],
Expand Down Expand Up @@ -104,11 +104,22 @@ EMMListModule >> renderOn: html menuForPlayable: song [
onClickUpdateRootDialogWith: [ :r | self renderDialogOn: r addPlayable: song ];
fullBleedDivider;
with: 'Add in playlist'.
html mdlMenuItem
onClick: (html jQuery ajax callback: [ self session model addNextPlayable: song ]);
with: [ html text: 'Play next'].
html mdlMenuItem
onClick: (html jQuery ajax callback: [ self session model addAtTheEndPlayable: song ]);
onClick:
((html jQuery id: self listId) load
html: [ :canvas |
self session model addNextPlayable: song.
self renderListOn: canvas ];
onComplete: 'componentHandler.upgradeDom();' js);
"onClick: (html jQuery ajax callback: [ self session model addNextPlayable: song ]);"
with: [ html text: 'Play next' ].
html mdlMenuItem
onClick:
((html jQuery id: self listId) load
html: [ :canvas |
self session model addAtTheEndPlayable: song.
self renderListOn: canvas ];
onComplete: 'componentHandler.upgradeDom();' js);
with: [ html text: 'Play at the end' ] ]
]

Expand Down
28 changes: 7 additions & 21 deletions src/EMM-WebApplication/EMMQueueModule.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Class {
#name : #EMMQueueModule,
#superclass : #EMMModule,
#traits : 'EMMTDisplayList',
#classTraits : 'EMMTDisplayList classTrait',
#category : #'EMM-WebApplication-Core'
}

Expand Down Expand Up @@ -46,28 +48,12 @@ EMMQueueModule >> renderContentOn: html [
size: 6;
with: [ html paragraph
id: self musicTitleId;
with: (self session model currentPlayable ifNotNil: [ :song | (song title) ifNil: [ song name ] ] ifNil: [ '' ]) ] ].
with: (self session model currentPlayable ifNotNil: [ :song | song title ifNil: [ song name ] ] ifNil: [ '' ]) ] ].
html render: (MDLProgressBarWidget progression: [ self session model musicPlayer currentPosition ]).
html mdlTable
attributeAt: 'width' put: '100%';
with: [ html
tableHead: [ html
tableRow: [ html mdlTableHeading
nonNumerical;
with: 'Title'.
html mdlTableHeading: 'Lenght'.
html mdlTableHeading: 'Author' ] ].
html
tableBody: [ datas
do: [ :song |
html
tableRow: [ html mdlTableCell
nonNumerical;
with: (song title ifNil: [ song name ]).
html mdlTableCell
nonNumerical;
with: [ html text: (song artists asOrderedCollection ifNotEmpty: [ :col | col first name ] ifEmpty: [ 'No Author' ]) ].
html mdlTableCell with: song length ] ] ] ].

html div
id: self listId;
with: [ self renderListOn: html ].

self renderJavaScriptOn: html
]
Expand Down
40 changes: 40 additions & 0 deletions src/EMM-WebApplication/EMMTDisplayList.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Trait {
#name : #EMMTDisplayList,
#category : #'EMM-WebApplication'
}

{ #category : #rendering }
EMMTDisplayList >> dataPlaylist [
^ self session model playList.
]

{ #category : #rendering }
EMMTDisplayList >> listId [
^ #listID
]

{ #category : #rendering }
EMMTDisplayList >> renderListOn: html [
| datas |
datas := self dataPlaylist.
html mdlTable
attributeAt: 'width' put: '100%';
with: [ html
tableHead: [ html
tableRow: [ html mdlTableHeading
nonNumerical;
with: 'Title'.
html mdlTableHeading: 'Lenght'.
html mdlTableHeading: 'Author' ].
html
tableBody: [ datas
do: [ :song |
html
tableRow: [ html mdlTableCell
nonNumerical;
with: (song title ifNil: [ song name ]).
html mdlTableCell
nonNumerical;
with: [ html text: (song artists asOrderedCollection ifNotEmpty: [ :col | col first name ] ifEmpty: [ 'No Author' ]) ].
html mdlTableCell with: song length ] ] ] ] ]
]

0 comments on commit b050286

Please sign in to comment.