* VRFS-622 - added search filter
This commit is contained in:
parent
562b93ff4b
commit
79f458d6d5
|
|
@ -2,21 +2,28 @@ require 'rest_client'
|
|||
|
||||
class GoogleAnalyticsTracker
|
||||
|
||||
attr_accessor :enabled
|
||||
attr_accessor :tracking_code
|
||||
attr_accessor :enabled, :tracking_code, :ga_version, :ga_endpoint
|
||||
|
||||
def initialize(enabled, tracking_code=nil)
|
||||
def initialize(enabled, tracking_code=nil, ga_version=nil, ga_endpoint="http://www.google-analytics.com/collect")
|
||||
if enabled && tracking_code.nil?
|
||||
raise "misconfigured application; a tracking code must be specified if tracking is enabled"
|
||||
end
|
||||
|
||||
if enabled && ga_version.nil?
|
||||
raise "misconfigured application; a google analytics version must be specified if tracking is enabled"
|
||||
end
|
||||
|
||||
@tracking_code = tracking_code
|
||||
@ga_version = ga_version
|
||||
@ga_endpoint = "http://www.google-analytics.com/collect"
|
||||
end
|
||||
|
||||
def event(category, action, client_id = nil)
|
||||
return unless enabled
|
||||
|
||||
params = {
|
||||
v: GOOGLE_ANALYTICS_SETTINGS[:version],
|
||||
tid: GOOGLE_ANALYTICS_SETTINGS[:tracking_code],
|
||||
v: @ga_version,
|
||||
tid: @tracking_code,
|
||||
cid: client_id
|
||||
t: "event",
|
||||
ec: category,
|
||||
|
|
@ -24,7 +31,7 @@ class GoogleAnalyticsTracker
|
|||
}
|
||||
|
||||
begin
|
||||
RestClient.get(GOOGLE_ANALYTICS_SETTINGS[:endpoint], params: params, timeout: 4, open_timeout: 4)
|
||||
RestClient.get(@"http://www.google-analytics.com/collect", params: params, timeout: 4, open_timeout: 4)
|
||||
return true
|
||||
rescue RestClient::Exception => rex
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
context.JK.InvitationDialog = function(app) {
|
||||
var logger = context.JK.logger;
|
||||
var rest = context.JK.Rest();
|
||||
var waitForUserToStopTypingTimer;
|
||||
|
||||
function trackMetrics(emails, googleInviteCount) {
|
||||
var allInvitations = emails.length; // all email invites, regardless of how they got in the form
|
||||
|
|
@ -15,14 +16,56 @@
|
|||
}
|
||||
}
|
||||
|
||||
function filterInvitations() {
|
||||
waitForUserToStopTypingTimer = null;
|
||||
|
||||
var filter = $('#invitation-dialog input[name=email-filter]').val();
|
||||
|
||||
var showAll = true;
|
||||
if(filter.length > 1) {
|
||||
showAll = false;
|
||||
}
|
||||
|
||||
$('#invitation-checkboxes').children().each(function (index, node) {
|
||||
|
||||
var input = $(node).find('input');
|
||||
|
||||
if(showAll) {
|
||||
$(node).show()
|
||||
}
|
||||
else {
|
||||
var email = input.attr('data-email');
|
||||
|
||||
if(email.toLowerCase().indexOf(filter.toLowerCase()) > -1) {
|
||||
$(node).show()
|
||||
}
|
||||
else {
|
||||
if(!input.is(':checked')) {
|
||||
$(node).hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function onFilterChange() {
|
||||
if(waitForUserToStopTypingTimer) {
|
||||
clearTimeout(waitForUserToStopTypingTimer);
|
||||
}
|
||||
waitForUserToStopTypingTimer = setTimeout(filterInvitations, 300);
|
||||
}
|
||||
|
||||
function registerEvents(onOff) {
|
||||
if(onOff) {
|
||||
$('#btn-send-invitation').on('click', sendEmail);
|
||||
$('#btn-next-invitation').on('click', clickNext);
|
||||
$('#invitation-dialog input[name=email-filter]').on('input', onFilterChange);
|
||||
}
|
||||
else {
|
||||
$('#btn-send-invitation').off('click', sendEmail);
|
||||
$('#btn-next-invitation').off('click', clickNext);
|
||||
$('#invitation-dialog input[name=email-filter]').off('keyup', onFilterChange);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,7 +77,6 @@
|
|||
rest.createInvitation($.trim(emails[i]), $('#txt-message').val())
|
||||
.done(function() {
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +137,7 @@
|
|||
});
|
||||
},
|
||||
error: function() {
|
||||
$('#invitation-checkboxes').html("Load failed");
|
||||
$('#invitation-checkboxes').html("Load failed!");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -152,6 +194,8 @@
|
|||
|
||||
function beforeShow() {
|
||||
registerEvents(true);
|
||||
|
||||
$('#invitation-dialog input[name=email-filter]').val('');
|
||||
}
|
||||
|
||||
function afterHide() {
|
||||
|
|
@ -163,6 +207,7 @@
|
|||
'beforeShow' : beforeShow,
|
||||
'afterHide': afterHide
|
||||
};
|
||||
|
||||
app.bindDialog('inviteUsers', dialogBindings);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@
|
|||
<div class="invitation-inner" id="invitation-checkbox-container">
|
||||
<div style="margin-left:10px; margin-top:10px;">
|
||||
<label>Click the checkbox next to the email of each person you'd like to invite.</label><br />
|
||||
<label class="email-filter" for="email-filter">Filter Results: <input text="text" name="email-filter" /></label><br />
|
||||
<div id="invitation-checkboxes">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue