We add a component to the SectionHeader of the SectionItem in DynamicForm. This was working well in SmartClient 12.1 but is broken in 13.0.
It can be easily reproduced in the Feature Explorer (showcase), by adding a canvasProperties, as follows:
/*
* Fails in: https://smartclient.com/smartclient-...d=formSections
* Works in: https://smartclient.com/smartclient-...d=formSections
*
*/
//BEGIN SectionItem bug sample
isc.DynamicForm.create({
width: 350,
titleWidth:120,
fields: [
{ defaultValue:"Item", type:"section", sectionExpanded:true,
itemIds: ["itemName", "description", "price"]
// Add a SectionHeader control: works in 12.1 but not in 13.0
,canvasProperties: { controls: isc.IButton.create({title: "X", autoFit: true})}
},
{ name:"itemName", type:"text", title:"Item"},
{ name:"description", type:"textArea", title:"Description"},
{ name:"price", type:"float", title:"Price", defaultValue:"low"},
{ defaultValue:"Stock", type:"section", sectionExpanded:false,
itemIds: ["inStock", "nextShipment"]
},
{ name:"inStock", type:"checkbox", title:"In Stock" },
{ name:"nextShipment", type:"date", title:"Next Shipment", useTextField:true, wrapTitle:false}
]
});
//END SectionItem bug sample
We have tracked the problem down, and propose a fix below. The !isc.isA.SectionStack(stack) check is too restrictive. It prevents a SectionHeader within a SectionItem from seeing the controls. This is only a quick fix which works for us so far. I have not done an investigation of all the SectionStack, SectionHeader changes made in SmartClient 13.
version v13.0p_2023-11-20, ISC_Foundation.js, line 24896
addControls : function () {
var stack = this.getSectionStack();
// Section headers may be created without an associated section stack
// In this case we can't invoke createSectionControls()
/* START Replace (by DaveC)
if (stack == null || !isc.isA.SectionStack(stack)) {
return;
}
var controls = stack.createSectionControls(this);
with */
var controls;
if (stack == null || !isc.isA.SectionStack(stack)) {
controls = this.controls;
if (controls && !isc.isAn.Array(controls)) controls = [controls];
} else {
controls = stack.createSectionControls(this);
}
/* END Replace */
if (controls == null || controls.length == 0) return;
var isRTL = this.isRTL();
var controlsSnapTo = this.getControlsSnapTo();
this.addAutoChild("controlsLayout", {
height:this.getInnerHeight(),
align:isRTL ? "left" : "right",
snapTo:controlsSnapTo,
members: controls,
resized : function () {
var label = this.creator,
background = this.creator.background;
if (background != null) label = background.label;
label.markForRedraw();
}
});
this.allowContentAndChildren = true;
},
Many thanks
It can be easily reproduced in the Feature Explorer (showcase), by adding a canvasProperties, as follows:
/*
* Fails in: https://smartclient.com/smartclient-...d=formSections
* Works in: https://smartclient.com/smartclient-...d=formSections
*
*/
//BEGIN SectionItem bug sample
isc.DynamicForm.create({
width: 350,
titleWidth:120,
fields: [
{ defaultValue:"Item", type:"section", sectionExpanded:true,
itemIds: ["itemName", "description", "price"]
// Add a SectionHeader control: works in 12.1 but not in 13.0
,canvasProperties: { controls: isc.IButton.create({title: "X", autoFit: true})}
},
{ name:"itemName", type:"text", title:"Item"},
{ name:"description", type:"textArea", title:"Description"},
{ name:"price", type:"float", title:"Price", defaultValue:"low"},
{ defaultValue:"Stock", type:"section", sectionExpanded:false,
itemIds: ["inStock", "nextShipment"]
},
{ name:"inStock", type:"checkbox", title:"In Stock" },
{ name:"nextShipment", type:"date", title:"Next Shipment", useTextField:true, wrapTitle:false}
]
});
//END SectionItem bug sample
We have tracked the problem down, and propose a fix below. The !isc.isA.SectionStack(stack) check is too restrictive. It prevents a SectionHeader within a SectionItem from seeing the controls. This is only a quick fix which works for us so far. I have not done an investigation of all the SectionStack, SectionHeader changes made in SmartClient 13.
version v13.0p_2023-11-20, ISC_Foundation.js, line 24896
addControls : function () {
var stack = this.getSectionStack();
// Section headers may be created without an associated section stack
// In this case we can't invoke createSectionControls()
/* START Replace (by DaveC)
if (stack == null || !isc.isA.SectionStack(stack)) {
return;
}
var controls = stack.createSectionControls(this);
with */
var controls;
if (stack == null || !isc.isA.SectionStack(stack)) {
controls = this.controls;
if (controls && !isc.isAn.Array(controls)) controls = [controls];
} else {
controls = stack.createSectionControls(this);
}
/* END Replace */
if (controls == null || controls.length == 0) return;
var isRTL = this.isRTL();
var controlsSnapTo = this.getControlsSnapTo();
this.addAutoChild("controlsLayout", {
height:this.getInnerHeight(),
align:isRTL ? "left" : "right",
snapTo:controlsSnapTo,
members: controls,
resized : function () {
var label = this.creator,
background = this.creator.background;
if (background != null) label = background.label;
label.markForRedraw();
}
});
this.allowContentAndChildren = true;
},
Many thanks
Comment