Skip to content

Commit

Permalink
Merge pull request #50 from TheDMSGroup/ENG-372
Browse files Browse the repository at this point in the history
[ENG-372] - fix js error on revenue datatables that causes downstream js errors
  • Loading branch information
heathdutton authored Jul 9, 2018
2 parents 2f7b699 + f11610d commit 15a5d47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
9 changes: 2 additions & 7 deletions Assets/js/global-revenue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Mautic.loadGlobalRevenueWidget = function (globalWidgetHeight) {
Mautic.loadGlobalRevenueWidget = function () {
var $globaltarget = mQuery('#global-revenue');
if ($globaltarget.length) {
mQuery('#global-revenue:not(.table-initialized):first').addClass('table-initialized').each(function () {
Expand All @@ -15,7 +15,7 @@ Mautic.loadGlobalRevenueWidget = function (globalWidgetHeight) {
cache: true,
dataType: 'json',
success: function (response) {
var rowCount = Math.floor((globalWidgetHeight - 220) / 40);
var rowCount = Math.floor(($globaltarget.data('height') - 220) / 40);
mQuery('#global-revenue').DataTable({
language: {
emptyTable: 'No results found for this date range and filters.'
Expand Down Expand Up @@ -193,8 +193,3 @@ Mautic.loadGlobalRevenueWidget = function (globalWidgetHeight) {
}
callback();
};


mQuery(document).ready(function () {
Mautic.loadGlobalRevenueWidget(globalWidgetHeight);
});
8 changes: 2 additions & 6 deletions Assets/js/source-revenue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Mautic.loadSourceRevenueWidget = function (detailWidgetHeight) {
Mautic.loadSourceRevenueWidget = function () {
var $sourcetarget = mQuery('#source-revenue');
if($sourcetarget.length) {
mQuery('#source-revenue:first:not(.table-initialized)').addClass('table-initialized').each(function () {
Expand All @@ -15,7 +15,7 @@ Mautic.loadSourceRevenueWidget = function (detailWidgetHeight) {
cache: true,
dataType: 'json',
success: function (response) {
var rowCount = Math.floor((detailWidgetHeight - 220) / 40);
var rowCount = Math.floor(($sourcetarget.data('height') - 220) / 40);
mQuery('#source-revenue').DataTable({
language: {
emptyTable: "No results found for this date range and filters."
Expand Down Expand Up @@ -204,8 +204,4 @@ mQuery.getCssOnce = function (url, callback) {
callback();
};

mQuery(document).ready(function () {
Mautic.loadSourceRevenueWidget(detailWidgetHeight);
});


11 changes: 4 additions & 7 deletions Views/Widgets/revenue.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
*/

?>
<script src="/plugins/MauticContactLedgerBundle/Assets/js/global-revenue.js"></script>

<?php
echo $view['assets']->includeScript('plugins/MauticContactLedgerBundle/Assets/js/global-revenue.js', 'loadGlobalRevenueWidget');

$params = $data['params'];
?>

Expand All @@ -22,14 +23,10 @@
<!-- Revenue By Campaign -->
<div class="responsive-table">
<div id="global-builder-overlay"><div style="position: relative; top: <?php echo $data['height'] / 3; ?>px; left: 45%; index: 1024;display:inline-block; opacity: .5"><i class="fa fa-spinner fa-spin fa-4x"></i></div></div>
<table id="global-revenue" class="table table-striped table-bordered" width="100%">
<table id="global-revenue" class="table table-striped table-bordered" width="100%" data-height="<?php echo $data['height']; ?>">
</table>
</div>
<!--/ Revenue By Campaign -->
</div>
</div>
</div>
<script>
var globalWidgetHeight = <?php echo $data['height']; ?>;
Mautic.loadGlobalRevenueWidget(globalWidgetHeight);
</script>
</div>
16 changes: 8 additions & 8 deletions Views/Widgets/sourceRevenue.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
?>
<script src="/plugins/MauticContactLedgerBundle/Assets/js/source-revenue.js"></script>
<?php
echo $view['assets']->includeScript('plugins/MauticContactLedgerBundle/Assets/js/source-revenue.js', 'loadSourceRevenueWidget');
$params = $data['params'];
?>

Expand All @@ -20,17 +20,17 @@
<div id="campaign-source-revenue-table" style="height:<?php echo $data['height']; ?>px">
<!-- Revenue By Campaign + Source -->
<div class="responsive-table">
<div id="source-builder-overlay"><div style="position: relative; top: <?php echo $data['height'] / 3; ?>px; left: 45%; index: 1024;display:inline-block; opacity: .5;"><i class="fa fa-spinner fa-spin fa-4x"></i></div></div>
<table id="source-revenue" class="table table-striped table-bordered" width="100%">
<div id="source-builder-overlay">
<div style="position: relative; top: <?php echo $data['height'] / 3; ?>px; left: 45%; index: 1024;display:inline-block; opacity: .5;">
<i class="fa fa-spinner fa-spin fa-4x"></i>
</div>
</div>
<table id="source-revenue" class="table table-striped table-bordered" width="100%" data-height="<?php echo $data['height']; ?>">
</table>
</div>
<!--/ Revenue By Campaign + Source -->
</div>
</div>
</div>
<script>
var detailWidgetHeight = <?php echo $data['height']; ?>;
mQuery('#source-builder-overlay').show();
Mautic.loadSourceRevenueWidget(detailWidgetHeight);
</script>


0 comments on commit 15a5d47

Please sign in to comment.