Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.

Commit 756357a

Browse files
committed
Merge branch 'development' of https://github.com/oasp-forge/oasp4js-rev into development
2 parents 174c57f + aac6595 commit 756357a

11 files changed

+84
-54
lines changed

oasp4js-sample/src/app/components/crud/view/Crud.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<h2>Tables</h2>
12
<div>
23
<filter-panel (filterValues) = "searchFilters($event)">
34
<label> Number </label>

oasp4js-sample/src/app/components/header/view/Header.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
<ul *ngIf="logged" class = "header-tabs">
55
<li role = "presentation">
6-
<a> Tables </a>
6+
<a [routerLink]="['/Tables']"> Tables </a>
77
</li>
88
<li role = "presentation">
9-
<a> Kitchen </a>
9+
<a [routerLink]="['/Kitchen']"> Kitchen </a>
1010
</li>
1111
</ul>
1212

oasp4js-sample/src/app/components/header/view/Header.component.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Component } from '@angular/core';
22
import { EventEmitter } from '@angular/core';
33
import {languages} from '../../../resources/languages/Languages.resource'
4+
import {ROUTER_DIRECTIVES} from "@angular/router";
45

56
@Component({
67
selector: 'header',
78
templateUrl: 'app/components/header/view/Header.component.html',
89
inputs: ["logged", "username"],
9-
outputs: ["logOffEvent"]
10+
outputs: ["logOffEvent"],
11+
directives: [ROUTER_DIRECTIVES]
1012
})
1113

