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

Commit b14bd94

Browse files
committed
details + pagination (wrong version)
1 parent 4f69ff3 commit b14bd94

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

oasp4js-sample/src/app/components/details/service/Details.service.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable} from '@angular/core'
1+
import {Injectable, OnInit} from '@angular/core'
22
import {Table} from '../../../models/table/Table.model'
33
import {tablesList} from '../../../resources/tables/Tables.resource'
44
import {Command} from '../../../models/command/Command.model'
@@ -9,6 +9,8 @@ export class DetailsService{
99
commands : Command[] = [];
1010
commandList : Command[] = commandsList;
1111

12+
13+
1214
addCommand(c:Command){
1315

1416
let n = 0;
@@ -36,4 +38,8 @@ export class DetailsService{
3638
this.commands = [];
3739
}
3840

41+
copyCommands():Command[]{
42+
return JSON.parse(JSON.stringify(this.commands));
43+
}
44+
3945
}

oasp4js-sample/src/app/components/details/view/Details.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232

3333
<div style="text-align:right">
34-
<pagination [list] = "detailsService.commands" [rowsPerPage] = "commandsPerPage" (paginationList) = "pagination($event)"></pagination>
34+
<pagination [list] = "myCommands" [rowsPerPage] = "commandsPerPage" (paginationList) = "pagination($event)"></pagination>
3535
</div>
3636

3737
<div style="text-align:right;" class="modal-footer">

oasp4js-sample/src/app/components/details/view/Details.component.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Output, EventEmitter, OnChanges} from '@angular/core'
1+
import {Component, Output, EventEmitter, OnChanges, OnInit} from '@angular/core'
22
import {Table} from '../../../models/table/Table.model'
33
import {commandsList} from '../../../resources/commands/Commands.resource'
44
import {Command} from '../../../models/command/Command.model'
@@ -15,15 +15,16 @@ import {GridTableComponent} from '../../../oasp/oasp-ui/grid-table/view/Grid-tab
1515
directives:[PaginationComponent, GridTableComponent],
1616
})
1717

18-
export class DetailsComponent implements OnChanges{
18+
export class DetailsComponent implements OnInit{
1919
resultEvent:EventEmitter<Table> = new EventEmitter<Table>();
2020
closeWindowEvent = new EventEmitter();
2121

2222
constructor(private detailsService:DetailsService){}
2323

24-
ngOnChanges(){
24+
ngOnInit(){
2525
if(this.parentTable.commands !== undefined){
2626
this.detailsService.commands = JSON.parse(JSON.stringify(this.parentTable.commands));
27+
this.myCommands = this.detailsService.copyCommands();
2728
}
2829
}
2930

@@ -41,6 +42,8 @@ export class DetailsComponent implements OnChanges{
4142
public commandsPerPage = 4;
4243
public showCommands: Command[];
4344

45+
public myCommands: Command[];
46+
4447

4548
openMenu(){
4649
this.viewMenu = !this.viewMenu;
@@ -49,8 +52,8 @@ export class DetailsComponent implements OnChanges{
4952

5053
addCommand(){
5154
this.viewMenu = !this.viewMenu;
52-
console.log("addCommand() --> viewMenu = " + this.viewMenu);
5355
this.detailsService.addCommand(this.commandToAdd);
56+
this.myCommands = this.detailsService.copyCommands();
5457
this.resetValues();
5558
}
5659

@@ -68,6 +71,7 @@ export class DetailsComponent implements OnChanges{
6871
if(this.detailsService.commands.length === 0){
6972
this.emptyTable = true;
7073
}
74+
this.myCommands = this.detailsService.copyCommands();
7175
}
7276

7377
resetValues(){

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

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class PaginationComponent implements OnChanges{
2121
paginationList = new EventEmitter();
2222

2323
ngOnChanges(){
24+
debugger
2425
if(this.list){
2526
if(this.rowsPerPage > this.list.length){
2627
this.rowsPerPage = this.list.length;

0 commit comments

Comments
 (0)