Commit 5f726a0e authored by julienmege's avatar julienmege Committed by abirembaut

fix(update) Update user manager in community (#499)

Rename directive property from "selected" to "selected-manager", to avoid grunt "htmlmin" task to remove the binding.
As the option "collapseBooleanAttributes: true" consider "selected" as a Boolean.

Closes [BPO-23](https://bonitasoft.atlassian.net/browse/BPO-23)
parent 030e8549
......@@ -53,7 +53,7 @@
<label class="col-md-3 control-label" translate>Manager</label>
<div class="col-md-9">
<bo-manager-field
selected="vm.user.manager_id"
selected-manager="vm.user.manager_id"
on-type="vm.searchManagers">
</div>
</div>
......
......@@ -8,7 +8,7 @@
function boManagerField() {
return {
scope: {
manager: '=selected',
selectedManager: '=',
onType: '=',
},
replace: true,
......
<input type="text"
class="form-control"
ng-model="vm.manager"
ng-model="vm.selectedManager"
typeahead="manager as vm.formatLabel(manager) for manager in vm.searchManagers($viewValue)"
typeahead-input-formatter="vm.formatLabel($model)"
ng-model-options="{ debounce: 200 }"
......
......@@ -11,7 +11,7 @@
scope = $rootScope.$new();
$timeout = _$timeout_;
scope.selected = {};
scope.selectedManager = {};
scope.search = function(value) {
return [
{firstname: 'Walter', lastname: 'Bates', userName: 'walter.bates'},
......@@ -19,21 +19,21 @@
{firstname: 'Hellen', lastname: 'Kelly', userName: 'hellen.kelly'}
].filter(manager => manager.firstname.indexOf(value) !== -1);
};
let template = '<div><bo-manager-field selected="selected" on-type="search"> </bo-manager-field></div>';
let template = '<div><bo-manager-field selected-manager="selectedManager" on-type="search"> </bo-manager-field></div>';
element = $compile(template)(scope);
scope.$apply();
modelCtrl = element.find('input').controller('ngModel');
}));
it('should display an empty field when selected manager is not defined', () => {
scope.selected = undefined;
scope.selectedManager = undefined;
scope.$apply();
expect(element.find('input').val()).toEqual('');
});
it('should format the manager\'s name', () => {
scope.selected = {firstname: 'Walter', lastname: 'Bates', userName: 'walter.bates'};
scope.selectedManager = {firstname: 'Walter', lastname: 'Bates', userName: 'walter.bates'};
scope.$apply();
expect(element.find('input').val()).toEqual('Walter Bates (walter.bates)');
......@@ -85,7 +85,7 @@
let lis = element.find('li');
angular.element(lis[0]).click();
expect(scope.selected).toEqual({firstname: 'Walter', lastname: 'Bates', userName: 'walter.bates'});
expect(scope.selectedManager).toEqual({firstname: 'Walter', lastname: 'Bates', userName: 'walter.bates'});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment