[filter bar] Move alias to a separate input field
This commit is contained in:
parent
c4d4b186a4
commit
b755082681
5 changed files with 18 additions and 8 deletions
|
@ -71,12 +71,12 @@ describe('update filters', function () {
|
|||
});
|
||||
|
||||
it('should set an alias in the meta object', function () {
|
||||
newFilter.alias = 'foo';
|
||||
|
||||
queryFilter.updateFilter({
|
||||
source: currentFilter,
|
||||
model: newFilter,
|
||||
type: 'query'
|
||||
type: 'query',
|
||||
alias: 'foo'
|
||||
});
|
||||
$rootScope.$digest();
|
||||
expect(currentFilter.meta.alias).to.be('foo');
|
||||
|
|
|
@ -41,6 +41,15 @@
|
|||
|
||||
<div class="filter-edit-container" ng-if="editingFilter">
|
||||
<form role="form" name="editFilterForm" ng-submit="editDone()">
|
||||
<div class="form-group filter-edit-alias">
|
||||
<label>Filter Alias
|
||||
<small>(optional)</small>
|
||||
</label>
|
||||
<input
|
||||
ng-model="editingFilter.alias"
|
||||
type="text"
|
||||
class="form-control">
|
||||
</div>
|
||||
<div
|
||||
json-input
|
||||
require-keys=false
|
||||
|
|
|
@ -64,7 +64,8 @@ define(function (require) {
|
|||
type: _.first(_.filter(_.keys(source), function (key) {
|
||||
return !key.match(privateFilterFieldRegex);
|
||||
})),
|
||||
model: convertToEditableFilter(source)
|
||||
model: convertToEditableFilter(source),
|
||||
alias: source.meta.alias
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -129,7 +130,6 @@ define(function (require) {
|
|||
|
||||
function convertToEditableFilter(filter) {
|
||||
var model = _.cloneDeep(filter);
|
||||
model.alias = filter.meta.alias;
|
||||
|
||||
var filterType;
|
||||
//Hide private properties
|
||||
|
|
|
@ -60,6 +60,10 @@ filter-bar .bar {
|
|||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.filter-edit-alias {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.filter-link {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
|
|
@ -91,11 +91,8 @@ define(function (require) {
|
|||
* @returns {object} Promise that resolves to the new filter on a successful merge
|
||||
*/
|
||||
queryFilter.updateFilter = function (filter) {
|
||||
filter.source.meta.alias = filter.model.alias;
|
||||
delete filter.model.alias;
|
||||
|
||||
var mergedFilter = _.assign({}, filter.source, filter.model);
|
||||
|
||||
mergedFilter.meta.alias = filter.alias;
|
||||
//If the filter type is changed we want to discard the old type
|
||||
//when merging changes back in
|
||||
var filterTypeReplaced = filter.model[filter.type] !== mergedFilter[filter.type];
|
||||
|
|
Loading…
Reference in a new issue