aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons')
-rw-r--r--catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-button.component.less42
-rw-r--r--catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.html8
-rw-r--r--catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.ts29
3 files changed, 79 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-button.component.less b/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-button.component.less
new file mode 100644
index 0000000000..b929486b10
--- /dev/null
+++ b/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-button.component.less
@@ -0,0 +1,42 @@
+@import './../../../../../../assets/styles/variables.less';
+.radio-buttons-container{
+ display: flex;
+ &.vertical{
+ flex-direction: column;
+ }
+ &.horizontal{
+ flex-direction: row;
+ }
+}
+.radio-button {
+ margin: 0 10px 10px 0;
+ display: flex;
+}
+
+input[type=radio] {
+ width:0;
+ height:0;
+ display:none;
+ &[disabled] ~ .radio-button {
+
+ }
+}
+
+.shown-radio-button{
+ border: @main_color_n solid 1px;
+ height: 14px;
+ width: 14px;
+ border-radius: 50%;
+ padding: 1px;
+ margin: auto 5px;
+ .selected{
+ background-color: @main_color_a;
+ height: 100%;
+ width: 100%;
+ border-radius: 50%;
+ }
+}
+span{
+ margin: auto 0;
+ color: @func_color_s;
+}
diff --git a/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.html b/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.html
new file mode 100644
index 0000000000..6c927301db
--- /dev/null
+++ b/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.html
@@ -0,0 +1,8 @@
+<div class="radio-buttons-container {{direction}}">
+ <div *ngFor="let option of options" class="radio-button" [ngClass]="{'disabled':readonly}">
+ <input type="radio" [(ngModel)]="value" name="{{fieldName}}" value="{{option.value}}" [disabled]="readonly"/>
+ <div class="shown-radio-button" (click)="!readonly && select(option.value)"><div *ngIf="value==option.value" class="selected"></div></div>
+ <span>{{option.key}}</span>
+ </div>
+</div>
+
diff --git a/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.ts b/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.ts
new file mode 100644
index 0000000000..0f80e2ad44
--- /dev/null
+++ b/catalog-ui/src/app/ng2/components/ui/form-components/radio-buttons/radio-buttons.component.ts
@@ -0,0 +1,29 @@
+/**
+ * Created by rc2122 on 9/4/2017.
+ */
+import { Component, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core';
+import { RadioButtonModel } from 'app/models'
+import {UiElementBaseInterface, UiElementBase} from "../ui-element-base.component";
+
+@Component({
+ selector: 'radio-buttons',
+ templateUrl: './radio-buttons.component.html',
+ styleUrls: ['./radio-button.component.less']
+})
+export class RadioButtonComponent extends UiElementBase implements UiElementBaseInterface {
+
+ onSave() {
+ this.baseEmitter.emit(this.value);
+ }
+
+ @Input() options:Array<RadioButtonModel>;
+ @Input() readonly:boolean;
+ @Input() direction:string = 'vertical'; //get 'horizontal' | 'vertical'
+ value:any;
+
+ select(value:any) {
+ this.value = value;
+ this.baseEmitter.emit(this.value);
+ }
+}
+