1214
export class HeaderComponent {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>KITCHEN</h1>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {Component} from '@angular/core'
2+
3+
@Component({
4+
selector:'kitchen',
5+
templateUrl:'app/components/kitchen/view/Kitchen.component.html'
6+
})
7+
8+
export class KitchenComponent{
9+
}

oasp4js-sample/src/app/oasp/oasp-ui/grid-table/view/Grid-table.component.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
</th>
88
</thead>
99
<tbody>
10-
<tr *ngFor="let obj of rowsData" #row (click)=clickedRow(obj)>
10+
<tr *ngFor="let obj of rowsData"
11+
(click)=clickedRow(obj)>
1112
<td *ngFor= "let attribute of attributeNames"
1213
[class.selected]="selection === obj">
1314
{{ obj[attribute] }}

oasp4js-sample/src/app/oasp/oasp-ui/grid-table/view/Grid-table.component.ts

+40-41
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,47 @@ import {GridtableService} from '../service/Grid-table.service'
1111

1212
export class GridTableComponent implements OnChanges{
1313

14-
headers;
15-
attributeNames;
16-
dataInput;
17-
18-
public rowsData = [];
19-
public attributesNames = [];
20-
public tableHeaders = [];
21-
22-
public selection;
23-
objSelected = new EventEmitter();
24-
25-
public sortIconStyle = ["glyphicon glyphicon-chevron-down","glyphicon glyphicon-chevron-down","glyphicon glyphicon-chevron-down"];
26-
27-
constructor(private gridtableService : GridtableService){
28-
}
29-
30-
ngOnChanges(){
31-
this.attributesNames = this.attributeNames;
32-
this.tableHeaders = this.headers;
33-
this.rowsData = this.dataInput;
34-
}
35-
36-
sortColumn(column:number, name:string){
37-
38-
if(this.sortIconStyle[column] === "glyphicon glyphicon-chevron-up"){
39-
this.sortIconStyle[column] = "glyphicon glyphicon-chevron-down";
40-
this.rowsData = this.gridtableService.getTablesOrderBy(-1, name, this.rowsData);
41-
} else {
42-
this.sortIconStyle[0] = "glyphicon glyphicon-chevron-down";
43-
this.sortIconStyle[1] = "glyphicon glyphicon-chevron-down";
44-
this.sortIconStyle[2] = "glyphicon glyphicon-chevron-down";
45-
this.sortIconStyle[column] = "glyphicon glyphicon-chevron-up";
46-
this.rowsData = this.gridtableService.getTablesOrderBy(1, name, this.rowsData);
14+
headers;
15+
attributeNames;
16+
dataInput;
17+
18+
public rowsData = [];
19+
public attributesNames = [];
20+
public tableHeaders = [];
21+
22+
public selection;
23+
objSelected = new EventEmitter();
24+
25+
public sortIconStyle = ["glyphicon glyphicon-chevron-down","glyphicon glyphicon-chevron-down","glyphicon glyphicon-chevron-down"];
26+
27+
constructor(private gridtableService : GridtableService){
28+
}
29+
30+
ngOnChanges(){
31+
this.attributesNames = this.attributeNames;
32+
this.tableHeaders = this.headers;
33+
this.rowsData = this.dataInput;
34+
}
35+
36+
sortColumn(column:number, name:string){
37+
if(this.sortIconStyle[column] === "glyphicon glyphicon-chevron-up"){
38+
this.sortIconStyle[column] = "glyphicon glyphicon-chevron-down";
39+
this.rowsData = this.gridtableService.getTablesOrderBy(-1, name, this.rowsData);
40+
} else {
41+
this.sortIconStyle[0] = "glyphicon glyphicon-chevron-down";
42+
this.sortIconStyle[1] = "glyphicon glyphicon-chevron-down";
43+
this.sortIconStyle[2] = "glyphicon glyphicon-chevron-down";
44+
this.sortIconStyle[column] = "glyphicon glyphicon-chevron-up";
45+
this.rowsData = this.gridtableService.getTablesOrderBy(1, name, this.rowsData);
46+
}
4747
}
48-
}
4948

50-
clickedRow(valor){
51-
if(this.selection === valor){
52-
this.selection = undefined;
53-
} else {
54-
this.selection = valor;
49+
clickedRow(valor){
50+
if(this.selection === valor){
51+
this.selection = undefined;
52+
} else {
53+
this.selection = valor;
54+
}
55+
this.objSelected.emit(this.selection);
5556
}
56-
this.objSelected.emit(this.selection);
57-
}
5857
}

oasp4js-sample/src/app/oasp/oasp-ui/table-pagination/Pagination.component.ts

+3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ export class PaginationComponent{
3434
this.rowsPerPage = this.initRowsPerPage;
3535
}
3636

37+
// This should be server-side
3738
this.showList = this.list.slice(this.rowsPerPage * (this.currentPage - 1), this.rowsPerPage * (this.currentPage - 1) + this.rowsPerPage);
3839
this.numberPages = Math.ceil(this.list.length / this.rowsPerPage);
3940
this.paginationList.emit(this.showList);
41+
// -------
4042

4143
if(this.showList.length <= 0){
4244
this.changePage(this.currentPage - 1, 0);
@@ -61,6 +63,7 @@ export class PaginationComponent{
6163
this.pageView = view;
6264
}
6365

66+
// This should be server-side
6467
if(this.rowsPerPage * (this.currentPage - 1) < this.rowsPerPage){
6568
this.showList = this.list.slice(0, this.rowsPerPage);
6669
} else{

oasp4js-sample/src/app/oasp4js-sample.component.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<header [logged]="login" [username] ="usuario.username" (logOffEvent)="login = $event"></header>
1+
<header [logged]="login" [username] ="usuario.username" (logOffEvent)="login = logOut($event)"></header>
22

33
<div class = "app-body">
44
<!-- LOGIN -->
@@ -7,9 +7,8 @@
77
</div>
88

99
<!-- APPLICATION -->
10-
<div *ngIf="login">
11-
<h2>Tables</h2>
12-
<crud></crud>
10+
<div [hidden]="!login">
11+
<router-outlet></router-outlet>
1312
</div>
1413
</div>
1514

oasp4js-sample/src/app/oasp4js-sample.component.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,41 @@ import { Component } from '@angular/core';
33
import { HeaderComponent} from './components/header/view/Header.component';
44
import { LoginComponent} from './components/login/view/Login.component';
55
import { CrudComponent } from './components/crud/view/Crud.component'
6+
import { KitchenComponent } from './components/kitchen/view/Kitchen.component'
67

78
import { User } from './models/user/User.model'
89

10+
import {ROUTER_DIRECTIVES, Router, Routes} from "@angular/router";
11+
12+
@Routes([
13+
{ path: '', component: CrudComponent },
14+
{ path: '/Tables', component: CrudComponent },
15+
{ path: '/Kitchen', component: KitchenComponent }
16+
])
17+
918
@Component({
1019
moduleId: module.id,
1120
selector: 'oasp4js-sample-app',
1221
templateUrl: 'oasp4js-sample.component.html',
1322
styleUrls: ['oasp4js-sample.component.css'],
14-
directives: [LoginComponent, HeaderComponent, CrudComponent]
23+
directives: [LoginComponent, HeaderComponent, CrudComponent, ROUTER_DIRECTIVES]
1524
})
25+
26+
1627
export class Oasp4jsSampleAppComponent{
1728
title = "oasp4js-sample works!";
1829
public login:boolean;
1930
public usuario: User = new User(0,"","");
2031

32+
constructor(private router: Router){}
33+
2134
enviar(value){
2235
setTimeout( ()=>{this.login = value;},1);
36+
this.router.navigate(['/Tables']);
2337
}
2438

2539
logOut(){
2640
this.login = false;
41+
this.router.navigate(['']);
2742
}
2843
}

oasp4js-sample/src/main.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { bootstrap } from '@angular/platform-browser-dynamic';
22
// import {bootstrap} from 'angular2/platform/browser'
33
import { enableProdMode } from '@angular/core';
4+
import { ROUTER_PROVIDERS, ROUTER_DIRECTIVES } from '@angular/router';
45
import { Oasp4jsSampleAppComponent, environment } from './app/';
56
//import {disableDeprecatedForms, provideForms} from "@angular/forms";
67

78
if (environment.production) {
89
enableProdMode();
910
}
1011

11-
bootstrap(Oasp4jsSampleAppComponent/*,[
12-
disableDeprecatedForms(),
13-
provideForms()
14-
]*/);
12+
13+
bootstrap(Oasp4jsSampleAppComponent, [ROUTER_PROVIDERS, ROUTER_DIRECTIVES])
14+
.catch(err => console.error(err));

0 commit comments

Comments
 (0)