diff --git a/app/qml/form/components/photo/MMPhotoAttachment.qml b/app/qml/form/components/photo/MMPhotoAttachment.qml index 73e57ffbb..c5ecd8f2d 100644 --- a/app/qml/form/components/photo/MMPhotoAttachment.qml +++ b/app/qml/form/components/photo/MMPhotoAttachment.qml @@ -58,6 +58,8 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideMiddle + + visible: root.enabled } } @@ -95,6 +97,8 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideMiddle + + visible: root.enabled } } diff --git a/app/qml/form/editors/MMFormPhotoEditor.qml b/app/qml/form/editors/MMFormPhotoEditor.qml index 3b99f42ba..12af68b94 100644 --- a/app/qml/form/editors/MMFormPhotoEditor.qml +++ b/app/qml/form/editors/MMFormPhotoEditor.qml @@ -88,7 +88,8 @@ MMFormPhotoViewer { photoUrl: internal.absoluteImagePath hasCameraCapability: __androidUtils.isAndroid || __iosUtils.isIos - on_FieldValueChanged: internal.calculateAbsoluteImagePath() + on_FieldValueChanged: internal.setAbsoluteImagePath() + on_FieldValueIsNullChanged: internal.setAbsoluteImagePath() onCapturePhotoClicked: internal.capturePhoto() onChooseFromGalleryClicked: internal.chooseFromGallery() @@ -200,27 +201,25 @@ MMFormPhotoViewer { property string imageSourceToDelete // used to postpone image deletion to when the form is saved - function calculateAbsoluteImagePath() { + // + // Sets path of the assigned photo to the absoluteImagePath. + // - absoluteImagePath is the actual path on the device and is used by QML Image to show the image + // + function setAbsoluteImagePath() { let absolutePath = __inputUtils.getAbsolutePath( root._fieldValue, internal.prefixToRelativePath ) - if ( root.photoComponent.status === Image.Error ) { - root.photoState = "notAvailable" + if ( !root._fieldValue || root._fieldValueIsNull ) { + root.photoState = "notSet" absoluteImagePath = "" - return } else if ( root._fieldValue && __inputUtils.fileExists( absolutePath ) ) { root.photoState = "valid" absoluteImagePath = "file://" + absolutePath - return } - else if ( !root._fieldValue || root._fieldValueIsNullfield ) { - root.photoState = "notSet" + else { + root.photoState = "notAvailable" absoluteImagePath = "" - return } - - root.photoState = "notAvailable" - absoluteImagePath = "file://" + absolutePath } /**