Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/StudentHealthTracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Report JSON data is then retrieved from dev instance using the `GET /rest/Report

| Module | Extension | Name | Description |
| :--- | :--- | :---- | :---- |
|Contacts|Vardefs|`vital_c`|Dropdown for tracking vital status of student.|
|Contacts|Vardefs|`vital_c`|Dropdown for tracking vital status of student. Audit field for tracking datestamps|
|Contacts|Vardefs|`cause_of_death_c`|Text field that allows Prof. M to enter cause of death.|
|Contacts|Vardefs|`flowers_sent_c`|Checkbox field that allows Prof M. to track if flowers were ordered.|
|Contacts|Dependencies|`cause_of_death_required`|Makes `cause_of_death_c` a required field when `vital_c` is set to `deceased`.|
Expand Down
2 changes: 1 addition & 1 deletion package/pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
'default_value' => 'active',
'date_modified' => '2018-02-01 21:32:16',
'deleted' => '0',
'audited' => '0',
'audited' => '1',
'mass_update' => '1',
'duplicate_merge' => '1',
'reportable' => '1',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

$app_strings['LBL_STUDENT_VITAL_CHART_DESC'] = 'Pie Chart grouping combined days in vitals status';
$app_strings['LBL_STUDENT_VITAL_CHART'] = 'Student Vitals Chart';
$app_strings['LBL_VITALS_DASHLET_SELECT_TEAM'] = 'Select Super Group to view data on';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="student-bital-chart">
<div class="sc-chart" data-content="chart">
<svg id="{{cid}}"></svg>
</div>
<div class="block-footer hide" data-content="nodata">{{str "LBL_NO_DATA_AVAILABLE"}}</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Your installation or use of this SugarCRM file is subject to the applicable
* terms available at
* http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
* If you do not agree to all of the applicable terms or do not have the
* authority to bind the entity as an authorized representative, then do not
* install or use this SugarCRM file.
*
* Copyright (C) SugarCRM Inc. All rights reserved.
*/
({
plugins: ['Dashlet', 'Chart'],
className: 'student-vital-chart',
chartCollection: null,
hasData: false,
total: 0,

/**
* @inheritdoc
*/
initialize: function(options) {
this._super('initialize', [options]);

this.listenTo(this, 'render', function () {
this.retrieveSuperGroupOptions();
} );
this.chart = sucrose.charts.pieChart()
.donut(true)
.donutLabelsOutside(true)
.donutRatio(0.25)
.hole(false)
.showTitle(true)
.tooltips(true)
.showLegend(true)
.colorData('class')
.tooltipContent(_.bind(function(eo, properties) {

var value = parseInt(this.chart.getValue()(eo), 10);
var total = parseInt(properties.total, 10);
(total == 0) ? total = 1 : '';
var percentage = value/total * 100;
return '<h3>' + this.chart.fmtKey()(eo) + '</h3>' +
'<p>' + value + ' days</p>' +
'<p>' + percentage.toFixed(2) + '%</p>';
}, this))
.strings({
noData: app.lang.get('LBL_CHART_NO_DATA')
});
},


/**
* Generic method to render chart with check for visibility and data.
* Called by _renderHtml and loadData.
*/
renderChart: function() {
var self = this;
if (!self.isChartReady()) {

return;
}


d3sugar.select(this.el).select('svg#' + this.cid)
.datum(self.chartCollection)
.call(self.chart);

this.chart_loaded = _.isFunction(this.chart.update);
this.displayNoData(!this.chart_loaded);

},

/**
* @inheritdoc
*/
loadData: function(options) {

if(this.meta.config) {

return;
}
var self = this;
var team_value = this.meta.vitals_dashlet_team ? this.meta.vitals_dashlet_team : 'all';
url = app.api.buildURL('contacts/professorM/getStudentVitalData/' + team_value);
this.hasData = false;
app.api.call('GET', url, null, {
success: function(data) {
self.hasData = true;
self.evaluateResponse(data);
self.render();
},
complete: options ? options.complete : null
});

},

evaluateResponse: function(data) {

this.total = 1;
this.hasData = true;
this.chartCollection = $.parseJSON(data);

},

retrieveSuperGroupOptions: function() {
if (!this.meta.config) {
return;
}
console.log(this.meta.vitals_dashlet_team);
var team_value = this.meta.vitals_dashlet_team ? this.meta.vitals_dashlet_team : 'all';
var accounts = app.data.createBeanCollection('Accounts');
var teams = [];
teams.push({id: 'all', text:'All'})
accounts.fetch({
success: function() {
accounts.comparator = 'name';
accounts.sort({silent: true});
_.each(accounts.models, function(account){
teams.push({id: account.id, text: account.attributes.name});
});

$('[name="vitals_dashlet_team"]').html('').select2({data: teams});
$('[name="vitals_dashlet_team"]').val(team_value).trigger('change');
}
})
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

$viewdefs['base']['view']['student-vital-chart'] = array(
'dashlets' => array(
array(
'label' => 'LBL_STUDENT_VITAL_CHART',
'description' => 'LBL_STUDENT_VITAL_CHART_DESC',
'config' => array(
'date_range' => 'all',
'team' => 'all',
),
'preview' => array(
),
'filter' => array(
'view' => array(
'records',
'record'
)
),

),

),
'panels' => array(
array(
'name' => 'panel_body',
'columns' => 2,
'labelsOnTop' => true,
'placeholders' => true,
'fields' => array(

array(
'name' => 'vitals_dashlet_team',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default width of this enum field is too narrow. It should probably be resized after fetching list of options. Also, lets avoid "team" term and use something like supergroup instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the corresponding js controller so column width is preserved when populating data dynamically

'label' => 'LBL_VITALS_DASHLET_SELECT_TEAM',
'type' => 'enum',
'options' => array('all' => 'All'),
),
array(
'name' => 'vitals_dashlet_date_range',
'label' => 'LBL_VITALS_DASHLET_SELECT_DATE_RANGE',
'type' => 'enum',
'options' => array('all' => 'All Time', 'ThisYear' => 'This Year', 'LastYear' => 'Last Year'),
),
),
),
),
);
Loading