From 97e7a685449c3f913a611c8f5dad9022e5532cb6 Mon Sep 17 00:00:00 2001 From: Emmanuel Darnis Date: Mon, 12 Mar 2018 15:13:07 +0000 Subject: [PATCH] [IMPAC-737] Widget Repeat customers --- .../sales-repeat-customers.directive.coffee | 59 +++++++++++++++++++ .../sales-repeat-customers.less | 18 ++++++ .../sales-repeat-customers.tmpl.html | 57 ++++++++++++++++++ src/impac-angular.module.js | 3 +- 4 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 src/components/widgets/sales-repeat-customers/sales-repeat-customers.directive.coffee create mode 100644 src/components/widgets/sales-repeat-customers/sales-repeat-customers.less create mode 100644 src/components/widgets/sales-repeat-customers/sales-repeat-customers.tmpl.html diff --git a/src/components/widgets/sales-repeat-customers/sales-repeat-customers.directive.coffee b/src/components/widgets/sales-repeat-customers/sales-repeat-customers.directive.coffee new file mode 100644 index 00000000..6734681c --- /dev/null +++ b/src/components/widgets/sales-repeat-customers/sales-repeat-customers.directive.coffee @@ -0,0 +1,59 @@ +module = angular.module('impac.components.widgets.sales-repeat-customers', []) +module.controller('WidgetSalesRepeatCustomersCtrl', ($scope, $q, $filter, ChartFormatterSvc) -> + + w = $scope.widget + + # Define settings + # -------------------------------------- + $scope.orgDeferred = $q.defer() + $scope.chartDeferred = $q.defer() + $scope.histModeDeferred = $q.defer() + settingsPromises = [ + $scope.orgDeferred.promise + $scope.chartDeferred.promise + $scope.histModeDeferred.promise + ] + + # Widget specific methods + # -------------------------------------- + w.initContext = -> + $scope.isDataFound = w.content? + + $scope.getColorByIndex = (index) -> + ChartFormatterSvc.getColor(index) + + # Chart formating function + # -------------------------------------- + $scope.drawTrigger = $q.defer() + w.format = -> + if $scope.isDataFound + dates = _.map w.content.small_chart.dates, (date) -> + $filter('date')(date, 'MMM yy') + + lineOptions = { + scaleBeginAtZero: true, + showXLabels: false, + currency: 'hide' + } + + lineData = [ + {title: 'Merchant', labels: dates, values: w.content.small_chart.merchant_values}, + {title: 'Competitive Set', labels: dates, values: w.content.small_chart.competitive_values}, + {title: 'Industry', labels: dates, values: w.content.small_chart.industry_values} + ] + + # init chartData after transletion chages + chartData = ChartFormatterSvc.lineChart(lineData,lineOptions) + + # calls chart.draw() + $scope.drawTrigger.notify(chartData) + + + $scope.widgetDeferred.resolve(settingsPromises) +) +module.directive('widgetSalesRepeatCustomers', -> + return { + restrict: 'A', + controller: 'WidgetSalesRepeatCustomersCtrl' + } +) \ No newline at end of file diff --git a/src/components/widgets/sales-repeat-customers/sales-repeat-customers.less b/src/components/widgets/sales-repeat-customers/sales-repeat-customers.less new file mode 100644 index 00000000..d07b77ea --- /dev/null +++ b/src/components/widgets/sales-repeat-customers/sales-repeat-customers.less @@ -0,0 +1,18 @@ +.analytics .widget-item .content.sales-repeat-customers { + h6 { + text-align: center; + font-size: 11px; + margin-top: 2px; + } + + td { + text-align: center; + padding-left: 3px; + padding-right: 3px; + padding-top: 3px; + } + + ::-webkit-scrollbar { + width: 0px; + } +} diff --git a/src/components/widgets/sales-repeat-customers/sales-repeat-customers.tmpl.html b/src/components/widgets/sales-repeat-customers/sales-repeat-customers.tmpl.html new file mode 100644 index 00000000..aa7b2998 --- /dev/null +++ b/src/components/widgets/sales-repeat-customers/sales-repeat-customers.tmpl.html @@ -0,0 +1,57 @@ +
+ +
+

Widget settings

+ +
+ + +
+ + +
+
+ + +
+ +
+
Percentage of customers at the store with more than one transaction
+ +
+ +
+ + + + + + + + + + + + + +
+ Within +
1 month + 2 months
{{figure.value[0]}}%{{figure.label}}{{figure.value[1]}}%
+
+ +
+
+
+ Merchant - + Competitive Set - + Industry +
+
Within 1 month
+
+
+ + +
+
+
\ No newline at end of file diff --git a/src/impac-angular.module.js b/src/impac-angular.module.js index 6347dbe6..fb86ed6c 100644 --- a/src/impac-angular.module.js +++ b/src/impac-angular.module.js @@ -92,7 +92,8 @@ angular.module('impac.components.widgets', 'impac.components.widgets.sales-summary', 'impac.components.widgets.sales-top-opportunities', 'impac.components.widgets.sales-top-customers', - 'impac.components.widgets.sales-new-vs-existing-customers' + 'impac.components.widgets.sales-new-vs-existing-customers', + 'impac.components.widgets.sales-repeat-customers' ] ); angular.module('impac.components.widgets-settings',