Disable closing modal during photo upload

This commit is contained in:
2026-04-24 12:24:19 +01:00
parent b4a70233cf
commit 73ad5b4eb1
4 changed files with 32 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ export default class Modal extends Component {
@action
close() {
if (this.args.disableClose) return;
if (this.args.onClose) {
this.args.onClose();
}
@@ -31,10 +32,11 @@ export default class Modal extends Component {
>
<button
type="button"
class="close-modal-btn btn-text"
class="close-modal-btn btn-text {{if @disableClose 'disabled'}}"
disabled={{@disableClose}}
{{on "click" this.close}}
>
<Icon @name="x" @size={{24}} />
<Icon @name="x" @size={{24}} @color="currentColor" />
</button>
{{yield}}
</div>

View File

@@ -27,6 +27,12 @@ export default class PlaceDetails extends Component {
@tracked isPhotoUploadModalOpen = false;
@tracked isNostrConnectModalOpen = false;
@tracked newlyUploadedPhotoId = null;
@tracked isPhotoUploadActive = false;
@action
handleUploadStateChange(isActive) {
this.isPhotoUploadActive = isActive;
}
@action
openPhotoUploadModal(e) {
@@ -42,6 +48,7 @@ export default class PlaceDetails extends Component {
@action
closePhotoUploadModal(eventId) {
if (this.isPhotoUploadActive) return;
this.isPhotoUploadModalOpen = false;
if (typeof eventId === 'string') {
this.newlyUploadedPhotoId = eventId;
@@ -585,10 +592,14 @@ export default class PlaceDetails extends Component {
</div>
{{#if this.isPhotoUploadModalOpen}}
<Modal @onClose={{this.closePhotoUploadModal}}>
<Modal
@onClose={{this.closePhotoUploadModal}}
@disableClose={{this.isPhotoUploadActive}}
>
<PlacePhotoUpload
@place={{this.saveablePlace}}
@onClose={{this.closePhotoUploadModal}}
@onUploadStateChange={{this.handleUploadStateChange}}
/>
</Modal>
{{/if}}

View File

@@ -77,6 +77,9 @@ export default class PlacePhotoUpload extends Component {
}
this.file = file;
this.uploadedPhoto = null;
if (this.args.onUploadStateChange) {
this.args.onUploadStateChange(true);
}
}
@action
@@ -91,6 +94,9 @@ export default class PlacePhotoUpload extends Component {
}
this.file = null;
this.uploadedPhoto = null;
if (this.args.onUploadStateChange) {
this.args.onUploadStateChange(false);
}
}
deletePhotoTask = task(async (photoData) => {
@@ -191,6 +197,10 @@ export default class PlacePhotoUpload extends Component {
this.file = null;
this.uploadedPhoto = null;
if (this.args.onUploadStateChange) {
this.args.onUploadStateChange(false);
}
if (this.args.onClose) {
this.args.onClose(event.id);
}