diff --git a/App.coffee b/App.coffee index 0b135ea..0224d58 100644 --- a/App.coffee +++ b/App.coffee @@ -202,8 +202,11 @@ Ext.define 'RallyPokerApp', { } @down('#storypicker').add @StoryList - Ext.getCmp('storyback').on 'click', () => + Ext.getCmp('storyback').on 'click', => @getLayout().setActiveItem 'storypicker' + @StoryPage.update {} + @DiscussionThread.update {} + @DiscussionThread.tpl.showEstimates = false return @CurrentStory = Ext.create 'Rally.data.WsapiDataStore', { @@ -281,13 +284,34 @@ Ext.define 'RallyPokerApp', { '', '', '', - '', + '', + '', '
  • ', - '', + '', '{name} at {when}', '
  • ', - '
    ' + '
    ' + '', + '', + '', + '', + '
  • ', + '{[this.revealCard(values.vote, values.user)]}', + ' by {name} at {when}', + '
  • ', + '
    ' + '', + '', + '
  • ', + '', + '{name} at {when}', + '
  • ', + '
    ' + '
    ' '', + 'Reveal', + 'Reload', + '
    ', '', '
    ', '
    ', @@ -308,6 +332,9 @@ Ext.define 'RallyPokerApp', { '
    ', '', { + isTeamMember: _this.Account.isTeamMember + showEstimates: false + revealCard: _this.PokerDeck.revealCard myVote: false shownMessages: false shownDiscussion: false @@ -315,7 +342,6 @@ Ext.define 'RallyPokerApp', { } ) itemSelector: 'div.discussionitem' - accountRef: "/user/" + Rally.environment.getContext().getUser().ObjectID prepareData: (data, index, record) -> if data.Message `var timestamp = data.CreationDate.getTime()` @@ -330,7 +356,7 @@ Ext.define 'RallyPokerApp', { `var whenVoted = [], voteMap = {}` data.whoVoted = [] for k, V of @tpl.whoVoted - if k is @accountRef then @tpl.myVote = V + if k is _this.Account.ref then @tpl.myVote = V if @tpl.whoVoted.hasOwnProperty k whenVoted.push V.when voteMap[V.when] = V @@ -343,8 +369,7 @@ Ext.define 'RallyPokerApp', { data.whoVoted.push voteMap[k] # console.log whenVoted # console.log @tpl.whenVoted - # console.log 'prepareData. accountVoted = ' + @tpl.accountVoted - data + return data listeners: scope: @ refresh: (view) -> @@ -355,31 +380,23 @@ Ext.define 'RallyPokerApp', { renderTo: Ext.query('.estimateselector')[0] StoryEstimator.update view.tpl.myVote else - div = Ext.query('.messagethread')[0] - # Ext.create 'Ext.Component', - # html: 'Reload' - # renderTo: div - # listeners: - # click: - # element: 'el' - # scope: @ - # fn: @_onReload - Ext.create 'Ext.Component', - html: 'Reveal' - renderTo: div - listeners: - click: - element: 'el' - scope: @ - fn: (e, t) -> #@_onReveal - for C in Ext.get(t).prev('.messageitems').query('li .card') - Ext.get(C).setHTML @PokerDeck.revealCard(C.getAttribute('data-vote'), C.getAttribute('data-userid')) + ' by ' + Ext.get(view.el.query('.messagethread-reveal')).on('click', view._onReveal, @) + Ext.get(view.el.query('.messagethread-reload')).on('click', view._onReload, @) # reset template variables for subsequent displays view.tpl.myVote = false view.tpl.shownMessages = false view.tpl.shownDiscussion = false view.tpl.whoVoted = {} return + _onReveal: (e, t) -> + # for C in Ext.get(t).prev('.messageitems').query('li .pokercard') + # Ext.get(C).setHTML @PokerDeck.revealCard(C.getAttribute('data-vote'), C.getAttribute('data-userid')) + ' by ' + @DiscussionThread.tpl.showEstimates = true + @DiscussionsStore.reload() + return + _onReload: (e, t) -> + @DiscussionsStore.reload() + return } @down('#storyview').add @DiscussionThread diff --git a/App.js b/App.js index 4af63a2..3ac7047 100644 --- a/App.js +++ b/App.js @@ -292,6 +292,9 @@ Ext.define('RallyPokerApp', { this.down('#storypicker').add(this.StoryList); Ext.getCmp('storyback').on('click', function() { _this.getLayout().setActiveItem('storypicker'); + _this.StoryPage.update({}); + _this.DiscussionThread.update({}); + _this.DiscussionThread.tpl.showEstimates = false; }); this.CurrentStory = Ext.create('Rally.data.WsapiDataStore', { model: 'userstory', @@ -342,14 +345,16 @@ Ext.define('RallyPokerApp', { }); this.DiscussionThread = Ext.create('Ext.view.View', { store: this.DiscussionsStore, - tpl: new Ext.XTemplate('', '', '{% this.shownMessages = true %}', '
    ', '

    Who\'s Voted

    ', '
      ', '', '', '', '', '
    • ', '', '{name} at {when}', '
    • ', '
      ', '
    ', '
    ', '
    ', '
    ', '
    ', '', '', '{% this.shownDiscussion = true %}', '
    ', '

    Discussion

    ', '', '
    ', '{User._refObjectName}: {CreationDate}', '

    {Text}

    ', '
    ', '', '', '
    ', '
    ', '
    ', { + tpl: new Ext.XTemplate('', '', '{% this.shownMessages = true %}', '
    ', '

    Who\'s Voted

    ', '
      ', '', '', '', '', '', '
    • ', '', '{name} at {when}', '
    • ', '
      ', '
    ', '', '', '', '
  • ', '{[this.revealCard(values.vote, values.user)]}', ' by {name} at {when}', '
  • ', '
    ', '', '', '
  • ', '', '{name} at {when}', '
  • ', '
    ', '
    ', '', 'Reveal', 'Reload', '
    ', '
    ', '
    ', '
    ', '
    ', '', '', '{% this.shownDiscussion = true %}', '
    ', '

    Discussion

    ', '', '
    ', '{User._refObjectName}: {CreationDate}', '

    {Text}

    ', '
    ', '', '', '
    ', '
    ', '
    ', { + isTeamMember: _this.Account.isTeamMember, + showEstimates: false, + revealCard: _this.PokerDeck.revealCard, myVote: false, shownMessages: false, shownDiscussion: false, whoVoted: {} }), itemSelector: 'div.discussionitem', - accountRef: "/user/" + Rally.environment.getContext().getUser().ObjectID, prepareData: function(data, index, record) { var A, D, V, k, _i, _len, _ref; @@ -371,7 +376,7 @@ Ext.define('RallyPokerApp', { _ref = this.tpl.whoVoted; for (k in _ref) { V = _ref[k]; - if (k === this.accountRef) { + if (k === _this.Account.ref) { this.tpl.myVote = V; } if (this.tpl.whoVoted.hasOwnProperty(k)) { @@ -394,7 +399,7 @@ Ext.define('RallyPokerApp', { listeners: { scope: this, refresh: function(view) { - var StoryEstimator, div; + var StoryEstimator; if (this.Account.isTeamMember) { StoryEstimator = Ext.create('EstimateSelector', { @@ -403,34 +408,21 @@ Ext.define('RallyPokerApp', { }); StoryEstimator.update(view.tpl.myVote); } else { - div = Ext.query('.messagethread')[0]; - Ext.create('Ext.Component', { - html: 'Reveal', - renderTo: div, - listeners: { - click: { - element: 'el', - scope: this, - fn: function(e, t) { - var C, _i, _len, _ref, _results; - - _ref = Ext.get(t).prev('.messageitems').query('li .card'); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - C = _ref[_i]; - _results.push(Ext.get(C).setHTML(this.PokerDeck.revealCard(C.getAttribute('data-vote'), C.getAttribute('data-userid')) + ' by ')); - } - return _results; - } - } - } - }); + Ext.get(view.el.query('.messagethread-reveal')).on('click', view._onReveal, this); + Ext.get(view.el.query('.messagethread-reload')).on('click', view._onReload, this); } view.tpl.myVote = false; view.tpl.shownMessages = false; view.tpl.shownDiscussion = false; view.tpl.whoVoted = {}; } + }, + _onReveal: function(e, t) { + this.DiscussionThread.tpl.showEstimates = true; + this.DiscussionsStore.reload(); + }, + _onReload: function(e, t) { + this.DiscussionsStore.reload(); } }); this.down('#storyview').add(this.DiscussionThread);