|
42 | 42 | });
|
43 | 43 | }
|
44 | 44 |
|
45 |
| - scope.fieldsForAggregation = function(fields, agg) { |
| 45 | + scope.fieldsForAggregation = function(fields, agg) { |
46 | 46 | if(agg === 'count') {
|
47 | 47 | return [];
|
48 | 48 | } else if(agg === 'sum' || agg === 'avg') {
|
|
77 | 77 | modalInstance.result.then(function(definition) {
|
78 | 78 | var entity = scope.component.options.entity;
|
79 | 79 |
|
80 |
| - if(!entity) { |
| 80 | + //if(!entity) { |
| 81 | + if(!DashboardSrv.hasMinimalConfiguration(scope.component)) { |
81 | 82 | return;
|
82 | 83 | }
|
83 | 84 |
|
84 | 85 | // Set the computed query
|
85 |
| - definition.query = DashboardSrv.buildFiltersQuery(scope.metadata[entity].attributes, scope.component.options.filters); |
| 86 | + definition.query = DashboardSrv.buildFiltersQuery(entity ? scope.metadata[entity].attributes : null, scope.component.options.filters); |
86 | 87 |
|
87 | 88 | // Set the computed querie of series if available
|
88 | 89 | _.each(definition.series, function(serie) {
|
89 | 90 | if(serie.filters) {
|
90 |
| - serie.query = DashboardSrv.buildFiltersQuery(scope.metadata[entity].attributes, serie.filters); |
| 91 | + serie.query = DashboardSrv.buildFiltersQuery(scope.metadata[entity || serie.entity].attributes, serie.filters); |
91 | 92 | }
|
92 | 93 | })
|
93 | 94 |
|
|
99 | 100 | });
|
100 | 101 | };
|
101 | 102 |
|
102 |
| - scope.editorFor = function(filter) { |
103 |
| - if (filter.type === null) { |
104 |
| - return; |
105 |
| - } |
106 |
| - var field = scope.metadata[scope.component.options.entity].attributes[filter.field]; |
107 |
| - var type = field.type; |
108 |
| - |
109 |
| - if ((type === 'string' || type === 'number') && field.values.length > 0) { |
110 |
| - return 'enumeration'; |
111 |
| - } |
112 |
| - |
113 |
| - return filter.type; |
114 |
| - }; |
115 |
| - |
116 |
| - scope.promiseFor = function(filter, query) { |
117 |
| - var field = scope.metadata[scope.component.options.entity].attributes[filter.field]; |
118 |
| - |
119 |
| - var promise = null; |
120 |
| - |
121 |
| - if(field.type === 'user') { |
122 |
| - promise = UserSrv.autoComplete(query); |
123 |
| - } else if (field.values.length > 0) { |
124 |
| - promise = $q.resolve( |
125 |
| - _.map(field.values, function(item, index) { |
126 |
| - return { |
127 |
| - text: item, |
128 |
| - label: field.labels[index] || item |
129 |
| - }; |
130 |
| - }) |
131 |
| - ); |
132 |
| - } else { |
133 |
| - promise = $q.resolve([]); |
134 |
| - } |
135 |
| - |
136 |
| - return promise.then(function(response) { |
137 |
| - var list = []; |
138 |
| - |
139 |
| - list = _.filter(response, function(item) { |
140 |
| - var regex = new RegExp(query, 'gi'); |
141 |
| - return regex.test(item.label); |
142 |
| - }); |
143 |
| - |
144 |
| - return $q.resolve(list); |
145 |
| - }); |
146 |
| - }; |
147 |
| - |
148 | 103 | scope.addFilter = function() {
|
149 | 104 | scope.component.options.filters = scope.component.options.filters || [];
|
150 | 105 |
|
|
158 | 113 | scope.component.options.filters.splice(index, 1);
|
159 | 114 | };
|
160 | 115 |
|
161 |
| - scope.setFilterField = function(filter) { |
162 |
| - var entity = scope.component.options.entity; |
| 116 | + scope.setFilterField = function(filter, entity) { |
163 | 117 | var field = scope.metadata[entity].attributes[filter.field];
|
164 | 118 |
|
165 | 119 | filter.type = field.type;
|
|
0 commit comments