Skip to content

Instantly share code, notes, and snippets.

@Y2017
Created July 16, 2017 16:08
Show Gist options
  • Save Y2017/edabd3b71283fa058b79f5304b45d465 to your computer and use it in GitHub Desktop.
Save Y2017/edabd3b71283fa058b79f5304b45d465 to your computer and use it in GitHub Desktop.
## PREZ : Dynamic Forms Prototyping (step 1)
--------------------------------------------
# object of discussion :
for Biotracking, being able to generate dynamic forms
# difficulties :
Ex : to populate the sample_number dropdown with correct values depending of the path (selection context)
a case of multiple chained dropdowns
400 Visit Dd
500 Sample Type Dd
510 Conditioning Dd ['FROZEN SAMPLE', 'PARAFFIN EMBEDDED SAMPLE', 'SLIDES FROM PARAFFIN EMBEDDED SAMPLE']
600 Local pathological ID Tx
610 Sample number Dd
with :
- sample_number dropdown values = fn(visit_value, sample_type_value, conditioning_value?)
- conditioning_value? : is not present for each combination of (visit, sample_type)
- conditional display of fields (conditioning dropdown, local pathological ID text)
# demo :
- Old Ng1 Finesse Biotracking version
- New Ng4 Biotracking version
NB : RAZ on new selected
# folders :
formd : module
dform : component (ex : custom form : register a sample)
dform-element : component (core dynamic form)
dform-element.component.css
dform-element.component.html
dform-element.component.spec.ts
dform-element.component.ts
dform.component.css
dform.component.html
dform.component.spec.ts
dform.component.ts
dform.service.spec.ts
dform.service.ts (service for funct and tech form data)
formd.module.ts
# data :
Useful functional data and technical data are centralized in service dform.service.ts
getFormElements()
getFormData (child, parent?, selected?, form?){
getFormGroup(formElements)
# template :
<form class="form-horizontal"
(ngSubmit)="onSubmit()"
[formGroup]="form">
<div *ngFor="let formElement of formElements" class="form-group">
<app-dform-element [formElement]="formElement"
[form]="form" ></app-dform-element>
</div>
<div class="col-sm-offset-4 col-sm-8">
<button class="btn btn-info"
type="submit"
[disabled]="!form.valid">Register</button>
</div>
</form>
# Complete form
"Register a Sample" will all internal dependencies :
Form Initial State S0 :
100 Site number Tx
200 Patient number Dd
300 Patient patient_birthdate Tx
400 Visit Dd
500 Sample Type Dd
510 Conditioning Dd ['FROZEN SAMPLE', 'PARAFFIN EMBEDDED SAMPLE', 'SLIDES FROM PARAFFIN EMBEDDED SAMPLE']
600 Local pathological ID Tx
610 Sample number Dd
700 Collection date Dt
705 Collection time Tm
710 Anatomical location Tx
720 Freezing procedure Dd
730 Total serum volume (mL) Tx
740 Total plasma volume (mL) Dd
750 Number of cryovials Tx
770 Storage temperature Dd ['-20°C', '-70°C or below']
772 Was sample taken prior to first administration of Lucitanib? Dd ['Yes', 'No']
775 Last drug intake date Dt
776 Last drug intake time Dt
800 Sample state Dd ['Good', 'Acceptable', 'Damaged', 'Destroyed', 'Exhausted', 'Lost', 'Other']
900 Comments Tx
# Still to do :
# Reset Selection : RAZ when selecting new values after a first selection
# refactor calculated visibility of children fields (like conditioning)
# refactor calculated child_options (for getFormData)
# all other linked form fields (Register a new sample)
# get data from external mocked services (result of observables)
# data from route / mock backend
# data from API / generic data Urls - secu WS calls - via proxy
# formModel from JSONB/DB
# errors, validation
# prepare externalization of core dynform component (form-element)
# external component packaging and import
(npm install --save from dist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment