-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the support for the Item Control grid extension. #117
base: master
Are you sure you want to change the base?
Changes from 9 commits
4eafcec
060d2fa
d9d291c
890dc22
a8620cc
d3ecc67
6ebab45
4cfc0f6
b1ab172
45c9c0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ import { SafeHtmlPipe } from './safe-html.pipe'; | |
import { LhcButtonPopoverComponent } from './lhc-button-popover/lhc-button-popover.component'; | ||
import { LhcItemAttachmentComponent } from './lhc-item-attachment/lhc-item-attachment.component'; | ||
import { LhcItemMessagesComponent } from './lhc-item-messages/lhc-item-messages.component'; | ||
import { LhcItemGirdComponent } from './lhc-item-gird/lhc-item-gird.component'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please rename it to lhc-group-grid as it is similar to lhc-group-matrix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and LhcGroupGridComponent |
||
|
||
|
||
registerLocaleData(en); | ||
|
@@ -87,7 +88,8 @@ registerLocaleData(en); | |
SafeHtmlPipe, | ||
LhcButtonPopoverComponent, | ||
LhcItemAttachmentComponent, | ||
LhcItemMessagesComponent | ||
LhcItemMessagesComponent, | ||
LhcItemGirdComponent | ||
], | ||
imports: [ | ||
BrowserModule, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<div *ngIf="item" class="lhc-layout-grid lf-table-item {{lhcDataService.getSiblingStatus(item)}}"> | ||
<div class="lf-form-grid-table-title" *ngIf="!formLevel"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CSS class names starting with 'lf-' are legacy names used in the previous versions of lforms, and will be cleaned up eventually. Please use 'lhc-' when adding new CSS class names. |
||
<lhc-item-question-text [item]="item"></lhc-item-question-text> | ||
</div> | ||
|
||
<table class="lf-form-grid-table lf-form-table"> | ||
<colgroup> | ||
<col class="lf-question"> | ||
<col *ngFor="let answer of item.items[0].answers"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The number of columns should be from item.items, right? The "other-answer" is not needed. Your implementation looks similar to the "matrix" ("table in fhir itemControl). If that's what you need, "matrix" has been implemented in lforms. There was discussion on chat.fhir.org (https://chat.fhir.org/#narrow/stream/179255-questionnaire/topic/Grid.20Question) that the items under each group are not necessary same. The grid could be sparse. |
||
<col class="other-answer" *ngIf="item.items[0].dataType ==='CWE'"> | ||
</colgroup> | ||
<thead> | ||
|
||
<tr class="lhc-grid-table-header-row"> | ||
<th class="lhc-form-grid-table-header"></th> | ||
<th class="lhc-form-grid-table-header">{{item.question}}</th> | ||
<th *ngFor="let header of uniqueGridHeaders; index as i;" class="lhc-form-grid-table-header" | ||
id="answer-{{index}}">{{header}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<ng-container *ngFor="let subItem of item.items; trackBy: lhcDataService.trackByElementId"> | ||
<tr *ngIf="subItem && lhcDataService.targetShown(subItem) && !subItem._isHiddenFromView" role="radiogroup" aria-labeledby="label-{{subItem._elementId }}" | ||
aria-describedby="help-{{ subItem._parentItem._elementId }} help-{{ subItem._elementId }}"> | ||
<td class="lf-question"> | ||
<lhc-item-question-text [item]="subItem"></lhc-item-question-text> | ||
<lhc-item-messages [item]="subItem"></lhc-item-messages> | ||
</td> | ||
|
||
<td> | ||
<div class="lf-form-item-data tooltipContainer"> | ||
<lhc-item-question [item]="subItem" [options]="{hideQuestionText: true}" class="lhc-de"> | ||
</lhc-item-question> | ||
</div> | ||
</td> | ||
|
||
<ng-container *ngFor="let cell of subItem.items; trackBy: lhcDataService.trackByElementId"> | ||
<td *ngIf="cell && lhcDataService.targetShown(cell) && !cell._isHiddenFromView" | ||
class="{{lhcDataService.getRowClass(cell)}} {{lhcDataService.getSkipLogicClass(cell)}} {{lhcDataService.getActiveRowClass(cell)}}"> | ||
<div class="lf-form-item-data tooltipContainer"> | ||
<lhc-item-question [item]="cell" [options]="{hideQuestionText: true}" class="lhc-de"> | ||
</lhc-item-question> | ||
</div> | ||
</td> | ||
</ng-container> | ||
|
||
</tr> | ||
</ng-container> | ||
</tbody> | ||
</table> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { LhcItemGirdComponent } from './lhc-item-gird.component'; | ||
|
||
describe('LhcItemGirdComponent', () => { | ||
let component: LhcItemGirdComponent; | ||
let fixture: ComponentFixture<LhcItemGirdComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ LhcItemGirdComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LhcItemGirdComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { LhcDataService} from '../../lib/lhc-data.service'; | ||
import * as _ from "lodash"; | ||
|
||
@Component({ | ||
selector: 'lhc-item-gird', | ||
templateUrl: './lhc-item-gird.component.html', | ||
styleUrls: ['./lhc-item-gird.component.css'] | ||
}) | ||
export class LhcItemGirdComponent { | ||
|
||
|
||
@Input() item; | ||
@Input() formLevel: boolean = false; | ||
uniqueGridHeaders: any[] = []; | ||
constructor(public lhcDataService: LhcDataService) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.createCustomHeaders(this.item); | ||
} | ||
|
||
createCustomHeaders(item): void{ | ||
_.forEach(item.items, (questionItems, key) => { | ||
_.forEach(questionItems.items, (subItems,key) => { | ||
if(!_.includes(this.uniqueGridHeaders, subItems.question) && subItems.skipLogic?.conditions[0]?.trigger?.value != 'alwaysHide'){ | ||
this.uniqueGridHeaders.push(subItems.question); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*** grid layout ***/ | ||
.lhc-form .lhc-layout-grid.lhc-item { | ||
padding-bottom: 2px; | ||
} | ||
.lhc-form .lf-form-grid-table { | ||
border-collapse: separate; | ||
border-radius: 4px; | ||
box-sizing: border-box; | ||
margin: 2px 4px 0 1px; | ||
text-align: left; | ||
border: 1px solid #ced5d9; | ||
} | ||
.lhc-form .lf-form-grid-table .lhc-grid-table-header-row { | ||
background: #E8E8E8; | ||
} | ||
|
||
.lhc-form-grid-table-header { | ||
overflow: hidden; | ||
vertical-align: top; | ||
background: none repeat scroll 0 0 #E8E8E8; | ||
padding: 4px 2px; | ||
text-align: left ; | ||
color: #666666; | ||
font-weight: 400; | ||
-moz-border-radius: 4px; | ||
border-radius: 4px; | ||
} | ||
|
||
.lhc-form .lf-form-grid-table-title { | ||
background: #e6f1ff; /*#E8E8E8;*/ | ||
-moz-border-radius: 4px; | ||
border-radius: 4px; | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
margin: 0 0 0 1px; | ||
text-align: left; | ||
|
||
border-width: 0; | ||
border-top: 2px solid white; /* leave space between headers */ | ||
padding: 4px 2px 4px 2px; | ||
} | ||
.lhc-form .lf-form-grid-table .lf-question { | ||
width: 25%; | ||
} | ||
.lhc-form .lf-form-grid-answer { | ||
padding-left: 5px; | ||
padding-right: 5px; | ||
} | ||
|
||
.lhc-form .lf-form-grid-cell-other { | ||
text-align: center; | ||
} | ||
.lhc-form .lf-form-grid-table th { | ||
padding: 4px; | ||
} | ||
.lhc-form .lf-form-grid-table td { | ||
padding: 4px; | ||
border-top: 1px solid #ced5d9; | ||
} | ||
/*** end of grid layout ***/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to add another 70KB unless it's absolutely necessary. forEach and includes could be done without lodash.