2021-10-21 11:12:54 -04:00
|
|
|
import Vue from 'vue';
|
2021-12-20 01:10:53 -05:00
|
|
|
import { pickBy } from 'lodash';
|
2021-11-09 10:12:42 -05:00
|
|
|
import { parseBoolean } from './lib/utils/common_utils';
|
2021-10-21 11:12:54 -04:00
|
|
|
import ConfirmDanger from './vue_shared/components/confirm_danger/confirm_danger.vue';
|
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const el = document.querySelector('.js-confirm-danger');
|
|
|
|
if (!el) return null;
|
|
|
|
|
2021-11-09 10:12:42 -05:00
|
|
|
const {
|
|
|
|
removeFormId = null,
|
|
|
|
phrase,
|
|
|
|
buttonText,
|
2021-12-01 07:16:08 -05:00
|
|
|
buttonClass = '',
|
2022-06-29 23:08:59 -04:00
|
|
|
buttonTestid,
|
|
|
|
buttonVariant,
|
2021-11-09 10:12:42 -05:00
|
|
|
confirmDangerMessage,
|
2021-12-20 01:10:53 -05:00
|
|
|
confirmButtonText = null,
|
2022-06-29 23:08:59 -04:00
|
|
|
disabled,
|
2021-12-20 01:10:53 -05:00
|
|
|
additionalInformation,
|
|
|
|
htmlConfirmationMessage,
|
2021-11-09 10:12:42 -05:00
|
|
|
} = el.dataset;
|
2021-10-21 11:12:54 -04:00
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2021-12-20 01:10:53 -05:00
|
|
|
provide: pickBy(
|
|
|
|
{
|
|
|
|
htmlConfirmationMessage,
|
|
|
|
confirmDangerMessage,
|
|
|
|
additionalInformation,
|
|
|
|
confirmButtonText,
|
|
|
|
},
|
|
|
|
(v) => Boolean(v),
|
|
|
|
),
|
2021-10-21 11:12:54 -04:00
|
|
|
render: (createElement) =>
|
|
|
|
createElement(ConfirmDanger, {
|
|
|
|
props: {
|
|
|
|
phrase,
|
|
|
|
buttonText,
|
2021-12-01 07:16:08 -05:00
|
|
|
buttonClass,
|
2021-12-20 01:10:53 -05:00
|
|
|
buttonVariant,
|
2021-11-09 10:12:42 -05:00
|
|
|
buttonTestid,
|
|
|
|
disabled: parseBoolean(disabled),
|
2021-10-21 11:12:54 -04:00
|
|
|
},
|
2021-11-09 10:12:42 -05:00
|
|
|
on: {
|
|
|
|
confirm: () => {
|
|
|
|
if (removeFormId) document.getElementById(removeFormId)?.submit();
|
|
|
|
},
|
2021-10-21 11:12:54 -04:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
};
|