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