mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-03 11:59:49 +00:00
Apply prettier rules
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Masonry from 'masonry-layout/masonry';
|
||||
import Masonry from "masonry-layout/masonry";
|
||||
|
||||
let elem = document.querySelector('#dashboards');
|
||||
let msnry = new Masonry( elem, {
|
||||
// options
|
||||
let elem = document.querySelector("#dashboards");
|
||||
let msnry = new Masonry(elem, {
|
||||
// options
|
||||
});
|
||||
|
@@ -1,49 +1,47 @@
|
||||
const onSubmit = function(e) {
|
||||
e.preventDefault();
|
||||
let
|
||||
form = e.target,
|
||||
formData = new FormData(form),
|
||||
url = form.action,
|
||||
payload = {
|
||||
type: 'accompanying_period',
|
||||
id: Number.parseInt(formData.get('periodId'), 10),
|
||||
personLocation: {
|
||||
type: 'person',
|
||||
id: Number.parseInt(formData.get('personLocation'), 10)
|
||||
}
|
||||
}
|
||||
;
|
||||
const onSubmit = function (e) {
|
||||
e.preventDefault();
|
||||
let form = e.target,
|
||||
formData = new FormData(form),
|
||||
url = form.action,
|
||||
payload = {
|
||||
type: "accompanying_period",
|
||||
id: Number.parseInt(formData.get("periodId"), 10),
|
||||
personLocation: {
|
||||
type: "person",
|
||||
id: Number.parseInt(formData.get("personLocation"), 10),
|
||||
},
|
||||
};
|
||||
console.log("event", e);
|
||||
console.log("form", form);
|
||||
console.log("formData", formData);
|
||||
console.log("url", url);
|
||||
console.log("payload", payload);
|
||||
|
||||
console.log('event', e);
|
||||
console.log('form', form);
|
||||
console.log('formData', formData);
|
||||
console.log('url', url);
|
||||
console.log('payload', payload);
|
||||
|
||||
window.fetch(url, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
window
|
||||
.fetch(url, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
.then(r => {
|
||||
if (r.ok) {
|
||||
console.log('response ok');
|
||||
window.location.reload();
|
||||
} else {
|
||||
console.err("could not patch accompanying course");
|
||||
}
|
||||
});
|
||||
}
|
||||
.then((r) => {
|
||||
if (r.ok) {
|
||||
console.log("response ok");
|
||||
window.location.reload();
|
||||
} else {
|
||||
console.err("could not patch accompanying course");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
let forms = document.querySelectorAll('.quickLocationForm');
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
let forms = document.querySelectorAll(".quickLocationForm");
|
||||
|
||||
console.log(forms);
|
||||
|
||||
forms.forEach(function(form){
|
||||
console.log('form quickLocation found', form);
|
||||
form.addEventListener('submit', onSubmit);
|
||||
})
|
||||
forms.forEach(function (form) {
|
||||
console.log("form quickLocation found", form);
|
||||
form.addEventListener("submit", onSubmit);
|
||||
});
|
||||
});
|
||||
|
@@ -1,25 +1,22 @@
|
||||
import { ShowHide } from 'ShowHide';
|
||||
import { ShowHide } from "ShowHide";
|
||||
|
||||
let
|
||||
k = document.getElementById('waitingForBirthContainer'),
|
||||
waitingForBirthDate = document.getElementById('waitingForBirthDateContainer')
|
||||
;
|
||||
let k = document.getElementById("waitingForBirthContainer"),
|
||||
waitingForBirthDate = document.getElementById("waitingForBirthDateContainer");
|
||||
console.log(k);
|
||||
|
||||
console.log(k );
|
||||
|
||||
new ShowHide({
|
||||
'container': [waitingForBirthDate],
|
||||
'froms': [k ],
|
||||
'event_name': 'input',
|
||||
'debug': true,
|
||||
'test': function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
console.log(f);
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
return input.checked;
|
||||
}
|
||||
new ShowHide({
|
||||
container: [waitingForBirthDate],
|
||||
froms: [k],
|
||||
event_name: "input",
|
||||
debug: true,
|
||||
test: function (froms) {
|
||||
for (let f of froms.values()) {
|
||||
console.log(f);
|
||||
for (let input of f.querySelectorAll("input").values()) {
|
||||
return input.checked;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
@@ -1,18 +1,18 @@
|
||||
import { ShowHide } from 'ShowHide';
|
||||
import { ShowHide } from "ShowHide";
|
||||
|
||||
const addressForm = document.getElementById("addressForm");
|
||||
const address = document.getElementById("address");
|
||||
|
||||
new ShowHide({
|
||||
froms: [addressForm],
|
||||
container: [address],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: 'change'
|
||||
froms: [addressForm],
|
||||
container: [address],
|
||||
test: function (froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll("input").values()) {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: "change",
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ShowHide } from 'ShowHide';
|
||||
import { ShowHide } from "ShowHide";
|
||||
|
||||
const maritalStatus = document.getElementById("maritalStatus");
|
||||
const maritalStatusDate = document.getElementById("maritalStatusDate");
|
||||
@@ -8,52 +8,51 @@ const personPhoneNumber = document.getElementById("personPhoneNumber");
|
||||
const personAcceptSMS = document.getElementById("personAcceptSMS");
|
||||
|
||||
new ShowHide({
|
||||
froms: [maritalStatus],
|
||||
container: [maritalStatusDate],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('select').values()) {
|
||||
if (input.value) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
froms: [maritalStatus],
|
||||
container: [maritalStatusDate],
|
||||
test: function (froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll("select").values()) {
|
||||
if (input.value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: 'change'
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: "change",
|
||||
});
|
||||
|
||||
if (personAcceptEmail) {
|
||||
new ShowHide({
|
||||
froms: [personEmail],
|
||||
container: [personAcceptEmail],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
if (input.value) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: 'input'
|
||||
});
|
||||
new ShowHide({
|
||||
froms: [personEmail],
|
||||
container: [personAcceptEmail],
|
||||
test: function (froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll("input").values()) {
|
||||
if (input.value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: "input",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
new ShowHide({
|
||||
froms: [personPhoneNumber],
|
||||
container: [personAcceptSMS],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
if (input.value) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
froms: [personPhoneNumber],
|
||||
container: [personAcceptSMS],
|
||||
test: function (froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll("input").values()) {
|
||||
if (input.value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: 'input'
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: "input",
|
||||
});
|
||||
|
@@ -1,61 +1,76 @@
|
||||
function capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toLocaleUpperCase() + string.slice(1);
|
||||
return string.charAt(0).toLocaleUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
const uri = decodeURI(location.hash.substring(1))
|
||||
let searchFragments = uri.split(' ')
|
||||
searchFragments = searchFragments.filter((el) => {
|
||||
if ( ( el.startsWith("firstname") || el.startsWith("lastname") ) || (el !== '' && !el.startsWith('birthdate') && !el.startsWith('gender') && !el.startsWith('city') && !el.startsWith('phonenumber') && !el.startsWith('@'))) {
|
||||
return el
|
||||
}
|
||||
})
|
||||
|
||||
searchFragments = searchFragments.map((el) => {
|
||||
if (el.startsWith("firstname")) {
|
||||
return el.slice(10)
|
||||
} else if (el.startsWith("lastname")) {
|
||||
return el.slice(10)
|
||||
}
|
||||
return el.replace('\"', '')
|
||||
})
|
||||
|
||||
if (searchFragments) {
|
||||
const pre = '<ul class="list-suggest add-items inline">';
|
||||
const after = '</ul>';
|
||||
|
||||
document.querySelectorAll('[data-suggest-container]').forEach(function(container) {
|
||||
const suggestions = searchFragments.map((el) => `<li class="suggest-item-name"><span data-suggest-target="${container.dataset.suggestContainer}">${capitalizeFirstLetter(el)}</span></li>`);
|
||||
container.innerHTML = pre + suggestions.join(' ') + after;
|
||||
})
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
const uri = decodeURI(location.hash.substring(1));
|
||||
let searchFragments = uri.split(" ");
|
||||
searchFragments = searchFragments.filter((el) => {
|
||||
if (
|
||||
el.startsWith("firstname") ||
|
||||
el.startsWith("lastname") ||
|
||||
(el !== "" &&
|
||||
!el.startsWith("birthdate") &&
|
||||
!el.startsWith("gender") &&
|
||||
!el.startsWith("city") &&
|
||||
!el.startsWith("phonenumber") &&
|
||||
!el.startsWith("@"))
|
||||
) {
|
||||
return el;
|
||||
}
|
||||
});
|
||||
|
||||
const tags = document.querySelectorAll('[data-suggest-target]').forEach((tag) => {
|
||||
tag.addEventListener('click', function(e) {
|
||||
const field = document.querySelector(`[name="${e.target.dataset.suggestTarget}"]`);
|
||||
let suggestion = e.target.textContent.trim();
|
||||
switch (field.dataset.suggestTransform) {
|
||||
case 'uppercase_all':
|
||||
suggestion = suggestion.toLocaleUpperCase();
|
||||
break;
|
||||
case 'uppercase_first_letter':
|
||||
default:
|
||||
suggestion = capitalizeFirstLetter(suggestion);
|
||||
}
|
||||
searchFragments = searchFragments.map((el) => {
|
||||
if (el.startsWith("firstname")) {
|
||||
return el.slice(10);
|
||||
} else if (el.startsWith("lastname")) {
|
||||
return el.slice(10);
|
||||
}
|
||||
return el.replace('"', "");
|
||||
});
|
||||
|
||||
if (field.value === '') {
|
||||
field.value = suggestion;
|
||||
} else {
|
||||
field.value = `${field.value} ${suggestion}`
|
||||
}
|
||||
e.target.style.display = "none";
|
||||
if (searchFragments) {
|
||||
const pre = '<ul class="list-suggest add-items inline">';
|
||||
const after = "</ul>";
|
||||
|
||||
[...document.querySelectorAll("[data-suggest-target]")]
|
||||
.filter(p => p.textContent.includes(e.target.textContent))
|
||||
.forEach(p => p.remove());
|
||||
})
|
||||
})
|
||||
document
|
||||
.querySelectorAll("[data-suggest-container]")
|
||||
.forEach(function (container) {
|
||||
const suggestions = searchFragments.map(
|
||||
(el) =>
|
||||
`<li class="suggest-item-name"><span data-suggest-target="${container.dataset.suggestContainer}">${capitalizeFirstLetter(el)}</span></li>`,
|
||||
);
|
||||
container.innerHTML = pre + suggestions.join(" ") + after;
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
const tags = document
|
||||
.querySelectorAll("[data-suggest-target]")
|
||||
.forEach((tag) => {
|
||||
tag.addEventListener("click", function (e) {
|
||||
const field = document.querySelector(
|
||||
`[name="${e.target.dataset.suggestTarget}"]`,
|
||||
);
|
||||
let suggestion = e.target.textContent.trim();
|
||||
switch (field.dataset.suggestTransform) {
|
||||
case "uppercase_all":
|
||||
suggestion = suggestion.toLocaleUpperCase();
|
||||
break;
|
||||
case "uppercase_first_letter":
|
||||
default:
|
||||
suggestion = capitalizeFirstLetter(suggestion);
|
||||
}
|
||||
|
||||
if (field.value === "") {
|
||||
field.value = suggestion;
|
||||
} else {
|
||||
field.value = `${field.value} ${suggestion}`;
|
||||
}
|
||||
e.target.style.display = "none";
|
||||
|
||||
[...document.querySelectorAll("[data-suggest-target]")]
|
||||
.filter((p) => p.textContent.includes(e.target.textContent))
|
||||
.forEach((p) => p.remove());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,55 +1,53 @@
|
||||
import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js';
|
||||
import { ShowHide } from "ChillMainAssets/lib/show_hide/show_hide.js";
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
let
|
||||
personContainer = document.querySelector('#person-entity'),
|
||||
entitySelector = document.querySelector('#entity-selector'),
|
||||
freetextContainer = document.querySelector('#freetext-entity'),
|
||||
thirdpartyContainer = document.querySelector('#thirdparty-entity')
|
||||
;
|
||||
if (null === entitySelector) {
|
||||
return;
|
||||
}
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
let personContainer = document.querySelector("#person-entity"),
|
||||
entitySelector = document.querySelector("#entity-selector"),
|
||||
freetextContainer = document.querySelector("#freetext-entity"),
|
||||
thirdpartyContainer = document.querySelector("#thirdparty-entity");
|
||||
if (null === entitySelector) {
|
||||
return;
|
||||
}
|
||||
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [entitySelector],
|
||||
container: [personContainer],
|
||||
test: function(froms) {
|
||||
for (let container of froms) {
|
||||
return container.querySelector('input[value="person"]').checked;
|
||||
}
|
||||
console.log('we couldnt find the input');
|
||||
return false;
|
||||
},
|
||||
})
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [entitySelector],
|
||||
container: [personContainer],
|
||||
test: function (froms) {
|
||||
for (let container of froms) {
|
||||
return container.querySelector('input[value="person"]').checked;
|
||||
}
|
||||
console.log("we couldnt find the input");
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [entitySelector],
|
||||
container: [thirdpartyContainer],
|
||||
test: function(froms) {
|
||||
for (let container of froms) {
|
||||
return container.querySelector('input[value="thirdparty"]').checked;
|
||||
}
|
||||
console.log('we couldnt find the input');
|
||||
return false;
|
||||
},
|
||||
})
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [entitySelector],
|
||||
container: [thirdpartyContainer],
|
||||
test: function (froms) {
|
||||
for (let container of froms) {
|
||||
return container.querySelector('input[value="thirdparty"]').checked;
|
||||
}
|
||||
console.log("we couldnt find the input");
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [entitySelector],
|
||||
container: [freetextContainer],
|
||||
test: function(froms) {
|
||||
for (let container of froms) {
|
||||
return container.querySelector('input[value="freetext"]').checked;
|
||||
}
|
||||
console.log('we couldnt find the input');
|
||||
return false;
|
||||
},
|
||||
})
|
||||
new ShowHide({
|
||||
debug: false,
|
||||
load_event: null,
|
||||
froms: [entitySelector],
|
||||
container: [freetextContainer],
|
||||
test: function (froms) {
|
||||
for (let container of froms) {
|
||||
return container.querySelector('input[value="freetext"]').checked;
|
||||
}
|
||||
console.log("we couldnt find the input");
|
||||
return false;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user