Fixing issue with Repeater refusing to use ES classes as values.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adsooi 2025-04-22 05:08:19 +02:00
parent 04e070058e
commit 5586f0c214
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
4 changed files with 14 additions and 7 deletions

View file

@ -41,6 +41,12 @@ Repeater {
Object whose properties to list and edit.
*/
property var obj
/*!
\qmlproperty var CustomPropertyList::objPropertyTypes
Record containing the properties types of the object mapped by their name.
*/
property var objPropertyTypes
/*!
\qmlproperty var CustomPropertyList::positionPicker
Reference to the global PositionPicker QML object.
@ -280,15 +286,15 @@ Repeater {
Loader {
id: propertyEditor
width: dlgProperties.width - pointerButton.width
property string propertyName: modelData[0]
property var propertyType: modelData[1]
property string propertyName: modelData
property var propertyType: objPropertyTypes[modelData]
property string propertyLabel: qsTranslate('prop',propertyName)
property string propertyIcon: propertyName
sourceComponent: {
if(propertyName.startsWith('comment'))
return commentComponent
else if(propertyType == 'boolean')
else if(propertyType === 'boolean')
return checkboxComponent
else if(paramTypeIn(propertyType, ['Expression']))
return expressionEditorComponent

View file

@ -164,8 +164,9 @@ Popup.BaseDialog {
*/
function open() {
dlgCustomProperties.model = [] // Reset
let objProps = Modules.Objects.types[objEditor.objType].properties()
dlgCustomProperties.model = Object.keys(objProps).map(prop => [prop, objProps[prop]]) // Converted to 2-dimentional array.
const objProps = Modules.Objects.types[objEditor.objType].properties()
dlgCustomProperties.objPropertyTypes = objProps
dlgCustomProperties.model = Object.keys(objProps)
objEditor.show()
}
}

View file

@ -140,7 +140,7 @@ ScrollView {
*/
function paramTypeIn(parameter, types = []) {
if(types.includes(parameter.toString())) return true
if(typeof parameter == 'object' && 'type' in parameter)
if(typeof parameter === 'object' && 'type' in parameter)
return types.includes(parameter.type)
return false
}