Skip to content
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

feat(core): map editor hidden keys #4721

Merged
merged 1 commit into from
Jan 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="pair in $ctrl.backingModel">
<tr ng-repeat="pair in $ctrl.backingModel" ng-if="!$ctrl.hiddenKeys.includes(pair.key)">
<td class="table-label" ng-if="$ctrl.labelsLeft"><b>{{$ctrl.keyLabel}}</b></td>
<td><input class="form-control input input-sm" type="text"
name="{{$index}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = angular
onChange: '&',
labelsLeft: '<?',
label: '@',
hiddenKeys: '<',
},
controller: function($scope) {
this.backingModel = [];
Expand All @@ -34,6 +35,7 @@ module.exports = angular
this.columnCount = (this.labelsLeft ? 5 : 3);
this.model = this.model || {};
this.isParameterized = isString(this.model);
this.hiddenKeys = this.hiddenKeys || [];

let modelKeys = () => Object.keys(this.model);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ describe('Component: mapEditor', function () {
});
});


describe('hidden keys', function() {
it('does not render key if included in `hiddenKeys`', function() {
scope.model = { a: '1', b: '2' };
scope.hiddenKeys = ['a'];
const dom = this.compile('<map-editor model="model" hidden-keys="hiddenKeys"></map-editor>')(scope);
scope.$digest();
expect($(dom.find('tbody tr')).length).toBe(1);
expect(dom.find('input').get(0).value).toBe('b');
expect(dom.find('input').get(1).value).toBe('2');
});
});

});