47 lines
1.0 KiB
JavaScript
47 lines
1.0 KiB
JavaScript
|
import ngModule from '../module';
|
||
|
|
||
|
class Controller {
|
||
|
constructor($scope, $stateParams) {
|
||
|
this.$scope = $scope;
|
||
|
this.$stateParams = $stateParams;
|
||
|
}
|
||
|
|
||
|
get worker() {
|
||
|
return this._worker;
|
||
|
}
|
||
|
|
||
|
set worker(value) {
|
||
|
this._worker = value;
|
||
|
if (value) {
|
||
|
this.$scope.$applyAsync(()=> {
|
||
|
this.$scope.model.link = {userFk: value.userFk};
|
||
|
this.$scope.model.refresh();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onSubmit() {
|
||
|
this.$scope.watcher.check();
|
||
|
this.$scope.model.save().then(() => {
|
||
|
this.$scope.watcher.updateOriginalData();
|
||
|
this.$scope.watcher.notifySaved();
|
||
|
this.card.reload();
|
||
|
});
|
||
|
}
|
||
|
|
||
|
add() {
|
||
|
this.$scope.model.insert();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Controller.$inject = ['$scope', '$stateParams'];
|
||
|
|
||
|
ngModule.component('vnWorkerPhones', {
|
||
|
template: require('./index.html'),
|
||
|
controller: Controller,
|
||
|
require: {card: '^vnWorkerCard'},
|
||
|
bindings: {
|
||
|
worker: '<'
|
||
|
}
|
||
|
});
|