-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from f7ed0/controller-modifier
Controller modifier
- Loading branch information
Showing
70 changed files
with
2,936 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ApiService } from 'sb-shared-lib'; | ||
|
||
// TODO add refresh function | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class TypeUsageService { | ||
protected scheme:any | ||
|
||
constructor( | ||
protected api:ApiService, | ||
) { | ||
this.api.fetch("?get=core_config_usages").then( | ||
data => { | ||
this.scheme = data | ||
console.log(this.scheme) | ||
} | ||
) | ||
} | ||
|
||
get usages() { | ||
return this.scheme | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...in/controllers/_components/params-editor/_components/param-list/param-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div> | ||
<mat-form-field class="filterinput"> | ||
<mat-icon matPrefix>filter_list</mat-icon> | ||
<mat-label>Filter</mat-label> | ||
<input matInput [formControl]="filterControl"> | ||
</mat-form-field> | ||
<button mat-mini-fab color="primary" (click)="createItem()"><mat-icon>add</mat-icon></button> | ||
</div> | ||
<mat-list class="list"> | ||
<mat-list-item *ngFor="let item of filteredList" class="item" (click)="onClickItem(list.indexOf(item))" [class.selected]="this.selectedIndex === list.indexOf(item)"> | ||
<div class="icon"> | ||
<mat-icon>{{iconList[item.type]}}</mat-icon> | ||
</div> | ||
<div class="name"> | ||
<label>{{item.name}}</label> | ||
</div> | ||
<div class="button"> | ||
<button mat-icon-button (click)="deleteItem(list.indexOf(item))"><mat-icon>delete</mat-icon></button> | ||
</div> | ||
</mat-list-item> | ||
</mat-list> |
50 changes: 50 additions & 0 deletions
50
...in/controllers/_components/params-editor/_components/param-list/param-list.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@import "src/theme.scss"; | ||
|
||
:host { | ||
width : 100%; | ||
height : 100%; | ||
padding: 1em; | ||
margin: .5em; | ||
background-color: whitesmoke; | ||
border-radius: 1em; | ||
|
||
} | ||
|
||
.list { | ||
width : 100%; | ||
height : 100%; | ||
overflow-y: scroll; | ||
} | ||
|
||
.selected { | ||
background-color: #dddddd; | ||
} | ||
|
||
.icon { | ||
display : flex; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: mat-color($maincolor,A100) ; | ||
min-width: 3em; | ||
width: 10%; | ||
height: 2em; | ||
border-radius: 1em; | ||
} | ||
|
||
.name { | ||
padding: 0 2em; | ||
width: calc( 100% - max(2em,10%) ); | ||
} | ||
|
||
.item { | ||
width: 100%; | ||
height: 3em; | ||
align-items: center; | ||
cursor : pointer; | ||
border-radius: .5em; | ||
} | ||
|
||
.filterinput { | ||
margin-right: 10px; | ||
width : calc(100% - 60px) | ||
} |
25 changes: 25 additions & 0 deletions
25
...controllers/_components/params-editor/_components/param-list/param-list.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ParamListComponent } from './param-list.component'; | ||
|
||
describe('ParamListComponent', () => { | ||
let component: ParamListComponent; | ||
let fixture: ComponentFixture<ParamListComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ParamListComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ParamListComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
91 changes: 91 additions & 0 deletions
91
...p/in/controllers/_components/params-editor/_components/param-list/param-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; | ||
import { FormControl } from '@angular/forms'; | ||
import { Params } from '@angular/router'; | ||
import { Observable } from 'rxjs'; | ||
import { map, startWith } from 'rxjs/operators'; | ||
import { AsyncPipe } from '@angular/common'; | ||
import { Param } from '../../_objects/Params'; | ||
import { ca } from 'date-fns/locale'; | ||
|
||
@Component({ | ||
selector: 'app-param-list', | ||
templateUrl: './param-list.component.html', | ||
styleUrls: ['./param-list.component.scss'] | ||
}) | ||
export class ParamListComponent implements OnInit, OnChanges { | ||
|
||
@Input() list: Params[] | ||
@Input() selectedIndex: number | ||
|
||
@Output() select = new EventEmitter<number>() | ||
@Output() CRUD = new EventEmitter<string>() | ||
|
||
public filteredList: Params[] | ||
|
||
public searchInput: string | ||
|
||
public filterControl = new FormControl("") | ||
public incremeter = 0 | ||
|
||
public iconList: { [id: string]: string } = { | ||
"string": "format_quote", | ||
"integer": "123", | ||
"array": "data_array", | ||
"float": "money", | ||
"boolean": "question_mark", | ||
"computed": "functions", | ||
"alias": "type_specimen", | ||
"binary": "looks_one", | ||
"date": "today", | ||
"datetime": "event", | ||
"time": "access_time", | ||
"text": "article", | ||
"many2one": "call_merge", | ||
"one2many": "call_split", | ||
"many2many": "height" | ||
} | ||
|
||
constructor() { | ||
|
||
} | ||
|
||
ngOnInit(): void { | ||
console.log("=============") | ||
this.filteredList = this.list.sort((p1, p2) => p1.name.localeCompare(p2.name)); | ||
console.log(this.filteredList) | ||
this.filterControl.valueChanges.subscribe(data => { | ||
console.log("RTIO") | ||
this.filteredList = this._filter(data) | ||
}) | ||
} | ||
|
||
ngOnChanges(): void { | ||
console.log("----") | ||
console.log(this.list) | ||
this.filteredList = this._filter(this.filterControl.value) | ||
} | ||
|
||
|
||
private _filter(value: string): Params[] { | ||
const filterValue = value.toLowerCase(); | ||
return this.list.filter(option => option.name.toLowerCase().includes(filterValue)).sort((p1, p2) => p1.name.localeCompare(p2.name)); | ||
} | ||
|
||
onClickItem(index: number) { | ||
this.select.emit(index) | ||
} | ||
|
||
createItem() { | ||
this.list.push(new Param("new_param_" + (this.incremeter++))) | ||
this.CRUD.emit("Creation of a new param") | ||
this.filteredList = this._filter(this.filterControl.value) | ||
} | ||
|
||
deleteItem(index: number) { | ||
let d = this.list.splice(index, 1) | ||
this.CRUD.emit("deletion of " + d[0].name) | ||
this.onClickItem(-1) | ||
this.filteredList = this._filter(this.filterControl.value) | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...omponent/property-domain-component/_components/auto-complete/auto-complete.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<mat-form-field appearance="fill" class="max-width"> | ||
<mat-label>{{ label }}</mat-label> | ||
<input matInput [formControl]="control" [matAutocomplete]="auto" [value]="value"> | ||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="onSelectionChange($event)"> | ||
<mat-option *ngFor="let option of filteredOptions | async" [value]="option"> | ||
{{ option }} | ||
</mat-option> | ||
</mat-autocomplete> | ||
</mat-form-field> |
Empty file.
43 changes: 43 additions & 0 deletions
43
..._component/property-domain-component/_components/auto-complete/auto-complete.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | ||
import { FormControl } from '@angular/forms'; | ||
import { Observable } from 'rxjs'; | ||
import { map, startWith } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'app-auto-complete', | ||
templateUrl: './auto-complete.component.html', | ||
styleUrls: ['./auto-complete.component.scss'] | ||
}) | ||
export class AutoCompleteComponent implements OnInit { | ||
|
||
@Input() label: string; | ||
@Input() options: string[]; | ||
@Input() value: any; | ||
@Output() updateValue = new EventEmitter<string>(); | ||
|
||
control = new FormControl(); | ||
filteredOptions: Observable<string[]>; | ||
|
||
constructor() { } | ||
|
||
ngOnInit(): void { | ||
this.filteredOptions = this.control.valueChanges.pipe( | ||
startWith(''), | ||
map(value => this.filter(value)) | ||
); | ||
|
||
this.control.setValue(this.value); | ||
} | ||
|
||
private filter(value: string): string[] { | ||
const filterValue = value.toLowerCase(); | ||
|
||
return Object.keys(this.options).filter(option => { | ||
return option.toLowerCase().includes(filterValue); | ||
}); | ||
} | ||
|
||
public onSelectionChange(event: any) { | ||
this.updateValue.emit(event.option.value); | ||
} | ||
} |
Oops, something went wrong.