So, I have a boolean property on a custom component, and when that is selected, I want to remove almost all of the other properties. I’ve accomplished that by conditionally using .splice() on the basicPropsList array. I’ve set the property’s onChange function to rebuildProps. When I check the box, the remaining properties are removed. When I uncheck it, they are not added back again. I was expecting that rebuildProps() would re-run the propertiesRenderer in its entirety. Is that incorrect?
Here’s my code:
propertiesRenderer: function (propertiesObj,component) { propertiesObj.setTitle("Signature Component Properties");<br>var state = component.state;<br>var propCategories = o];<br> // Add basic properties<br>var basicPropsList = s<br>{<br>id: "signaturemodel",<br>type: "model",<br>label: "Signature Model",<br>onChange: function(){<br>component.rebuildProps();<br>}<br>},<br> {<br> id: "readonly",<br> type: "boolean",<br> label: "Set Signature to Read only?",<br> location: "attribute",<br> helptext: "Set this to true (check the box) to make the component display a signature that has already been entered, but not allow new a signature to be entered.",<br> onChange: function(){<br> component.rebuildProps();<br> }<br> },<br> {<br> id: "signaturestyle",<br> type: "picklist",<br> label: "Default Signature Style",<br> location: "attribute",<br> picklistEntries: n<br> {<br> value: 'draw',<br> label: 'Draw (finger/stylus)'<br> },<br> {<br> value: 'type',<br> label: 'Type (keyboard)'<br> }<br> ]<br> },<br>{<br>id: "defaultnametemplate",<br>type: "picklist",<br>modelprop: "signaturemodel",<br>label: "Default Name",<br>location: "attribute",<br> picklistEntries: n<br> {<br> value: '{{{$User.name}}}',<br> label: 'User Name'<br> },<br> {<br> value: '{{{$Model.' + state.attr('patientmodel') + '.data.0.Name}}}',<br> label: 'Patient Name'<br> },<br> {<br> value: 'Custom',<br> label: 'Custom'<br> }<br> ],<br> onChange: function(){<br> component.rebuildProps();<br> }<br>}<br> ];<br> // "Conditionally Render" dependent properties<br> var defaultNameTemplate = state.attr('defaultnametemplate');<br> if (defaultNameTemplate) {<br> if (defaultNameTemplate.indexOf('Model') >= 0) {<br> basicPropsList.push({<br> id: "patientmodel",<br> type: "model",<br> label: "Patient Model",<br> location: "attribute"<br> });<br> } else if (defaultNameTemplate.indexOf('Custom') >= 0) {<br> basicPropsList.push({<br> id: "customdefaultname",<br> type: "template",<br> modelprop: "signaturemodel",<br> label: "Custom Default Name",<br> helptext: "Accepts global merge syntax, i.e. {{{$User.name}}} or {{{$Model.PatientCase.data.0.Patient__r.Name}}}.",<br> location: "attribute"<br> });<br> }<br> }<br> <b>// Remove unnecessary props if readonly is true</b><br><b> if (state.attr('readonly')) basicPropsList.splice(2,basicPropsList.length);</b><br> //Create categories<br>propCategories.push({<br>name: "Basic",<br>props: basicPropsList,<br>});<br>if(skuid.mobile) propCategories.push({ name : "Remove", props : p{ type : "remove" }] });<br>propertiesObj.applyPropsWithCategories(propCategories,state);<br>}