diff --git a/app/controllers/forms.server.controller.js b/app/controllers/forms.server.controller.js index 79459f8c..fdc472b9 100644 --- a/app/controllers/forms.server.controller.js +++ b/app/controllers/forms.server.controller.js @@ -200,13 +200,21 @@ exports.getVisitorData = function(req, res) { responses: "$responses", visits: "$visits", average_time: { - $divide : ["$total_time", "$responses"] + $cond: [ + { $eq: [ "$responses", 0 ] }, + 0, + { $divide: ["$total_time", "$responses"] } + ] }, conversion_rate: { $multiply: [ 100, { - $divide : ["$responses", "$visits"] + $cond: [ + { $eq: [ "$visits", 0 ] }, + 0, + { $divide: ["$responses", "$visits"] } + ] } ] } @@ -256,13 +264,21 @@ exports.getVisitorData = function(req, res) { responses: "$responses", visits: "$visits", average_time: { - $divide : ["$total_time", "$responses"] + $cond: [ + { $eq: [ "$responses", 0 ] }, + 0, + { $divide: ["$total_time", "$responses"] } + ] }, conversion_rate: { $multiply: [ 100, { - $divide : ["$responses", "$visits"] + $cond: [ + { $eq: [ "$visits", 0 ] }, + 0, + { $divide: ["$responses", "$visits"] } + ] } ] } diff --git a/public/modules/forms/admin/directives/edit-submissions-form.client.directive.js b/public/modules/forms/admin/directives/edit-submissions-form.client.directive.js index 63984893..b5c111b2 100644 --- a/public/modules/forms/admin/directives/edit-submissions-form.client.directive.js +++ b/public/modules/forms/admin/directives/edit-submissions-form.client.directive.js @@ -24,9 +24,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope', //Waits until deletionInProgress is false before running getSubmissions $scope.$watch("deletionInProgress",function(newVal, oldVal){ - if(newVal === oldVal) return; - - if(newVal === false && $scope.waitingForDeletion) { + if(newVal !== oldVal && newVal === false && $scope.waitingForDeletion) { $scope.getSubmissions(); $scope.waitingForDeletion = false; } diff --git a/public/modules/forms/config/forms.client.config.js b/public/modules/forms/config/forms.client.config.js index 52b790fa..51135d95 100644 --- a/public/modules/forms/config/forms.client.config.js +++ b/public/modules/forms/config/forms.client.config.js @@ -55,38 +55,4 @@ angular.module('forms').run(['Menus', directive.replace = true; return $delegate; }); -}]).config(['$provide', function ($provide){ - $provide.decorator('taOptions', ['$delegate', 'taRegisterTool', '$translate', '$window', 'taSelection', function(taOptions, taRegisterTool, $translate, $window, taSelection) { - taRegisterTool('insertField', { - display: '
\ -
\ - {{ "ADD_VARIABLE_BUTTON" | translate }}\ - \ -
\ - \ -
', - class: 'btn-group', - onClickField: function(field_id, field_name){ - if (taSelection.getSelectionElement().tagName && (taSelection.getSelectionElement().tagName.toLowerCase() === 'var' || taSelection.getSelectionElement().tagName.toLowerCase() === 'a')) { - // due to differences in implementation between FireFox and Chrome, we must move the - // insertion point past the element, otherwise FireFox inserts inside the - // With this change, both FireFox and Chrome behave the same way! - taSelection.setSelectionAfterElement(taSelection.getSelectionElement()); - } - this.$editor().wrapSelection('insertHTML', ' ' + field_name + ' ', true); - }, - action: function(){ - } - }); - - taOptions.defaultTagAttributes['var'] = { - 'contenteditable': 'false' - }; - - return taOptions; - }]); }]); \ No newline at end of file