summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/filter-properties-assignment
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/components/filter-properties-assignment')
-rw-r--r--catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.html26
-rw-r--r--catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.less38
-rw-r--r--catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.ts77
3 files changed, 141 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.html b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.html
new file mode 100644
index 0000000000..4d2b91f3b4
--- /dev/null
+++ b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.html
@@ -0,0 +1,26 @@
+<popover-content #filterPopover [title]="'Filters'" [buttons]="footerButtons" placement="bottom-right" [hideArrow]="true">
+ <!--<form [formGroup]="filterForm">-->
+ <form>
+ <div class="field">
+ <label>Resource Type</label>
+ <div>
+ <checkbox [label]="'All'" [(checked)]="allSelected" (checkedChange)="selectAll()"></checkbox>
+ </div>
+ <div *ngFor="let type of typesOptions">
+ <checkbox [label]="type" [(checked)]="selectedTypes[type]" (checkedChange)="onTypeSelected(type)"></checkbox>
+ </div>
+ </div>
+ <div class="field">
+ <label>Property Name</label>
+ <input class="i-sdc-form-input"
+ name="propertyName"
+ [(ngModel)]="filterData.propertyName"
+ placeholder="Type here"
+ required
+ />
+ </div>
+ </form>
+</popover-content>
+<div class="open-filter-button" [popover]="filterPopover" [ngClass]="{'open':showPopover}" (onShown)="showPopover = true" (onHidden)="showPopover = false">
+ <div class="sprite-new filter-icon"></div>
+</div>
diff --git a/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.less b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.less
new file mode 100644
index 0000000000..c1341b8dcf
--- /dev/null
+++ b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.less
@@ -0,0 +1,38 @@
+@import '../../../../assets/styles/variables';
+form{
+ margin: 0 20px;
+ .field{
+ padding:20px 0;
+ &:not(:last-child){
+ border-bottom: solid 1px @main_color_o;
+ }
+ }
+ /deep/ [ng-reflect-checked="true"]{
+ /deep/ .checkbox-label-content{
+ color: @main_color_a;
+ }
+ }
+}
+
+.open-filter-button{
+ cursor: pointer;
+ width: 25px;
+ height: 34px;
+ display: inline-block;
+ &.open{
+ z-index: 1061;
+ position: relative;
+ top: 2px;
+ background-color: @main_color_p;
+ border: solid 1px @main_color_c;
+ border-bottom: none;
+ }
+ .filter-icon{
+ top: 8px;
+ position: relative;
+ }
+}
+
+/deep/ .popover{
+ border: solid 1px @main_color_c !important;
+}
diff --git a/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.ts b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.ts
new file mode 100644
index 0000000000..c23e08bc0d
--- /dev/null
+++ b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.ts
@@ -0,0 +1,77 @@
+/**
+ * Created by rc2122 on 5/16/2017.
+ */
+import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
+import {ButtonModel, ButtonsModelMap, FilterPropertiesAssignmentData} from "app/models";
+import {PopoverComponent} from "../popover/popover.component";
+import * as sdcConfig from "../../../../../configurations/dev"
+
+@Component({
+ selector: 'filter-properties-assignment',
+ templateUrl: './filter-properties-assignment.component.html',
+ styleUrls: ['./filter-properties-assignment.component.less']
+})
+
+export class FilterPropertiesAssignmentComponent {
+ @Input() componentType: string;
+ @Output() searchProperties: EventEmitter<FilterPropertiesAssignmentData> = new EventEmitter<FilterPropertiesAssignmentData>();
+ footerButtons:ButtonsModelMap = {};
+ typesOptions:Array<string>;//All optional types
+ selectedTypes:Object = {};
+ allSelected:boolean = false;//if all option selected
+ filterData:FilterPropertiesAssignmentData = new FilterPropertiesAssignmentData();
+ @ViewChild('filterPopover') filterPopover: PopoverComponent;
+
+ ngOnInit() {
+ this.footerButtons['Apply'] = new ButtonModel('Apply', 'blue', this.search, this.someTypesSelectedAndThereIsPropertyName);
+ this.footerButtons['Close'] = new ButtonModel('Close', 'grey', this.close);
+ this.componentType = this.componentType.toLocaleLowerCase();
+ this.typesOptions = sdcConfig.resourceTypesFilter[this.componentType];
+ }
+
+ selectAll = () => {
+ _.forEach(this.typesOptions, (type) => {
+ this.selectedTypes[type] = this.allSelected;
+ });
+ }
+
+ onTypeSelected = (type:string) => {
+ if(!this.selectedTypes[type]){
+ this.allSelected = false;//unselected 'All'
+ }
+ };
+
+ search = () => {
+ console.log('search props');
+ this.filterData.selectedTypes = [];
+ _.forEach(sdcConfig.resourceTypesFilter[this.componentType], (type) => {
+ if(this.selectedTypes[type]){
+ this.filterData.selectedTypes.push(type);
+ }
+ });
+ this.searchProperties.emit(this.filterData);
+ this.filterPopover.hide();
+ }
+
+ close = () => {
+ this.filterPopover.hide();
+ }
+
+ someTypesSelectedAndThereIsPropertyName = ():boolean => {
+ if( _.find(Object.keys(this.selectedTypes),(key) => {
+ return this.selectedTypes[key];
+ }) && this.filterData.propertyName ){
+ return null
+ }
+ return true;
+ }
+
+ clearAll = ():void => {
+ this.filterData.propertyName = "";
+ _.forEach(this.selectedTypes,(value, key) => {
+ this.selectedTypes[key] = false;
+ });
+ this.allSelected = false;
+ }
+
+}