|  | 
|  | 1 | +<template> | 
|  | 2 | +	<DialogBody :is-loading="isLoading"> | 
|  | 3 | +		<div | 
|  | 4 | +			v-strip-unsafe-html=" | 
|  | 5 | +				t('manager.contributorRoles.alert.delete.message.body', { | 
|  | 6 | +					identifier: contributorRoleIdentifier, | 
|  | 7 | +				}) | 
|  | 8 | +			" | 
|  | 9 | +		></div> | 
|  | 10 | + | 
|  | 11 | +		<FieldText | 
|  | 12 | +			class="mt-8" | 
|  | 13 | +			size="large" | 
|  | 14 | +			:value="inputValue" | 
|  | 15 | +			@input="inputValue = $event.target.value" | 
|  | 16 | +		/> | 
|  | 17 | +		<template #actions> | 
|  | 18 | +			<PkpButton | 
|  | 19 | +				:disabled="inputValue !== contributorRoleIdentifier" | 
|  | 20 | +				is-primary | 
|  | 21 | +				@click="confirmInput" | 
|  | 22 | +			> | 
|  | 23 | +				{{ t('common.confirmDelete') }} | 
|  | 24 | +			</PkpButton> | 
|  | 25 | +			<PkpButton :is-warnable="true" @click="closeModal"> | 
|  | 26 | +				{{ t('common.cancel') }} | 
|  | 27 | +			</PkpButton> | 
|  | 28 | +		</template> | 
|  | 29 | +	</DialogBody> | 
|  | 30 | +</template> | 
|  | 31 | + | 
|  | 32 | +<script setup> | 
|  | 33 | +import PkpButton from '@/components/Button/Button.vue'; | 
|  | 34 | +import DialogBody from '@/components/Modal/DialogBody.vue'; | 
|  | 35 | +import FieldText from '@/components/Form/fields/FieldText.vue'; | 
|  | 36 | +import {useLocalize} from '@/composables/useLocalize'; | 
|  | 37 | +import {ref} from 'vue'; | 
|  | 38 | +
 | 
|  | 39 | +const {t} = useLocalize(); | 
|  | 40 | +
 | 
|  | 41 | +const inputValue = ref(''); | 
|  | 42 | +const isLoading = ref(false); | 
|  | 43 | +const props = defineProps({ | 
|  | 44 | +	/** | 
|  | 45 | +	 * Function to be executed when the user confirms the deletion. | 
|  | 46 | +	 */ | 
|  | 47 | +	onConfirm: { | 
|  | 48 | +		type: Function, | 
|  | 49 | +		required: true, | 
|  | 50 | +	}, | 
|  | 51 | +	/** | 
|  | 52 | +	 * Function to be executed when the dialog is closed. | 
|  | 53 | +	 */ | 
|  | 54 | +	onClose: { | 
|  | 55 | +		type: Function, | 
|  | 56 | +		required: false, | 
|  | 57 | +	}, | 
|  | 58 | +	/** | 
|  | 59 | +	 * Identifier of the contributor role to be deleted. Displayed in the dialog message | 
|  | 60 | +	 * and used as the required input for confirming the deletion. | 
|  | 61 | +	 */ | 
|  | 62 | +	contributorRoleIdentifier: { | 
|  | 63 | +		type: String, | 
|  | 64 | +		required: true, | 
|  | 65 | +	}, | 
|  | 66 | +}); | 
|  | 67 | +
 | 
|  | 68 | +/** | 
|  | 69 | + * Function to confirm the deletion of the role. It checks if the input value | 
|  | 70 | + * matches the role identifier and then calls the onConfirm function. | 
|  | 71 | + */ | 
|  | 72 | +async function confirmInput() { | 
|  | 73 | +	if (inputValue.value !== props.contributorRoleIdentifier) { | 
|  | 74 | +		return; | 
|  | 75 | +	} | 
|  | 76 | +
 | 
|  | 77 | +	isLoading.value = true; | 
|  | 78 | +	await props.onConfirm(); | 
|  | 79 | +	closeModal(); | 
|  | 80 | +} | 
|  | 81 | +
 | 
|  | 82 | +function closeModal() { | 
|  | 83 | +	props.onClose?.(); | 
|  | 84 | +} | 
|  | 85 | +</script> | 
0 commit comments