/**
* prevent double-submits
*/
function helper_disableSubmitForm(id, form_id)
{
try
{
//console.log(id);
//console.log(form_id);
if (form_id == 'member_update_form' || form_id == 'add_subitem_update_form')
{
ecm_calculateTimeSpent(null);
}
var okay = true;//submitReviewDialog();
if (okay)
{
var button = $('#' + id);
button.attr('disabled',true);
}
$('#' + form_id).submit();
return okay;
}
catch (err)
{
alert(err);
console.log(err);
return false;
}
}
function helper_getSpinner(id)
{
var html = '';
html += '
';
html += '';
html += '';
html += ' ';
html += ' | ';
html += '
';
html += '
';
return html;
}
function helper_showMemberInfoHeader(cin, item_id, element_id, extra)
{
var uri = 'https://dev.oversightcloud.com/app/ui/ecm/member/header/' + cin + '/' + item_id;
if (typeof extra != 'undefined') {
uri = uri + '?' + extra;
}
$('#' + element_id).replaceWith(helper_getSpinner(element_id));
//console.log(uri);
//return;
$.ajax({
url: uri,
cache: false,
success: function(response) {
//console.log(response);
//response = response + response + response;
// var r = $(response);
//console.log(r);
// var contents = r.find(".member_info_table");
//console.log(contents);
$('#' + element_id).replaceWith(response);
if (element_id == 'member_info_table')
{
$('#subitem_name').focus();
}
}
});
}
function helper_getWorkitemCounts()
{
var counts = $.ajax({
url: 'https://dev.oversightcloud.com/app/ui/ecm/workitems/count'
,cache: false
,success: function(response) {
//console.log(response);
if (!response.hasOwnProperty('counts')) { return; }
var counts = response.counts;
var owner = 0;
var blocking = 0;
var cmtasks = 0;
if (counts.hasOwnProperty('blocking')) { blocking = counts.blocking; }
if (counts.hasOwnProperty('cm_tasks')) { cmtasks = counts.cm_tasks; }
if (counts.hasOwnProperty('owner')) {
owner_counts = counts.owner;
if (owner_counts.hasOwnProperty('IN PROGRESS')) {
owner = owner_counts['IN PROGRESS'];
}
}
//testing
//owner = 0;
//blocking = 0;
//cmtasks = 0;
//are there any badges to show?
var has_badges = owner > 0 || blocking > 0 || cmtasks > 0;
if (has_badges)
{
$('.navinator').css('display','inline');
$('.user_name_anchor').css('top','-9px');
$('.simulated_user').css('top','-9px');
$('.user_name_anchor_view').css('top','-8px');
}
if (blocking > 0) {
$('.workitem_count_blocking').html(blocking);
$('.workitem_count_blocking').show();
}
if (cmtasks > 0) {
$('.workitem_count_cmtasks').html(cmtasks);
$('.workitem_count_cmtasks').show();
}
if (owner > 0) {
$('.workitem_count_mywork').html(owner);
if (owner > 20) { $('.workitem_count_mywork').addClass('review_red'); }
else if (owner > 12) { $('.workitem_count_mywork').addClass('review_yellow'); }
else { $('.workitem_count_mywork').addClass('review_green'); }
$('.workitem_count_mywork').show();
}
if (has_badges) {
if (owner > 0 && blocking > 0 && cmtasks > 0) {
$('.workitem_count_spacer1').show();
//$('.workitem_count_spacer2').show();
} else if (owner == 0 && blocking > 0 && cmtasks > 0) {
$('.workitem_count_spacer1').show();
$('.workitem_count_spacer2').show();
} else if (blocking > 0 || cmtasks > 0) {
if (owner < 10) {
$('.workitem_count_spacer1').show();
}
}
}
}
});
}
function helper_openMcoHistoryDialog(control)
{
var cin = control.data('cin');
var parent_id = control.data('parent-id');
helper_showMemberInfoHeader(cin, parent_id, 'member_info_table_mco_history',
'show_tier=true&show_pof=false'
);
var uri = 'https://dev.oversightcloud.com/app/ui/ecm/member/mco_history/' + cin + '/' + parent_id;
var element_id = 'mco_loading';
$('#' + element_id).show();
$('#' + element_id).replaceWith(helper_getSpinner(element_id));
//console.log(uri);
//return;
$.ajax({
url: uri,
cache: false,
success: function(response) {
//console.log(response);
$('#' + element_id).hide();
var mif = $(response).find('#fragment_mco_mif');
var pofs = $(response).find('#fragment_mco_pofs');
var meds = $(response).find('#fragment_mco_medications');
var hi = $(response).find('#fragment_mco_health_indicators');
var bh = $(response).find('#fragment_behaviorial_health');
//console.log(meds);
if (mif.length > 0) {
$('#fragment_mco_mif').replaceWith(mif);
$('#mco_mif_collapsible').show();
} else {
$('#fragment_mco_mif').empty();
$('#mco_mif_collapsible').hide();
}
if (pofs.length > 0) {
$('#fragment_mco_pofs').replaceWith(pofs);
$('#mco_pofs_collapsible').show();
} else {
$('#fragment_mco_pofs').empty();
$('#mco_pofs_collapsible').hide();
}
if (meds.length > 0) {
$('#fragment_mco_medications').replaceWith(meds);
$('#mco_medications_collapsible').show();
} else {
$('#fragment_mco_medications').empty();
$('#mco_medications_collapsible').hide();
}
if (hi.length > 0) {
$('#fragment_mco_health_indicators').replaceWith(hi);
$('#mco_health_indicators_collapsible').show();
} else {
$('#fragment_mco_health_indicators').empty();
$('#mco_health_indicators_collapsible').hide();
}
if (bh.length > 0) {
$('#fragment_behaviorial_health').replaceWith(bh);
$('#mco_behaviorial_health_collapsible').show();
} else {
$('#fragment_behaviorial_health').empty();
$('#mco_behaviorial_health_collapsible').hide();
}
$('#mco_history_data' + ' .moment').each(function(){
var val = $(this).attr('data-timestamp');
var date = new Date(val);
var moment = fromNow(date);
$(this).html('(' + moment + ')');
});
}
});
}