Index: openacs-4/packages/xowiki/tcl/includelet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/includelet-procs.tcl,v diff -u -r1.239.2.5 -r1.239.2.6 --- openacs-4/packages/xowiki/tcl/includelet-procs.tcl 10 Mar 2019 21:12:28 -0000 1.239.2.5 +++ openacs-4/packages/xowiki/tcl/includelet-procs.tcl 22 Mar 2019 13:16:42 -0000 1.239.2.6 @@ -4010,16 +4010,16 @@ -html {style "padding: 2px;text-align: center;"}} \n } if {[info exists use_button(edit)]} { - append cols {AnchorField create _edit -CSSclass edit-item-button -label "" \ + append cols {AnchorField create _edit -CSSclass edit-item-button -label "" \ -html {style "padding: 2px;"} -no_csv 1 -richtext 1} \n } if {[info exists use_button(view)]} { - append cols {AnchorField create _view -CSSclass view-item-button -label "" \ + append cols {AnchorField create _view -CSSclass view-item-button -label "" \ -html {style "padding: 2px;"} -no_csv 1 -richtext 1} \n } foreach fn $field_names { if {[info exists __hidden($fn)]} continue - append cols [list AnchorField create $fn \ + append cols [list AnchorField create $fn \ -label [$__ff($fn) label] \ -richtext 1 \ -orderby $fn \ Index: openacs-4/packages/xowiki/tcl/repeat-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/repeat-procs.tcl,v diff -u -r1.14 -r1.14.2.1 --- openacs-4/packages/xowiki/tcl/repeat-procs.tcl 10 Apr 2018 06:52:09 -0000 1.14 +++ openacs-4/packages/xowiki/tcl/repeat-procs.tcl 22 Mar 2019 13:16:42 -0000 1.14.2.1 @@ -218,7 +218,7 @@ # html::fieldset [:get_attributes id {CSSclass class}] { set i 0 - set clientData "{'min':${:min},'max':${:max}, 'name':'${:name}'}" + set clientData [subst {{"min":${:min},"max":${:max}, "name":"${:name}"}}] set CSSclass "[:form_widget_CSSclass] repeatable" set providedValues [:count_values [:value]] if {${:min} > $providedValues} { @@ -237,8 +237,11 @@ lappend atts style "display: none;" } ::html::div $atts { - $c render_input - # compound fields - link not shown if we are not rendering for the template and copy the template afterwards + $c render_input + # + # Compound fields - link not shown if we are not rendering + # for the template and copy the template afterwards. + # if {!$containerIsDisabled || $containerIsPrototype} { set del_id "repeat-del-link-[$c set id]" ::html::a -href "#" \ @@ -248,7 +251,7 @@ } template::add_event_listener \ -id $del_id \ - -script [subst {xowiki.repeat.delItem(this,\"$clientData\");}] + -script [subst {xowiki.repeat.delItem(this,'$clientData');}] } } incr i @@ -257,7 +260,7 @@ if {!$containerIsDisabled || $containerIsPrototype } { set hidden [expr {[:count_values [:value]] == ${:max} ? "display: none;" : ""}] set add_id "repeat-add-link-[:id]" - ns_log notice "... add another for ${:name}" + #ns_log notice "... add another for ${:name}" html::a -href "#" \ -id $add_id \ -style $hidden \ @@ -266,7 +269,7 @@ } template::add_event_listener \ -id $add_id \ - -script [subst {xowiki.repeat.newItem(this,\"$clientData\");}] + -script [subst {xowiki.repeat.newItem(this,'$clientData');}] } } } @@ -299,13 +302,30 @@ } repeatContainer instproc value_if_nothing_is_returned_from_form {default} { + # # Here we have to distinguish between two cases to: # - edit mode: somebody has removed a mark from a check button; # this means: clear the field # - view mode: the fields were deactivated (made insensitive); # this means: keep the old value - - if {[info exists :disabled]} {return $default} else {return ""} + # + #ns_log notice "=== repeatContainer value_if_nothing_is_returned_from_form <$default>" + set result "" + if {![info exists :disabled]} { + # + # Leave the first entry (template on position "0") untouched + # + set result [lrange $default 0 1] + # + # Return values from the included components + # + set l [:count_values $default] + foreach c [lrange ${:components} 1 $l] d [lrange $default 1 $l] { + lappend result [$c name] [$c value_if_nothing_is_returned_from_form $d] + } + #ns_log notice "=== repeatContainer computes $result" + } + return $result } Class create repeattest -superclass CompoundField Index: openacs-4/packages/xowiki/www/resources/repeat.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/www/resources/repeat.js,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/xowiki/www/resources/repeat.js 7 Aug 2017 23:48:31 -0000 1.4 +++ openacs-4/packages/xowiki/www/resources/repeat.js 22 Mar 2019 13:16:42 -0000 1.4.2.1 @@ -8,7 +8,8 @@ * this function just invisible items visible. */ xowiki.repeat.addItem = function(e, json) { - var data = eval("(" + json + ')'); + //var data = eval("(" + json + ')'); + var data = JSON.parse(json); var items = $(e.parentNode).children(".repeatable:hidden"); var currentItem = ''; // the loop starts with 1 because items[0] is the template @@ -66,7 +67,7 @@ */ xowiki.repeat.newItem = function(e, json) { - var data = eval("(" + json + ')'); + var data = JSON.parse(json); var item = e; var stats = this.itemStats(item); @@ -258,7 +259,8 @@ // Replace the ID in the name compontent inside the json // structure. // - var data = eval("(" + data_repeat_attribute + ')'); + var data = JSON.parse(data_repeat_attribute); + var compareLength = from.length; if (data.name.substring(0,compareLength) == from) { var new_name = to + data.name.substring(compareLength,data.name.length); @@ -282,7 +284,8 @@ * the fields. */ xowiki.repeat.delItem = function(e, json) { - var data = eval("(" + json + ')'); + + var data = JSON.parse(json); var item = e.parentNode; var stats = this.itemStats(item); //console.info(item);