Merge pull request #7094 from artoscinote/ma_SCI_10224

Modal code cleanup [SCI-10224]
This commit is contained in:
Martin Artnik 2024-02-15 14:11:58 +01:00 committed by GitHub
commit 090f42c36b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 27 additions and 42 deletions

View file

@ -55,11 +55,11 @@
<NoPredefinedAppModal
v-if="showNoPredefinedAppModal"
:fileName="attachment.attributes.file_name"
@confirm="showNoPredefinedAppModal = false"
@close="showNoPredefinedAppModal = false"
/>
<UpdateVersionModal
v-if="showUpdateVersionModal"
@cancel="showUpdateVersionModal = false"
@close="showUpdateVersionModal = false"
/>
<editLaunchingApplicationModal
v-if="editAppModal"

View file

@ -57,6 +57,8 @@ export default {
this.localAppName = response.data.application;
}
} catch (error) {
if (error.response?.status === 404) return; // all good, no app was found for the file
console.error('Error in request: ', error);
}
},
@ -107,7 +109,7 @@ export default {
clearInterval(this.pollingInterval);
this.pollingInterval = null;
}
}
}
}
}

View file

@ -28,7 +28,7 @@
<NoPredefinedAppModal
v-if="showNoPredefinedAppModal"
:fileName="attachment.attributes.file_name"
@confirm="showNoPredefinedAppModal = false"
@close="showNoPredefinedAppModal = false"
/>
<editLaunchingApplicationModal
v-if="editAppModal"
@ -38,7 +38,7 @@
/>
<UpdateVersionModal
v-if="showUpdateVersionModal"
@cancel="showUpdateVersionModal = false"
@close="showUpdateVersionModal = false"
/>
</Teleport>
</div>

View file

@ -145,11 +145,17 @@
<NoPredefinedAppModal
v-if="showNoPredefinedAppModal"
:fileName="attachment.attributes.file_name"
@confirm="showNoPredefinedAppModal = false"
@close="showNoPredefinedAppModal = false"
/>
<UpdateVersionModal
v-if="showUpdateVersionModal"
@cancel="showUpdateVersionModal = false"
@close="showUpdateVersionModal = false"
/>
<editLaunchingApplicationModal
v-if="editAppModal"
:fileName="attachment.attributes.file_name"
:application="this.localAppName"
@close="editAppModal = false"
/>
</Teleport>
<a class="image-edit-button hidden"

View file

@ -14,7 +14,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-secondary" @click="cancel">{{ i18n.t('general.cancel') }}</button>
<button class="btn btn-secondary" @click="close">{{ i18n.t('general.cancel') }}</button>
<button class="btn btn-danger" @click="confirm">{{ i18n.t('protocols.steps.modals.delete_element.confirm')}}</button>
</div>
</div>
@ -22,21 +22,15 @@
</div>
</template>
<script>
import modalMixin from '../../modal_mixin';
export default {
name: 'deleteElementModal',
mounted() {
$(this.$refs.modal).modal('show');
$(this.$refs.modal).on('hidden.bs.modal', () => {
this.$emit('cancel');
});
},
mixins: [modalMixin],
methods: {
confirm() {
$(this.$refs.modal).modal('hide');
this.$emit('confirm');
},
cancel() {
$(this.$refs.modal).modal('hide');
this.$nextTick(() => this.close);
}
}
};

View file

@ -12,7 +12,7 @@
<p v-html="i18n.t('assets.no_predefined_app_modal.body_text_html', { file_name: fileName })"></p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" @click="confirm">{{ this.i18n.t('assets.no_predefined_app_modal.understand_button') }}</button>
<button class="btn btn-primary" @click="close">{{ this.i18n.t('assets.no_predefined_app_modal.understand_button') }}</button>
</div>
</div>
</div>
@ -20,21 +20,13 @@
</template>
<script>
import modalMixin from '../../modal_mixin';
export default {
name: 'NoPredefinedAppModal',
mixins: [modalMixin],
props: {
fileName: String
},
mounted() {
$(this.$refs.modal).modal('show');
$(this.$refs.modal).on('hidden.bs.modal', () => {
this.$emit('confirm');
});
},
methods: {
confirm() {
$(this.$refs.modal).modal('hide');
}
}
};
</script>

View file

@ -12,7 +12,7 @@
<p v-html="i18n.t('assets.update_version_modal.body_text_html')"></p>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" @click="cancel">{{ i18n.t('general.cancel') }}</button>
<button class="btn btn-secondary" @click="close">{{ i18n.t('general.cancel') }}</button>
<ScinoteEditDownload
:data="userAgent"
:isUpdateVersionModal="true"
@ -25,12 +25,14 @@
<script>
import ScinoteEditDownload from '../../../../vue/shared/scinote_edit_download.vue';
import modalMixin from '../../modal_mixin';
export default {
name: 'UpdateVersionModal',
components: {
ScinoteEditDownload
},
mixins: [modalMixin],
props: {
fileName: String
},
@ -38,17 +40,6 @@ export default {
userAgent() {
return window.navigator.userAgent;
}
},
mounted() {
$(this.$refs.modal).modal('show');
$(this.$refs.modal).on('hidden.bs.modal', () => {
this.$emit('cancel');
});
},
methods: {
cancel() {
$(this.$refs.modal).modal('hide');
}
}
};
</script>