-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(table, formfield): remove padding from formfields inside table an…
…d add example (#281)
- Loading branch information
1 parent
7f05f15
commit ad7e21d
Showing
6 changed files
with
149 additions
and
1 deletion.
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
8 changes: 8 additions & 0 deletions
8
...g-aquila/documentation/examples/table/table-form-elements/table-form-elements-example.css
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,8 @@ | ||
:host { | ||
overflow-x: auto; | ||
display: block; | ||
} | ||
|
||
.date-cell, .status-cell { | ||
min-width: 160px; | ||
} |
52 changes: 52 additions & 0 deletions
52
...-aquila/documentation/examples/table/table-form-elements/table-form-elements-example.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,52 @@ | ||
<table nxTable condensed class="nx-margin-bottom-xs"> | ||
<thead> | ||
<tr nxTableRow> | ||
<th nxHeaderCell>Assignment/Case ID</th> | ||
<th nxHeaderCell>Gross Amount</th> | ||
<th nxHeaderCell>Ending At</th> | ||
<th nxHeaderCell>Status</th> | ||
<th nxHeaderCell></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr nxTableRow *ngFor="let control of formArray.controls; index as i" [formGroup]="getFormGroup(i)"> | ||
<td nxTableCell> | ||
<nx-formfield> | ||
<input nxInput formControlName="id"/> | ||
</nx-formfield> | ||
</td> | ||
<td nxTableCell> | ||
<nx-formfield> | ||
<input nxInput formControlName="amount"/> | ||
</nx-formfield> | ||
</td> | ||
<td nxTableCell class="date-cell"> | ||
<nx-formfield> | ||
<input nxDatefield nxInput [nxDatepicker]="myDatepicker" formControlName="endingAt" /> | ||
|
||
<nx-datepicker-toggle [for]="myDatepicker" nxFormfieldSuffix></nx-datepicker-toggle> | ||
<nx-datepicker #myDatepicker></nx-datepicker> | ||
</nx-formfield> | ||
</td> | ||
<td nxTableCell class="status-cell"> | ||
<nx-formfield> | ||
<nx-dropdown formControlName="status"> | ||
<nx-dropdown-item nxValue="open"></nx-dropdown-item> | ||
<nx-dropdown-item nxValue="processing"></nx-dropdown-item> | ||
<nx-dropdown-item nxValue="accepted"></nx-dropdown-item> | ||
<nx-dropdown-item nxValue="rejected"></nx-dropdown-item> | ||
</nx-dropdown> | ||
</nx-formfield> | ||
</td> | ||
<td nxTableCell> | ||
<button nxPlainButton (click)="removeRow(i)" aria-label="Remove row"> | ||
<nx-icon name="trash-o"></nx-icon> | ||
</button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<button nxPlainButton (click)="addRow()"> | ||
<nx-icon name="plus" class="nx-margin-right-2xs"></nx-icon>Add row | ||
</button> |
67 changes: 67 additions & 0 deletions
67
...ng-aquila/documentation/examples/table/table-form-elements/table-form-elements-example.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,67 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormArray, FormControl, FormGroup } from '@angular/forms'; | ||
import { DATEPICKER_DEFAULT_OPTIONS } from '@aposin/ng-aquila/datefield'; | ||
import { FORMFIELD_DEFAULT_OPTIONS } from '@aposin/ng-aquila/formfield'; | ||
import moment from 'moment'; | ||
|
||
/** | ||
* @title Table with form elements | ||
*/ | ||
@Component({ | ||
selector: 'table-form-elements-example', | ||
templateUrl: './table-form-elements-example.html', | ||
styleUrls: ['./table-form-elements-example.css'], | ||
providers: [ | ||
// Both provided with NxExpertModule | ||
{ provide: FORMFIELD_DEFAULT_OPTIONS, useValue: { appearance: 'outline', nxFloatLabel: 'always' }}, | ||
{ provide: DATEPICKER_DEFAULT_OPTIONS, useValue: { toggleIconTabindex: -1 } }, | ||
] | ||
}) | ||
export class TableFormElementsExampleComponent { | ||
|
||
formArray = new FormArray([ | ||
new FormGroup({ | ||
id: new FormControl('123456789'), | ||
amount: new FormControl(250.00), | ||
endingAt: new FormControl(moment([2021, 4, 1])), | ||
status: new FormControl('open') | ||
}), | ||
new FormGroup({ | ||
id: new FormControl('987654321'), | ||
amount: new FormControl(1000.40), | ||
endingAt: new FormControl(moment([2023, 2, 23])), | ||
status: new FormControl('processing') | ||
}), | ||
new FormGroup({ | ||
id: new FormControl('123456700'), | ||
amount: new FormControl(40), | ||
endingAt: new FormControl(moment([2019, 11, 31])), | ||
status: new FormControl('accepted') | ||
}), | ||
new FormGroup({ | ||
id: new FormControl('123456780'), | ||
amount: new FormControl(501), | ||
endingAt: new FormControl(moment([2018, 11, 31])), | ||
status: new FormControl('rejected') | ||
}) | ||
]); | ||
|
||
addRow() { | ||
this.formArray.push( | ||
new FormGroup({ | ||
id: new FormControl(''), | ||
amount: new FormControl(''), | ||
endingAt: new FormControl(''), | ||
status: new FormControl('') | ||
}) | ||
); | ||
} | ||
|
||
removeRow(index: number) { | ||
this.formArray.removeAt(index); | ||
} | ||
|
||
getFormGroup(i: number): FormGroup { | ||
return this.formArray.controls[i] as FormGroup; | ||
} | ||
} |
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