1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-20 05:49:40 +02:00
portainer/app/portainer/components/BoxSelector/BoxSelectorAngular.tsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.1 KiB
TypeScript
Raw Normal View History

import {
IComponentOptions,
IComponentController,
IFormController,
IScope,
} from 'angular';
class BoxSelectorController implements IComponentController {
formCtrl!: IFormController;
onChange!: (value: string | number) => void;
radioName!: string;
$scope: IScope;
/* @ngInject */
constructor($scope: IScope) {
this.handleChange = this.handleChange.bind(this);
this.$scope = $scope;
}
handleChange(value: string | number, limitedToBE: boolean) {
this.$scope.$evalAsync(() => {
this.formCtrl.$setValidity(this.radioName, !limitedToBE, this.formCtrl);
this.onChange(value);
});
}
}
export const BoxSelectorAngular: IComponentOptions = {
template: `<box-selector-react
value="$ctrl.value"
on-change="$ctrl.handleChange"
options="$ctrl.options"
radio-name="$ctrl.radioName"
slim="$ctrl.slim"
></box-selector-react>`,
bindings: {
value: '<',
onChange: '<',
options: '<',
radioName: '<',
slim: '<',
},
require: {
formCtrl: '^form',
},
controller: BoxSelectorController,
};