Skip to content

Commit

Permalink
Enable count badge for Force Pull button similar to Pull Times button.
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson committed Feb 19, 2018
1 parent 1eb1bf6 commit cfa2abd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
21 changes: 12 additions & 9 deletions app/assets/javascripts/group_live_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,23 @@
channel.bind('update', function (data) {
// New value pushed from the server
// Display updated number of new live times on Pull Times button
var new_count = (typeof data.count === 'number') ? data.count : 0;
liveEntry.pusher.displayNewCount(new_count);
var unconsideredCount = (typeof data.unconsidered === 'number') ? data.unconsidered : 0;
var unmatchedCount = (typeof data.unmatched === 'number') ? data.unmatched : 0;
liveEntry.pusher.displayNewCount(unconsideredCount, unmatchedCount);
});
},

displayNewCount: function(count) {
var text = '';
if (count > 0) {
displayNewCount: function(unconsideredCount, unmatchedCount) {
var unconsideredText = (unconsideredCount > 0) ? unconsideredCount : '';
var unmatchedText = (unmatchedCount > 0) ? unmatchedCount : '';
$('#js-pull-times-count').text(unconsideredText);
$('#js-force-pull-times-count').text(unmatchedText);

if (unconsideredCount > 0) {
$('#js-group-new-times-alert').fadeTo(500, 1);
text = count;
} else {
} else if($('#js-group-new-times-alert').is(":visible")) {
$('#js-group-new-times-alert').fadeTo(500, 0, function() {$('#js-group-new-times-alert').hide()});
}
$('#js-pull-times-count').text(text);
}
},

Expand Down Expand Up @@ -1018,7 +1021,7 @@
return;
}
liveEntry.importAsyncBusy = true;
var forceParam = (this.id === 'js-import-live-times') ? '?forcePull=true' : '';
var forceParam = (this.id === 'js-force-import-live-times') ? '?forcePull=true' : '';
$.ajax('/api/v1/event_groups/' + liveEntry.currentEventGroupId + '/pull_live_time_rows' + forceParam, {
error: function(obj, error) {
liveEntry.importAsyncBusy = false;
Expand Down
3 changes: 2 additions & 1 deletion app/models/concerns/background_notifiable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def report_interactor_response(response)

def report_live_times_available(resource)
channel = "live-times-available.#{resource.class.to_s.underscore}.#{resource.id}"
message = {count: resource.live_times.unconsidered.size}
message = {unconsidered: resource.live_times.unconsidered.size,
unmatched: resource.live_times.unmatched.size}
Pusher.trigger(channel, 'update', message)
end

Expand Down

0 comments on commit cfa2abd

Please sign in to comment.