-
Notifications
You must be signed in to change notification settings - Fork 31
[IMPAC-698] Add widget average spend per customer #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lmi-insights
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| module = angular.module('impac.components.widgets.sales-average-spend-per-customer', []) | ||
| module.controller('WidgetSalesAverageSpendPerCustomerCtrl', ($scope, $q, $filter, HighchartsFactory) -> | ||
|
|
||
| w = $scope.widget | ||
| $scope.isChartDisplayed = true | ||
|
|
||
| # Define settings | ||
| # -------------------------------------- | ||
| $scope.orgDeferred = $q.defer(); | ||
| settingsPromises = [$scope.orgDeferred.promise] | ||
|
|
||
| # Unique identifier for the chart object in the DOM | ||
| $scope.chartId = -> | ||
| "averageSpendPerCustomerChart-#{w.id}" | ||
|
|
||
| # # == Sub-Components ============================================================= | ||
| $scope.chartDeferred = $q.defer() | ||
|
|
||
| # Widget specific methods | ||
| # -------------------------------------- | ||
| w.initContext = -> | ||
| $scope.isDataFound = w.content? | ||
|
|
||
| w.format = -> | ||
| # Instantiate and render chart | ||
| options = | ||
| chartType: 'line' | ||
| chartOnClickCallbacks: [] | ||
| currency: w.metadata.currency | ||
| showToday: true | ||
| showLegend: true | ||
|
|
||
| $scope.chart = new HighchartsFactory($scope.chartId(), w.content.chart, options) | ||
|
|
||
| $scope.chart.formatters = -> | ||
| currency = @options.currency | ||
| xAxisLabels = | ||
| labels: | ||
| formatter: -> | ||
| moment.utc(this.value).format('MMM YYYY') | ||
| yAxisLabels = | ||
| labels: | ||
| formatter: -> | ||
| $filter('mnoCurrency')(this.value, currency, false) | ||
| xAxis: angular.merge([w.content.chart.xAxis[0]], [xAxisLabels]) | ||
| yAxis: angular.merge([w.content.chart.yAxis[0]], [yAxisLabels]) | ||
| rangeSelector: | ||
| selected: 5 | ||
|
|
||
| $scope.chart.render(w.content.chart, options) | ||
|
|
||
| # Notifies parent element that the chart is ready to be displayed | ||
| $scope.chartDeferred.notify($scope.chart) | ||
|
|
||
| $scope.widgetDeferred.resolve(settingsPromises) | ||
| ) | ||
| module.directive('widgetSalesAverageSpendPerCustomer', -> | ||
| return { | ||
| restrict: 'A', | ||
| controller: 'WidgetSalesAverageSpendPerCustomerCtrl' | ||
| } | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .analytics .widget-item .content.sales-average-spend-per-customer { | ||
| .tall-widget(); | ||
|
|
||
| .average-spend-per-customer-chart { | ||
| height: ~"calc(@{impac-big-widget-size} - 50px)"; | ||
| } | ||
|
|
||
| .highcharts-y-primary { | ||
| fill: 'rgb(68, 208, 218)' | ||
| } | ||
|
|
||
| .highcharts-y-secondary { | ||
| fill: 'rgb(208, 68, 218)' | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <div widget-sales-average-spend-per-customer> | ||
| <!-- Settings Panel --> | ||
| <div ng-show="widget.isEditMode" class="edit"> | ||
| <h4>Widget settings</h4> | ||
|
|
||
| <div setting-organizations parent-widget="widget" class="part" deferred="::orgDeferred" /> | ||
|
|
||
| <!-- Buttons displayed on the lower --> | ||
| <div class="bottom-buttons" align="right"> | ||
| <button class="btn btn-default" ng-click="initSettings()">Cancel</button> | ||
| <button class="btn btn-warning" ng-click="updateSettings()">Save</button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Content Panel --> | ||
| <div ng-hide="widget.isEditMode"> | ||
| <!-- Data found --> | ||
| <div ng-show="(isDataFound==true)" class=""> | ||
| <div id="{{chartId()}}" class="average-spend-per-customer-chart"></div> | ||
| </div> | ||
|
|
||
| <!-- No data found --> | ||
| <div ng-if="(isDataFound==false)" common-data-not-found on-display-alerts="onDisplayAlerts()" endpoint="::widget.category" width="::widget.width" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the old implementation of the data-not-found directive. I know the generator created it, but its out of date. I updated this in the generator in v1.6.9 but the lmi feature branch is behind. The data-not-found is now a modal, so no need to show/hide content on Take a look at cash projection template for example, test with a bolt widget for org with no bolt data. |
||
| </div> | ||
| </div> | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To save some lines, you can assign the result to a variable, and then mutate the object and return that.