1 <md-dialog class="reportField-dialog" aria-label="New Report Field">
2 <form name="reportFieldForm" class="md-inline-form" novalidate>
3 <md-toolbar class="md-accent md-hue-2">
5 class="md-toolbar-tools"
7 layout-align="space-between center"
9 <span class="title">{{vm.title}}</span>
10 <md-button class="md-icon-button" ng-click="vm.closeDialog()">
12 md-font-icon="icon-close"
13 aria-label="Close dialog"
20 <md-dialog-content ms-scroll>
21 <div class="error-list">
23 ng-repeat="error in vm.errors"
26 layout-align="space-between center"
29 <span class="message">{{error.message}}</span>
30 <span class="type">({{error.type}})</span>
32 <md-button class="md-icon-button">
34 md-font-icon="icon-alert-box"
35 aria-label="alert error"
41 <md-input-container class="md-block">
42 <label translate="ANALYTICS.TYPE">Type</label>
45 ng-model="vm.reportField.type"
46 ng-change="vm.reportField.field = undefined"
49 <md-option value="column">Select a column</md-option>
50 <md-option value="metric">Select an existing metric</md-option>
51 <md-option value="custom">Write a custom metric</md-option>
54 ng-messages="reportForm.type.$error"
55 ng-show="reportForm.type.$touched"
58 <div ng-message="required">
59 <span translate="ANALYTICS.ERRORS.TYPE_REQUIRED"
60 >Type field is required</span
65 <div ng-switch on="vm.reportField.type">
66 <md-input-container class="md-block" ng-switch-when="column">
67 <label translate="ANALYTICS.COLUMN">Column Name</label>
68 <md-select name="column" ng-model="vm.reportField.field" required>
69 <md-optgroup label="{{vm.report.table}}">
71 ng-repeat="column in vm.columns"
72 value="{{vm.report.table}}.{{column}}"
73 >{{column}}</md-option
75 <!-- <md-option ng-repeat="column in vm.columns" ng-value="">{{column}}</md-option> -->
78 ng-if="vm.report.joins"
79 ng-repeat="join in vm.report.joins"
80 label="{{join.foreignTable}}"
83 ng-repeat="field in join.foreignTableFields"
84 value="{{join.foreignTable}}.{{field}}"
90 ng-messages="reportForm.column.$error"
91 ng-show="reportForm.column.$touched"
94 <div ng-message="required">
95 <span translate="ANALYTICS.ERRORS.COLUMN_REQUIRED"
96 >Column field is required</span
100 </md-input-container>
101 <md-input-container class="md-block" ng-switch-when="metric">
102 <label translate="ANALYTICS.METRIC_NAME">Metric Name</label>
103 <md-select name="metric" ng-model="vm.reportField.MetricId" required>
104 <md-option ng-repeat="metric in vm.metrics" ng-value="metric.id"
105 >{{metric.name}}</md-option
109 ng-messages="reportForm.metric.$error"
110 ng-show="reportForm.metric.$touched"
113 <div ng-message="required">
114 <span translate="ANALYTICS.ERRORS.METRIC_REQUIRED"
115 >Metric field is required</span
119 </md-input-container>
120 <md-input-container class="md-block" ng-switch-when="custom">
121 <label translate="ANALYTICS.CUSTOM_METRIC">Custom Metric</label>
125 ng-model="vm.reportField.field"
130 ng-messages="reportFieldForm.field.$error"
131 ng-show="reportFieldForm.field.$touched"
134 <div ng-message="required">
135 <span translate="ANALYTICS.ERRORS.CUSTOM_METRIC_REQUIRED"
136 >Custom Metric field is required</span
140 </md-input-container>
142 <md-input-container class="md-block">
143 <label translate="ANALYTICS.ALIAS">Alias</label>
147 ng-model="vm.reportField.alias"
148 ng-required="vm.reportField.type === 'custom' || vm.reportField.type === 'metric'"
151 ng-messages="reportFieldForm.alias.$error"
152 ng-show="reportFieldForm.alias.$touched"
155 <div ng-message="required">
156 <span translate="ANALYTICS.ERRORS.ALIAS_REQUIRED"
157 >Alias field is required</span
161 </md-input-container>
164 ng-if="vm.reportField.type !== 'metric'"
166 <label translate="ANALYTICS.FUNCTION">Function</label>
167 <md-select name="function" ng-model="vm.reportField.function">
168 <md-option ng-value="null">No Function</md-option>
170 ng-repeat="function in vm.sqlUtil.getFunctions"
171 ng-value="function.value"
172 >{{function.value}}</md-option
175 </md-input-container>
178 ng-if="vm.reportField.type !== 'metric'"
180 <label translate="ANALYTICS.FORMAT">Format</label>
181 <md-select name="format" ng-model="vm.reportField.format">
182 <md-option ng-value="null">No Format</md-option>
184 ng-repeat="format in vm.sqlUtil.getFormats"
185 ng-value="format.value"
186 >{{format.value}}</md-option
189 </md-input-container>
190 <md-input-container class="md-block">
191 <label translate="ANALYTICS.GROUP_BY">Group By</label>
192 <md-select name="groupBy" ng-model="vm.reportField.groupBy">
193 <md-option ng-repeat="gb in vm.sqlUtil.getGroupBy" ng-value="gb.value"
194 >{{gb.value ? 'Yes' : 'No'}}</md-option
197 </md-input-container>
198 <md-input-container class="md-block">
199 <label translate="ANALYTICS.ORDER_BY">Order By</label>
200 <md-select name="orderBy" ng-model="vm.reportField.orderBy">
201 <md-option ng-value="null">No Order</md-option>
202 <md-option ng-repeat="ob in vm.sqlUtil.getOrderBy" ng-value="ob.value"
203 >{{ob.value}}</md-option
206 </md-input-container>
207 <div class="error-list">
209 ng-repeat="error in vm.errors"
212 layout-align="space-between center"
215 <span class="message">{{error.message}}</span>
216 <span class="type">({{error.type}})</span>
218 <md-button class="md-icon-button">
220 md-font-icon="icon-alert-box"
221 aria-label="alert error"
229 <md-dialog-actions layout="row" layout-align="space-between center">
232 layout-align="start center"
233 ng-if="vm.crudPermissions.canEdit"
237 ng-if="!vm.newReportField"
238 ng-click="vm.saveReportField()"
239 class="send-button md-accent md-raised"
240 ng-disabled="reportFieldForm.$invalid || reportFieldForm.$pristine"
242 translate="ANALYTICS.SAVE"
243 translate-attr-aria-label="ANALYTICS.SAVE"
250 ng-if="vm.newReportField"
251 ng-click="vm.addNewReportField()"
252 class="send-button md-accent md-raised"
253 ng-disabled="reportFieldForm.$invalid || reportFieldForm.$pristine"
255 translate="ANALYTICS.ADD_REPORTFIELD"
256 translate-attr-aria-label="ANALYTICS.ADD_REPORTFIELD"
263 class="md-icon-button"
264 ng-if="vm.crudPermissions.canDelete && !vm.newReportField"
265 ng-click="vm.deleteReportField($event)"
268 translate-attr-aria-label="ANALYTICS.DELETE"
270 <md-icon md-font-icon="icon-delete"></md-icon>
272 ><span translate="ANALYTICS.DELETE">DELETE</span></md-tooltip