-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSettingsXmlView.fs
719 lines (672 loc) · 31.7 KB
/
SettingsXmlView.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
module SettingsXmlView
open Fulma
open Fable
open Fable.React
open Fable.React.Props
open Fable.FontAwesome
//open Fable.Core.JS
open Fable.Core.JsInterop
open Shared
open Model
open Messages
let dangerZone model dispatch =
div [][
Label.label [][str "Dangerzone"]
Container.container [
Container.Props [Style [
Padding "1rem"
Border (sprintf "2.5px solid %s" NFDIColors.Red.Base)
BorderRadius "10px"
]]
][
Button.a [
Button.Color Color.IsDanger
Button.IsFullWidth
Button.OnClick (fun e -> DeleteAllCustomXml |> ExcelInterop |> dispatch )
Button.Props [Style []; Title "Be sure you know what you do. This cannot be undone!"]
] [
Icon.icon [ ] [
Fa.i [Fa.Solid.ExclamationTriangle][]
]
span [] [str "Delete All Custom Xml!"]
Icon.icon [ ] [
Fa.i [Fa.Solid.ExclamationTriangle][]
]
]
]
]
let breadcrumbEle dispatch =
Breadcrumb.breadcrumb [Breadcrumb.HasArrowSeparator][
Breadcrumb.item [][
a [
OnClick (fun e -> UpdatePageState (Some Routing.Route.Settings) |> dispatch)
][
str (Routing.Route.Settings.toStringRdbl)
]
]
Breadcrumb.item [ Breadcrumb.Item.IsActive true ][
a [
OnClick (fun e -> UpdatePageState (Some Routing.Route.SettingsXml) |> dispatch)
][
str Routing.Route.SettingsXml.toStringRdbl
]
]
]
let showRawCustomXmlButton model dispatch =
Field.div [][
Button.a [
Button.Color Color.IsInfo
Button.IsFullWidth
Button.OnClick (fun e -> GetSwateCustomXml |> ExcelInterop |> dispatch )
Button.Props [Title "Show record type data of Swate custom Xml"]
] [
span [] [str "Load raw custom xml"]
]
]
let textAreaEle (model:Model) dispatch =
Columns.columns [Columns.IsMobile][
Column.column [][
Control.div [][
Textarea.textarea [
Textarea.OnChange (fun e ->
UpdateNextRawCustomXml e.Value |> SettingsXmlMsg |> dispatch
)
Textarea.DefaultValue model.SettingsXmlState.RawXml
][ ]
]
]
Column.column [
Column.Width (Screen.All,Column.IsNarrow)
][
Field.div [][
Button.a [
Button.Props [
Style [Width "40.5px"]
Title "Copy to Clipboard"
]
Button.Color IsInfo
Button.OnClick (fun e ->
let txt = model.SettingsXmlState.RawXml
let textArea = Browser.Dom.document.createElement "textarea"
textArea?value <- txt
textArea?style?top <- "0"
textArea?style?left <- "0"
textArea?style?position <- "fixed"
Browser.Dom.document.body.appendChild textArea |> ignore
textArea.focus()
/// Can't belive this actually worked
textArea?select()
let t = Browser.Dom.document.execCommand("copy")
Browser.Dom.document.body.removeChild(textArea) |> ignore
()
)
][
Fa.i [Fa.Regular.Clipboard ] []
]
]
Field.div [][
Button.a [
Button.IsStatic (model.SettingsXmlState.NextRawXml = "")
Button.Props [
Style [Width "40.5px"]
Title "Apply Changes"
]
Button.Color IsWarning
Button.OnClick (fun e ->
let rmvWhiteSpace =
let xmlEle = model.SettingsXmlState.NextRawXml |> Fable.SimpleXml.SimpleXml.parseElementNonStrict
xmlEle
|> OfficeInterop.HelperFunctions.xmlElementToXmlString
let msg = ExcelInteropMsg.UpdateSwateCustomXml rmvWhiteSpace |> ExcelInterop
let modalBody = "Changes in this field could potentially invalidate your checklist and protocol xml. Please safe a copy before clicking 'Continue'."
let nM = {|ModalMessage = modalBody; NextMsg = msg|} |> Some
UpdateWarningModal nM |> dispatch
)
][
Fa.i [
Fa.Solid.Pen
] []
]
]
]
]
let showRawCustomXmlEle (model:Model) dispatch =
div [
Style [
BorderLeft (sprintf "5px solid %s" NFDIColors.Mint.Base)
Padding "0.25rem 1rem"
MarginBottom "1rem"
]
][
Field.div [][
Help.help [Help.Modifiers [Modifier.TextAlignment (Screen.All,TextAlignment.Justified)]][
str "Here you can display all custom xml of your Swate table. This can help debug your Swate table and/or fix any problems occuring."
]
]
Field.div [][
Columns.columns [Columns.IsMobile][
Column.column [][
showRawCustomXmlButton model dispatch
]
if model.SettingsXmlState.RawXml <> "" then
Column.column [Column.Width (Screen.All,Column.IsNarrow)][
Button.a [
Button.OnClick (fun e -> UpdateRawCustomXml "" |> SettingsXmlMsg |> dispatch)
Button.Color IsDanger
Button.Props [Title "Remove custom xml from the text area"]
][
Fa.i [Fa.Solid.Times][]
]
]
]
]
if model.SettingsXmlState.RawXml <> "" then
Field.div [][
textAreaEle model dispatch
]
]
// UP: Elements used to display raw custom xml
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Down: Elements used to display validation/checklist xml
let getValidationXmlButton (model:Model) dispatch =
Button.span [
Button.Color IsInfo
Button.IsFullWidth
Button.OnClick (fun e ->
GetAllValidationXmlParsedRequest |> SettingsXmlMsg |> dispatch
)
][
str "Load checklist xml"
]
let removeValidationXmlButton (model:Model) dispatch =
Button.span [
Button.Color IsDanger
Button.OnClick (fun e ->
UpdateValidationXmls [||] |> SettingsXmlMsg |> dispatch
)
][
Fa.i [Fa.Solid.Times][]
]
open OfficeInterop.Types.Xml
let private tryFindInMap (tryFindMap:Map<string,string>) (toFind:Shared.AnnotationTable) =
let isValidKey = tryFindMap.ContainsKey toFind.Name
if isValidKey then
tryFindMap.[toFind.Name] = toFind.Worksheet
else false
let applyChangesToTableValidationButton (model:Model) dispatch (tableValidation:ValidationTypes.TableValidation) isNextValidForWorkbook =
Button.a [
Button.Color IsWarning
Button.IsStatic (isNextValidForWorkbook |> not)
Button.OnClick (fun e ->
let prevat = tableValidation.AnnotationTable
let newat = model.SettingsXmlState.NextAnnotationTableForActiveValidation.Value
let prevXml = XmlTypes.ValidationType tableValidation
let newXml = XmlTypes.ValidationType {
tableValidation with
AnnotationTable =
AnnotationTable.create
(if newat.Name = "" then prevat.Name else newat.Name)
(if newat.Worksheet = "" then prevat.Worksheet else newat.Worksheet)
}
ReassignCustomXmlRequest (prevXml,newXml) |> SettingsXmlMsg |> dispatch
)
][
text [if isNextValidForWorkbook then Style [Color "white"]] [str "Apply Changes"]
]
let removeTableValidationButton (model:Model) dispatch (tableValidation:ValidationTypes.TableValidation) =
Button.a [
Button.OnClick (fun e ->
let xmlType = XmlTypes.ValidationType tableValidation
let msg = RemoveCustomXmlRequest xmlType |> SettingsXmlMsg
let modalBody = "This function will remove the related checklist xml without chance of recovery. Please safe a copy before clicking 'Continue'."
let nM = {|ModalMessage = modalBody; NextMsg = msg|} |> Some
UpdateWarningModal nM |> dispatch
)
Button.Color IsDanger
][
str "Remove"
]
let displaySingleTableValidationEle (model:Model) dispatch (tableValidation:ValidationTypes.TableValidation) tryFindMap =
let isValidForWorkBook = tryFindInMap tryFindMap tableValidation.AnnotationTable
let isActive = model.SettingsXmlState.ActiveSwateValidation.IsSome && model.SettingsXmlState.ActiveSwateValidation.Value = tableValidation
let isNextValidForWorkbook =
if isActive && model.SettingsXmlState.NextAnnotationTableForActiveValidation.IsSome then
let at = model.SettingsXmlState.NextAnnotationTableForActiveValidation.Value
match at.Name, at.Worksheet with
| "","" ->
let next = AnnotationTable.create tableValidation.AnnotationTable.Name tableValidation.AnnotationTable.Worksheet
tryFindInMap tryFindMap next
| "", newWorksheetName ->
let next = AnnotationTable.create tableValidation.AnnotationTable.Name newWorksheetName
tryFindInMap tryFindMap next
| newAnnotationTableName, "" ->
let next = AnnotationTable.create newAnnotationTableName tableValidation.AnnotationTable.Worksheet
tryFindInMap tryFindMap next
| newAnnotationTableName, newWorksheetName ->
let next = AnnotationTable.create newAnnotationTableName newWorksheetName
tryFindInMap tryFindMap next
else
false
Table.table [
Table.IsFullWidth
Table.IsBordered
Table.IsStriped
][
thead [][
tr [
Style [Cursor "pointer"]
Class "validationTableEle"
OnClick (fun e ->
let next = if isActive then None else Some tableValidation
UpdateActiveSwateValidation next |> SettingsXmlMsg |> dispatch
)
][
th [
Style [if not isValidForWorkBook then Color NFDIColors.Red.Base else Color NFDIColors.Mint.Base]
Title ""
][
if isActive then
Input.text [
if isValidForWorkBook || isNextValidForWorkbook then Input.Color IsSuccess else Input.Color IsDanger
Input.Props [
OnClick (fun e -> e.stopPropagation())
]
Input.DefaultValue tableValidation.AnnotationTable.Name
Input.OnChange (fun e ->
let nextAnnoT =
if model.SettingsXmlState.NextAnnotationTableForActiveValidation.IsSome then
{ model.SettingsXmlState.NextAnnotationTableForActiveValidation.Value with Name = e.Value }
else AnnotationTable.create e.Value ""
|> Some
UpdateNextAnnotationTableForActiveValidation nextAnnoT |> SettingsXmlMsg |> dispatch
)
]
else
str tableValidation.AnnotationTable.Name
]
th [
Style [if not isValidForWorkBook then Color NFDIColors.Red.Base else Color NFDIColors.Mint.Base]
][
if isActive then
Input.text [
if isValidForWorkBook || isNextValidForWorkbook then Input.Color IsSuccess else Input.Color IsDanger
Input.Props [
OnClick (fun e -> e.stopPropagation())
]
Input.DefaultValue tableValidation.AnnotationTable.Worksheet
Input.OnChange (fun e ->
let nextAnnoT =
if model.SettingsXmlState.NextAnnotationTableForActiveValidation.IsSome then
{ model.SettingsXmlState.NextAnnotationTableForActiveValidation.Value with Worksheet = e.Value }
else AnnotationTable.create "" e.Value
|> Some
UpdateNextAnnotationTableForActiveValidation nextAnnoT |> SettingsXmlMsg |> dispatch
)
]
else
str tableValidation.AnnotationTable.Worksheet
]
th [][str tableValidation.SwateVersion]
th [][str ( sprintf "%s %s" (tableValidation.DateTime.ToShortDateString()) (tableValidation.DateTime.ToShortTimeString()) )]
]
]
tbody [Style [
Transition "height 0.25s"
OverflowY OverflowOptions.Hidden
if not isActive then
Height "0px"
Display DisplayOptions.None
]] [
for col in tableValidation.ColumnValidations do
let valFormat = if col.ValidationFormat.IsSome then col.ValidationFormat.Value.toReadableString else "-"
let importance = if col.Importance.IsSome then string col.Importance.Value else "-"
let colAdress = if col.ColumnAdress.IsSome then string col.ColumnAdress.Value else "-"
yield
tr [][
td [][str col.ColumnHeader]
td [][str valFormat]
td [][str importance]
td [][str colAdress]
]
yield
tr [] [
td [ColSpan 4][
Level.level [Level.Level.IsMobile][
Level.left [][
Level.item [][
applyChangesToTableValidationButton model dispatch tableValidation isNextValidForWorkbook
]
]
Level.right [][
Level.item [][
removeTableValidationButton model dispatch tableValidation
]
]
]
]
]
]
]
let showValidationXmlEle (model:Model) dispatch =
let tryFindMap =
model.SettingsXmlState.FoundTables |> Array.map (fun x -> x.Name, x.Worksheet) |> Map.ofArray
div [
Style [
BorderLeft (sprintf "5px solid %s" NFDIColors.Mint.Base)
//BorderRadius "15px 15px 0 0"
Padding "0.25rem 1rem"
MarginBottom "1rem"
]
][
Field.div [][
Help.help [Help.Modifiers [Modifier.TextAlignment (Screen.All,TextAlignment.Justified)]][
str "This block will display all checklist xml for this workbook. You can then remove single elements or assign
them to a new table-sheet combination. Should Swate find any information not related to an existing table-sheet
combination these will be marked in red."
]
]
Field.div [][
Columns.columns [Columns.IsMobile][
Column.column [][
getValidationXmlButton model dispatch
]
if model.SettingsXmlState.ValidationXmls |> Array.isEmpty |> not then
Column.column [Column.Width (Screen.All,Column.IsNarrow)][
removeValidationXmlButton model dispatch
]
]
]
if model.SettingsXmlState.ValidationXmls |> Array.isEmpty |> not then
Field.div [][
for validation in model.SettingsXmlState.ValidationXmls do
yield
displaySingleTableValidationEle model dispatch validation tryFindMap
]
]
// UP: Elements used to display validation/checklist xml
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Down: Elements used to display protocol(-group) xml
let getProtocolGroupXmlButton (model:Model) dispatch =
Button.span [
Button.Color IsInfo
Button.IsFullWidth
Button.OnClick (fun e ->
GetAllProtocolGroupXmlParsedRequest |> SettingsXmlMsg |> dispatch
)
][
str "Load protocol group xml"
]
let removeProtocolGroupXmlButton (model:Model) dispatch =
Button.span [
Button.Color IsDanger
Button.OnClick (fun e ->
UpdateProtocolGroupXmls [||] |> SettingsXmlMsg |> dispatch
)
][
Fa.i [Fa.Solid.Times][]
]
let applyChangesToProtocolGroupButton (model:Model) dispatch (protGroup:GroupTypes.ProtocolGroup) isNextValidForWorkbook =
Button.a [
Button.Color IsWarning
Button.IsStatic (isNextValidForWorkbook |> not)
Button.OnClick (fun e ->
let prevat = protGroup.AnnotationTable
let newat = model.SettingsXmlState.NextAnnotationTableForActiveProtGroup.Value
let prevXml = XmlTypes.GroupType protGroup
let newName = if newat.Name = "" then prevat.Name else newat.Name
let newWorksheet = if newat.Worksheet = "" then prevat.Worksheet else newat.Worksheet
let newXml = XmlTypes.GroupType {
protGroup with
AnnotationTable = AnnotationTable.create newName newWorksheet
Protocols = protGroup.Protocols |> List.map (fun x -> {x with AnnotationTable = AnnotationTable.create newName newWorksheet})
}
ReassignCustomXmlRequest (prevXml,newXml) |> SettingsXmlMsg |> dispatch
)
][
text [if isNextValidForWorkbook then Style [Color "white"]] [str "Apply Changes"]
]
let removeProtocolGroupButton (model:Model) dispatch (protGroup:GroupTypes.ProtocolGroup) =
Button.a [
Button.OnClick (fun e ->
let xmlType = XmlTypes.GroupType protGroup
let msg = RemoveCustomXmlRequest xmlType |> SettingsXmlMsg
let modalBody = "This function will remove the related protocol xml without chance of recovery. Please safe a copy before clicking 'Continue'."
let nM = {|ModalMessage = modalBody; NextMsg = msg|} |> Some
UpdateWarningModal nM |> dispatch
)
Button.Color IsDanger
][
str "Remove"
]
let ativeRowBorder = BorderLeft (sprintf "3px solid %s" NFDIColors.LightBlue.Base)
let protocolChildList (protocol:GroupTypes.Protocol) isActive model dispatch =
[
for bb in protocol.SpannedBuildingBlocks do
yield
tr [if not isActive then Style [Display DisplayOptions.None]][
td [ColSpan 2; Style [ativeRowBorder] ] [ str bb.ColumnName ]
td [ColSpan 2 ] [ str bb.TermAccession ]
td [ ] [ ]
]
yield
tr [if not isActive then Style [Display DisplayOptions.None]][
td [ColSpan 5; Style [ativeRowBorder] ][
Level.level [Level.Level.IsMobile][
Level.left [][
Level.item [][]
]
Level.right [][
Level.item [][
Button.a [
Button.Color IsDanger
Button.OnClick (fun e ->
let xml = XmlTypes.ProtocolType protocol
let msg = RemoveCustomXmlRequest xml |> SettingsXmlMsg
let modalBody = "This function will remove the related protocol xml without chance of recovery. Please safe a copy before clicking 'Continue'."
let nM = {|ModalMessage = modalBody; NextMsg = msg|} |> Some
UpdateWarningModal nM |> dispatch
)
][
str "Remove"
]
]
]
]
]
]
]
let displaySingleProtocolGroupEle model dispatch (protocolGroup:GroupTypes.ProtocolGroup) tryFindMap =
let isValidForWorkBook = tryFindInMap tryFindMap protocolGroup.AnnotationTable
let isActive = model.SettingsXmlState.ActiveProtocolGroup.IsSome && model.SettingsXmlState.ActiveProtocolGroup.Value = protocolGroup
let isNextValidForWorkbook =
if isActive && model.SettingsXmlState.NextAnnotationTableForActiveProtGroup.IsSome then
let at = model.SettingsXmlState.NextAnnotationTableForActiveProtGroup.Value
match at.Name, at.Worksheet with
| "","" ->
let next = AnnotationTable.create protocolGroup.AnnotationTable.Name protocolGroup.AnnotationTable.Worksheet
tryFindInMap tryFindMap next
| "", newWorksheetName ->
let next = AnnotationTable.create protocolGroup.AnnotationTable.Name newWorksheetName
tryFindInMap tryFindMap next
| newAnnotationTableName, "" ->
let next = AnnotationTable.create newAnnotationTableName protocolGroup.AnnotationTable.Worksheet
tryFindInMap tryFindMap next
| newAnnotationTableName, newWorksheetName ->
let next = AnnotationTable.create newAnnotationTableName newWorksheetName
tryFindInMap tryFindMap next
else
false
Table.table [
Table.IsFullWidth
Table.IsBordered
Table.IsStriped
][
thead [][
tr [
Style [Cursor "pointer"]
Class "validationTableEle"
OnClick (fun e ->
let next = if isActive then None else Some protocolGroup
UpdateActiveProtocolGroup next |> SettingsXmlMsg |> dispatch
)
][
th [
Style [if not isValidForWorkBook then Color NFDIColors.Red.Base else Color NFDIColors.Mint.Base]
Title ""
][
if isActive && model.SettingsXmlState.ActiveProtocol.IsNone then
Input.text [
if isValidForWorkBook || isNextValidForWorkbook then Input.Color IsSuccess else Input.Color IsDanger
Input.Props [
OnClick (fun e -> e.stopPropagation())
]
Input.DefaultValue protocolGroup.AnnotationTable.Name
Input.OnChange (fun e ->
let nextAnnoT =
if model.SettingsXmlState.NextAnnotationTableForActiveProtGroup.IsSome then
{ model.SettingsXmlState.NextAnnotationTableForActiveProtGroup.Value with Name = e.Value }
else AnnotationTable.create e.Value ""
|> Some
UpdateNextAnnotationTableForActiveProtGroup nextAnnoT |> SettingsXmlMsg |> dispatch
)
]
else
str protocolGroup.AnnotationTable.Name
]
th [
Style [if not isValidForWorkBook then Color NFDIColors.Red.Base else Color NFDIColors.Mint.Base]
][
if isActive && model.SettingsXmlState.ActiveProtocol.IsNone then
Input.text [
if isValidForWorkBook || isNextValidForWorkbook then Input.Color IsSuccess else Input.Color IsDanger
Input.Props [
OnClick (fun e -> e.stopPropagation())
]
Input.DefaultValue protocolGroup.AnnotationTable.Worksheet
Input.OnChange (fun e ->
let nextAnnoT =
if model.SettingsXmlState.NextAnnotationTableForActiveProtGroup.IsSome then
{ model.SettingsXmlState.NextAnnotationTableForActiveProtGroup.Value with Worksheet = e.Value }
else AnnotationTable.create "" e.Value
|> Some
UpdateNextAnnotationTableForActiveProtGroup nextAnnoT |> SettingsXmlMsg |> dispatch
)
]
else
str protocolGroup.AnnotationTable.Worksheet
]
th [][str protocolGroup.SwateVersion]
th [ColSpan 2] []
]
]
tbody [Style [
if not isActive then
Display DisplayOptions.None
]] [
for protocol in protocolGroup.Protocols do
let isActiveProt = model.SettingsXmlState.ActiveProtocol.IsSome && model.SettingsXmlState.ActiveProtocol.Value = protocol
yield
tr [][
td [if isActiveProt then Style [ativeRowBorder] ][str protocol.Id]
td [][str protocol.AnnotationTable.Name]
td [][str protocol.AnnotationTable.Worksheet]
td [][str protocol.SwateVersion]
td [
Style [
Cursor "Pointer"; Padding "0"
]
][
Button.a [
Button.Color IsInfo
Button.OnClick (fun e ->
let nextProtocol = if isActiveProt then None else Some protocol
UpdateActiveProtocol nextProtocol |> SettingsXmlMsg |> dispatch
)
Button.IsOutlined
Button.IsFullWidth
Button.Props [Style [BorderRadius "0"]]
][
Fa.i [
Fa.Props [Style [Transition "transform 0.4s"]]
if isActiveProt then Fa.Rotate180
Fa.Solid.AngleDown
][]
]
]
]
yield! protocolChildList protocol isActiveProt model dispatch
if model.SettingsXmlState.ActiveProtocol.IsNone then
yield
tr [] [
td [ColSpan 5][
Level.level [Level.Level.IsMobile][
Level.left [][
Level.item [][
applyChangesToProtocolGroupButton model dispatch protocolGroup isNextValidForWorkbook
]
]
Level.right [][
Level.item [][
removeProtocolGroupButton model dispatch protocolGroup
]
]
]
]
]
]
]
let showProtocolGroupXmlEle (model:Model) dispatch =
let tryFindMap =
model.SettingsXmlState.FoundTables |> Array.map (fun x -> x.Name, x.Worksheet) |> Map.ofArray
div [
Style [
BorderLeft (sprintf "5px solid %s" NFDIColors.Mint.Base)
Padding "0.25rem 1rem"
MarginBottom "1rem"
]
][
Field.div [][
Help.help [Help.Modifiers [Modifier.TextAlignment (Screen.All,TextAlignment.Justified)]][
str "This block will display all protocol xml for this workbook. You can then remove single elements or assign
them to a new table-sheet combination. Should Swate find any information not related to an existing table-sheet
combination these will be marked in red."
]
]
Field.div [][
Columns.columns [Columns.IsMobile][
Column.column [][
getProtocolGroupXmlButton model dispatch
]
if model.SettingsXmlState.ProtocolGroupXmls |> Array.isEmpty |> not then
Column.column [Column.Width (Screen.All,Column.IsNarrow)][
removeProtocolGroupXmlButton model dispatch
]
]
]
if model.SettingsXmlState.ProtocolGroupXmls |> Array.isEmpty |> not then
Field.div [][
for protGroup in model.SettingsXmlState.ProtocolGroupXmls do
yield
displaySingleProtocolGroupEle model dispatch protGroup tryFindMap
]
]
let settingsXmlViewComponent (model:Model) dispatch =
form [
OnSubmit (fun e -> e.preventDefault())
// https://keycode.info/
OnKeyDown (fun k -> if k.key = "Enter" then k.preventDefault())
] [
breadcrumbEle dispatch
Help.help [][str "The functions on this page allow more or less direct manipulation of the Xml used to save additional information about your Swate table. Please use them with care."]
Label.label [Label.Props [Style [Color model.SiteStyleState.ColorMode.Accent]]] [str "Display raw custom xml."]
showRawCustomXmlEle model dispatch
Label.label [Label.Props [Style [Color model.SiteStyleState.ColorMode.Accent]]] [str "Handle checklist xml."]
showValidationXmlEle model dispatch
Label.label [Label.Props [Style [Color model.SiteStyleState.ColorMode.Accent]]] [str "Handle protocol group xml."]
showProtocolGroupXmlEle model dispatch
dangerZone model dispatch
]