Commit 35239074 authored by Denys Mishunov's avatar Denys Mishunov

Unified form JS handling for snippets

The unification of JS handling for the Project and Personal
snippets happened in abstracting the shared functionality
(pretty much all of it) into a shared file to have one SSOT for
4 (2 'edit' + 2 'new') views
parent 16f380e3
import $ from 'jquery'; import '~/snippet/snippet_edit';
import initSnippet from '~/snippet/snippet_bundle';
import initForm from '~/pages/projects/init_form';
document.addEventListener('DOMContentLoaded', () => {
initSnippet();
initForm($('.snippet-form'));
});
import $ from 'jquery'; import '~/snippet/snippet_edit';
import initSnippet from '~/snippet/snippet_bundle';
import initForm from '~/pages/projects/init_form';
document.addEventListener('DOMContentLoaded', () => {
initSnippet();
initForm($('.snippet-form'));
});
import initSnippet from '~/snippet/snippet_bundle'; import '~/snippet/snippet_edit';
import form from '../form';
document.addEventListener('DOMContentLoaded', () => {
initSnippet();
form();
});
import initSnippet from '~/snippet/snippet_bundle'; import '~/snippet/snippet_edit';
import form from '../form';
document.addEventListener('DOMContentLoaded', () => {
initSnippet();
form();
});
import $ from 'jquery';
import initSnippet from '~/snippet/snippet_bundle';
import ZenMode from '~/zen_mode';
import GLForm from '~/gl_form';
document.addEventListener('DOMContentLoaded', () => {
const form = document.querySelector('.snippet-form');
const personalSnippetOptions = {
members: false,
issues: false,
mergeRequests: false,
epics: false,
milestones: false,
labels: false,
snippets: false,
};
const projectSnippetOptions = {};
const options =
form.dataset.snippetType === 'project' ? projectSnippetOptions : personalSnippetOptions;
initSnippet();
new ZenMode(); // eslint-disable-line no-new
new GLForm($(form), options); // eslint-disable-line no-new
});
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
.snippet-form-holder .snippet-form-holder
= form_for @snippet, url: url, = form_for @snippet, url: url,
html: { class: "snippet-form js-requires-input js-quick-submit common-note-form" } do |f| html: { class: "snippet-form js-requires-input js-quick-submit common-note-form" },
data: { "snippet-type": @snippet.project_id ? 'project' : 'personal'} do |f|
= form_errors(@snippet) = form_errors(@snippet)
.form-group .form-group
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment