-
Notifications
You must be signed in to change notification settings - Fork 98
/
bhMultipleDepotSelect.js
47 lines (39 loc) · 1.07 KB
/
bhMultipleDepotSelect.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
angular.module('bhima.components')
.component('bhMultipleDepotSelect', {
templateUrl : 'modules/templates/bhMultipleDepotSelect.tmpl.html',
controller : MultipleDepotSelectController,
bindings : {
depotsUuids : '<',
label : '@?',
onChange : '&',
formName : '@?',
},
});
MultipleDepotSelectController.$inject = [
'DepotService', 'NotifyService',
];
/**
* Multiple Depot Selection Component
*
*/
function MultipleDepotSelectController(Depots, Notify) {
const $ctrl = this;
$ctrl.$onInit = function onInit() {
// label to display
$ctrl.label = $ctrl.label || 'STOCK.DEPOT';
// default for form name
$ctrl.formName = $ctrl.formName || 'DepotForm';
// init the model
$ctrl.depotsUuids = $ctrl.depotsUuids || [];
// load all Depot
Depots.read()
.then(depots => {
$ctrl.depots = depots;
})
.catch(Notify.handleError);
};
// fires the onChange bound to the component boundary
$ctrl.handleChange = (depots) => {
$ctrl.onChange({ depots });
};
}