docbrown/app/javascript/packs/articleForm.jsx
Ridhwana b9a8d87e95
[deploy] Refactor to create a helper for the mailer links (#7502)
* refactor: set the email_from to use in teh defaults

* chore: remove some new lines

* feat: add a mail link helper that can be used in the views

* feat: returns the default if it doesn't understand the parameter

* feat: Quick replacement of links

* feat: allow subject to be passed through

* chore: update all hrefs

* chore: remove rel attribute

* chore: mail link

* update spec

* chore: space

* chore: update some whitespaces and emails

* style

* chore: PR mail_link to email_link and the comment

* feat: PR suggestions for encoding

* feat: use mail_to
2020-04-27 09:18:16 -04:00

40 lines
1,003 B
JavaScript

import { h, render } from 'preact';
import { getUserDataAndCsrfToken } from '../chat/util';
import ArticleForm from '../article-form/articleForm';
HTMLDocument.prototype.ready = new Promise((resolve) => {
if (document.readyState !== 'loading') {
return resolve();
}
document.addEventListener('DOMContentLoaded', () => resolve());
return null;
});
function loadForm() {
getUserDataAndCsrfToken().then(({ currentUser, csrfToken }) => {
window.currentUser = currentUser;
window.csrfToken = csrfToken;
const root = document.getElementById('article-form');
const { article, organizations, version } = root.dataset;
render(
<ArticleForm
article={article}
organizations={organizations}
version={version}
/>,
root,
root.firstElementChild,
);
});
}
document.ready.then(() => {
loadForm();
window.InstantClick.on('change', () => {
if (document.getElementById('article-form')) {
loadForm();
}
});
});