@@ -41,38 +41,38 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
41
41
info <- template_info()
42
42
43
43
if (" tab_editor" %in% menu_tabs()){
44
- removeTab(inputId = " tabbox " ,
44
+ removeTab(inputId = " tabbox_data_editor " ,
45
45
session = parent.session ,
46
46
target = " tab_editor" )
47
47
}
48
48
49
49
tabs_list <- unique(c(menu_tabs()," tab_editor" ))
50
50
menu_tabs <- menu_tabs(tabs_list )
51
51
52
- appendTab(inputId = " tabbox " ,
52
+ appendTab(inputId = " tabbox_data_editor " ,
53
53
session = parent.session ,
54
54
select = TRUE ,
55
55
tabPanel(title = tagList(icon(" edit" )," Editor" ),
56
56
value = " tab_editor" ,
57
57
uiOutput(ns(" buttons_wrapper" )),
58
58
br(),
59
- uiOutput(ns(" table_wrapper " ))
59
+ uiOutput(ns(" hst_table_wrapper " ))
60
60
61
61
)
62
62
)
63
63
64
64
if (any(! is.na(info $ ref ))){
65
65
66
66
if (" tab_referentials" %in% menu_tabs()){
67
- removeTab(inputId = " tabbox " ,
67
+ removeTab(inputId = " tabbox_data_editor " ,
68
68
session = parent.session ,
69
69
target = " tab_referentials" )
70
70
}
71
71
72
72
tabs_list <- unique(c(menu_tabs()," tab_referentials" ))
73
73
menu_tabs <- menu_tabs(tabs_list )
74
74
75
- appendTab(inputId = " tabbox " ,
75
+ appendTab(inputId = " tabbox_data_editor " ,
76
76
session = parent.session ,
77
77
select = FALSE ,
78
78
tabPanel(title = tagList(icon(" search" )," Referentials" ),
@@ -86,15 +86,15 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
86
86
}
87
87
88
88
if (" tab_templates" %in% menu_tabs()){
89
- removeTab(inputId = " tabbox " ,
89
+ removeTab(inputId = " tabbox_data_editor " ,
90
90
session = parent.session ,
91
91
target = " tab_templates" )
92
92
}
93
93
94
94
tabs_list <- unique(c(menu_tabs()," tab_templates" ))
95
95
menu_tabs <- menu_tabs(tabs_list )
96
96
97
- appendTab(inputId = " tabbox " ,
97
+ appendTab(inputId = " tabbox_data_editor " ,
98
98
session = parent.session ,
99
99
select = FALSE ,
100
100
tabPanel(title = tagList(icon(" download" )," Templates" ),
@@ -263,7 +263,7 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
263
263
264
264
observeEvent(input $ new_data ,{
265
265
req(input $ new_data )
266
- ready <- ready(TRUE )
266
+ ready <- ready(TRUE )
267
267
})
268
268
269
269
observeEvent(input $ import_data ,{
@@ -321,7 +321,7 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
321
321
req(input $ format )
322
322
if (! is.null(input $ task ))if (input $ task != " " )if (! is.null(input $ reporting_entity ))if (input $ reporting_entity != " " )if (! is.null(input $ format ))if (input $ format != " " ){
323
323
reset <- FALSE
324
- if (! is.null(input $ table )){
324
+ if (! is.null(input $ hst_table )){
325
325
reset <- TRUE
326
326
showModal(
327
327
modalDialog(
@@ -362,7 +362,7 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
362
362
data_template [1 ,]<- values_type
363
363
364
364
empty_row <- empty_row(data_template )
365
- cache_data <- cache_data(data_template [rep(seq_len(nrow(data_template )), 10 ), ])
365
+ cache_data <- cache_data(data_template [rep(seq_len(nrow(data_template )), 5 ), ])
366
366
})
367
367
}
368
368
})
@@ -408,7 +408,7 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
408
408
data_template [1 ,]<- values_type
409
409
410
410
empty_row <- empty_row(data_template )
411
- cache_data <- cache_data (data_template [rep(seq_len(nrow(data_template )), 10 ), ])
411
+ cache_data(data_template [rep(seq_len(nrow(data_template )), 10 ), ])
412
412
})
413
413
}
414
414
})
@@ -498,13 +498,13 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
498
498
sprintf(" data_%s_%s_%s.csv" ,input $ task ,input $ reporting_entity ,input $ format )
499
499
},
500
500
content = function (filename ) {
501
- data_to_save <- hot_to_r(input $ table )
501
+ data_to_save <- hot_to_r(input $ hst_table )
502
502
data_to_save <- as.data.frame(data_to_save )
503
503
data_to_load <- data_spec()$ standardizeContent(data_to_save )
504
504
write.csv(data_to_save , filename ,row.names = F )
505
505
})
506
506
507
- output $ table <- renderRHandsontable({
507
+ output $ hst_table <- rhandsontable :: renderRHandsontable({
508
508
req(! is.null(cache_data()))
509
509
req(ready())
510
510
@@ -542,9 +542,11 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
542
542
cache_report <- cache_report(report )
543
543
544
544
# display
545
- editable_table <- data_spec()$ display_as_handsontable(data , report , read_only = FALSE ) %> %
545
+ editable_table <- data_spec()$ display_as_handsontable(data , as.data.frame( report ) , read_only = FALSE ) %> %
546
546
hot_context_menu(allowRowEdit = T , allowColEdit = F )
547
547
548
+ editable_table
549
+
548
550
# column that should not be editable --> put them as readonly
549
551
info <- template_info()
550
552
if (any(! info $ editable )){
@@ -565,24 +567,24 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
565
567
}
566
568
}
567
569
568
- return ( editable_table )
570
+ editable_table
569
571
})
570
572
571
573
572
574
# observe changes on handsontable
573
- observeEvent(input $ table $ changes $ changes ,{
575
+ observeEvent(input $ hst_table $ changes $ changes ,{
574
576
WARN(" Triggered handsontable cell event on render" )
575
- target_cell_row = input $ table $ changes $ changes [[1 ]][[1 ]]+ 1
576
- target_cell_col = input $ table $ changes $ changes [[1 ]][[2 ]]+ 1
577
- target_cell_value_old = input $ table $ changes $ changes [[1 ]][[3 ]]
577
+ target_cell_row = input $ hst_table $ changes $ changes [[1 ]][[1 ]]+ 1
578
+ target_cell_col = input $ hst_table $ changes $ changes [[1 ]][[2 ]]+ 1
579
+ target_cell_value_old = input $ hst_table $ changes $ changes [[1 ]][[3 ]]
578
580
if (is.null(target_cell_value_old )) target_cell_value_old = " "
579
- target_cell_value_new = input $ table $ changes $ changes [[1 ]][[4 ]]
581
+ target_cell_value_new = input $ hst_table $ changes $ changes [[1 ]][[4 ]]
580
582
if (is.null(target_cell_value_new )) target_cell_value_new = " "
581
583
if (target_cell_value_old != target_cell_value_new ){
582
584
WARN(" Changed row = %s" , target_cell_row )
583
585
WARN(" Changed col = %s" , target_cell_col )
584
586
WARN(" Value '%s' changed by '%s'" , target_cell_value_old , target_cell_value_new )
585
- updated_hst = hot_to_r(input $ table ) %> % as.data.frame()
587
+ updated_hst = hot_to_r(input $ hst_table ) %> % as.data.frame()
586
588
587
589
WARN(" Caching data..." )
588
590
WARN(" Old data cell content:" )
@@ -595,13 +597,13 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
595
597
}
596
598
})
597
599
598
- output $ table_wrapper <- renderUI({
600
+ output $ hst_table_wrapper <- renderUI({
599
601
req(! is.null(cache_data()))
600
602
req(ready())
601
603
info <- template_info()
602
604
div(
603
605
div(
604
- rHandsontableOutput(ns(" table " ))
606
+ rhandsontable :: rHandsontableOutput(ns(" hst_table " ))
605
607
),
606
608
br(),
607
609
div(
@@ -653,7 +655,7 @@ data_entry_editor_server <- function(id, parent.session, config, profile, compon
653
655
new_row <- empty_row()
654
656
for (i in 1 : input $ nb_add_row ){
655
657
if (i == 1 ){
656
- last_data <- hot_to_r(input $ table )
658
+ last_data <- hot_to_r(input $ hst_table )
657
659
}else {
658
660
last_data <- new_data
659
661
}
0 commit comments