mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-05 04:49:44 +00:00
eslint fixes
This commit is contained in:
@@ -7,43 +7,43 @@ import { Address } from "../../types";
|
||||
const i18n = _createI18n({});
|
||||
|
||||
document
|
||||
.querySelectorAll<HTMLSpanElement>("span[data-address-details]")
|
||||
.forEach((el) => {
|
||||
const dataset = el.dataset as {
|
||||
addressId: string;
|
||||
addressRefStatus: string;
|
||||
.querySelectorAll<HTMLSpanElement>("span[data-address-details]")
|
||||
.forEach((el) => {
|
||||
const dataset = el.dataset as {
|
||||
addressId: string;
|
||||
addressRefStatus: string;
|
||||
};
|
||||
|
||||
const app = createApp({
|
||||
components: { AddressDetailsButton },
|
||||
data() {
|
||||
return {
|
||||
addressId: Number.parseInt(dataset.addressId),
|
||||
addressRefStatus: dataset.addressRefStatus,
|
||||
};
|
||||
|
||||
const app = createApp({
|
||||
components: { AddressDetailsButton },
|
||||
data() {
|
||||
return {
|
||||
addressId: Number.parseInt(dataset.addressId),
|
||||
addressRefStatus: dataset.addressRefStatus,
|
||||
};
|
||||
},
|
||||
template:
|
||||
'<address-details-button :address_id="addressId" :address_ref_status="addressRefStatus" @update-address="onUpdateAddress"></address-details-button>',
|
||||
methods: {
|
||||
onUpdateAddress: (address: Address): void => {
|
||||
if (
|
||||
address.refStatus === "to_review" ||
|
||||
address.refStatus === "reviewed"
|
||||
) {
|
||||
// in this two case, the address content do not change
|
||||
return;
|
||||
}
|
||||
if (
|
||||
window.confirm(
|
||||
"L'adresse a été modifiée. Vous pouvez continuer votre travail. Cependant, pour afficher les données immédiatement, veuillez recharger la page. \n\n Voulez-vous recharger la page immédiatement ?",
|
||||
)
|
||||
) {
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
app.use(i18n);
|
||||
app.mount(el);
|
||||
},
|
||||
template:
|
||||
'<address-details-button :address_id="addressId" :address_ref_status="addressRefStatus" @update-address="onUpdateAddress"></address-details-button>',
|
||||
methods: {
|
||||
onUpdateAddress: (address: Address): void => {
|
||||
if (
|
||||
address.refStatus === "to_review" ||
|
||||
address.refStatus === "reviewed"
|
||||
) {
|
||||
// in this two case, the address content do not change
|
||||
return;
|
||||
}
|
||||
if (
|
||||
window.confirm(
|
||||
"L'adresse a été modifiée. Vous pouvez continuer votre travail. Cependant, pour afficher les données immédiatement, veuillez recharger la page. \n\n Voulez-vous recharger la page immédiatement ?",
|
||||
)
|
||||
) {
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
app.use(i18n);
|
||||
app.mount(el);
|
||||
});
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import {
|
||||
Essentials,
|
||||
Bold,
|
||||
Italic,
|
||||
Paragraph,
|
||||
Markdown,
|
||||
BlockQuote,
|
||||
Heading,
|
||||
Link,
|
||||
List,
|
||||
Emoji,
|
||||
Mention,
|
||||
Fullscreen,
|
||||
Essentials,
|
||||
Bold,
|
||||
Italic,
|
||||
Paragraph,
|
||||
Markdown,
|
||||
BlockQuote,
|
||||
Heading,
|
||||
Link,
|
||||
List,
|
||||
Emoji,
|
||||
Mention,
|
||||
Fullscreen,
|
||||
} from "ckeditor5";
|
||||
import coreTranslations from "ckeditor5/translations/fr.js";
|
||||
|
||||
@@ -19,41 +19,41 @@ import "ckeditor5/ckeditor5.css";
|
||||
import "./index.scss";
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
Essentials,
|
||||
Markdown,
|
||||
Bold,
|
||||
Italic,
|
||||
BlockQuote,
|
||||
Heading,
|
||||
Link,
|
||||
List,
|
||||
Paragraph,
|
||||
// both Emoji and Mention are required for Emoji feature
|
||||
Emoji,
|
||||
Mention,
|
||||
// to enable fullscreen
|
||||
Fullscreen,
|
||||
plugins: [
|
||||
Essentials,
|
||||
Markdown,
|
||||
Bold,
|
||||
Italic,
|
||||
BlockQuote,
|
||||
Heading,
|
||||
Link,
|
||||
List,
|
||||
Paragraph,
|
||||
// both Emoji and Mention are required for Emoji feature
|
||||
Emoji,
|
||||
Mention,
|
||||
// to enable fullscreen
|
||||
Fullscreen,
|
||||
],
|
||||
toolbar: {
|
||||
items: [
|
||||
"heading",
|
||||
"|",
|
||||
"bold",
|
||||
"italic",
|
||||
"link",
|
||||
"bulletedList",
|
||||
"numberedList",
|
||||
"blockQuote",
|
||||
"|",
|
||||
"emoji",
|
||||
"|",
|
||||
"undo",
|
||||
"redo",
|
||||
"|",
|
||||
"fullscreen",
|
||||
],
|
||||
toolbar: {
|
||||
items: [
|
||||
"heading",
|
||||
"|",
|
||||
"bold",
|
||||
"italic",
|
||||
"link",
|
||||
"bulletedList",
|
||||
"numberedList",
|
||||
"blockQuote",
|
||||
"|",
|
||||
"emoji",
|
||||
"|",
|
||||
"undo",
|
||||
"redo",
|
||||
"|",
|
||||
"fullscreen",
|
||||
],
|
||||
},
|
||||
translations: [coreTranslations],
|
||||
licenseKey: "GPL",
|
||||
},
|
||||
translations: [coreTranslations],
|
||||
licenseKey: "GPL",
|
||||
};
|
||||
|
@@ -2,31 +2,31 @@ import { createApp } from "vue";
|
||||
import CommentEditor from "ChillMainAssets/vuejs/_components/CommentEditor/CommentEditor.vue";
|
||||
|
||||
const ckeditorFields: NodeListOf<HTMLTextAreaElement> =
|
||||
document.querySelectorAll("textarea[ckeditor]");
|
||||
document.querySelectorAll("textarea[ckeditor]");
|
||||
ckeditorFields.forEach((field: HTMLTextAreaElement): void => {
|
||||
const content = field.value;
|
||||
const div = document.createElement("div");
|
||||
const content = field.value;
|
||||
const div = document.createElement("div");
|
||||
|
||||
if (field.parentNode !== null) {
|
||||
field.parentNode.insertBefore(div, field);
|
||||
} else {
|
||||
throw "parent is null";
|
||||
}
|
||||
if (field.parentNode !== null) {
|
||||
field.parentNode.insertBefore(div, field);
|
||||
} else {
|
||||
throw "parent is null";
|
||||
}
|
||||
|
||||
createApp({
|
||||
components: { CommentEditor },
|
||||
template: `<comment-editor v-model="content" @update:modelValue="handleInput"></comment-editor>`,
|
||||
data() {
|
||||
return {
|
||||
content,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleInput() {
|
||||
field.value = this.content;
|
||||
},
|
||||
},
|
||||
}).mount(div);
|
||||
createApp({
|
||||
components: { CommentEditor },
|
||||
template: `<comment-editor v-model="content" @update:modelValue="handleInput"></comment-editor>`,
|
||||
data() {
|
||||
return {
|
||||
content,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleInput() {
|
||||
field.value = this.content;
|
||||
},
|
||||
},
|
||||
}).mount(div);
|
||||
|
||||
field.style.display = "none";
|
||||
field.style.display = "none";
|
||||
});
|
||||
|
@@ -31,157 +31,157 @@
|
||||
import "./collection.scss";
|
||||
|
||||
declare global {
|
||||
interface GlobalEventHandlersEventMap {
|
||||
"show-hide-show": CustomEvent<{
|
||||
id: number;
|
||||
froms: HTMLElement[];
|
||||
container: HTMLElement;
|
||||
}>;
|
||||
}
|
||||
interface GlobalEventHandlersEventMap {
|
||||
"show-hide-show": CustomEvent<{
|
||||
id: number;
|
||||
froms: HTMLElement[];
|
||||
container: HTMLElement;
|
||||
}>;
|
||||
}
|
||||
}
|
||||
|
||||
export class CollectionEventPayload {
|
||||
collection: HTMLUListElement;
|
||||
entry: HTMLLIElement;
|
||||
collection: HTMLUListElement;
|
||||
entry: HTMLLIElement;
|
||||
|
||||
constructor(collection: HTMLUListElement, entry: HTMLLIElement) {
|
||||
this.collection = collection;
|
||||
this.entry = entry;
|
||||
}
|
||||
constructor(collection: HTMLUListElement, entry: HTMLLIElement) {
|
||||
this.collection = collection;
|
||||
this.entry = entry;
|
||||
}
|
||||
}
|
||||
|
||||
export const handleAdd = (button: any): void => {
|
||||
const form_name = button.dataset.collectionAddTarget,
|
||||
prototype = button.dataset.formPrototype,
|
||||
collection: HTMLUListElement | null = document.querySelector(
|
||||
'ul[data-collection-name="' + form_name + '"]',
|
||||
);
|
||||
const form_name = button.dataset.collectionAddTarget,
|
||||
prototype = button.dataset.formPrototype,
|
||||
collection: HTMLUListElement | null = document.querySelector(
|
||||
'ul[data-collection-name="' + form_name + '"]',
|
||||
);
|
||||
|
||||
if (collection === null) {
|
||||
return;
|
||||
if (collection === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const empty_explain: HTMLLIElement | null = collection.querySelector(
|
||||
"li[data-collection-empty-explain]",
|
||||
),
|
||||
entry = document.createElement("li"),
|
||||
counter = collection.querySelectorAll("li.entry").length, // Updated counter logic
|
||||
content = prototype.replace(/__name__/g, counter.toString()),
|
||||
event = new CustomEvent("collection-add-entry", {
|
||||
detail: new CollectionEventPayload(collection, entry),
|
||||
});
|
||||
|
||||
console.log(counter);
|
||||
console.log(content);
|
||||
|
||||
entry.innerHTML = content;
|
||||
entry.classList.add("entry");
|
||||
|
||||
if ("collectionRegular" in collection.dataset) {
|
||||
initializeRemove(collection, entry);
|
||||
if (empty_explain !== null) {
|
||||
empty_explain.remove();
|
||||
}
|
||||
}
|
||||
|
||||
const empty_explain: HTMLLIElement | null = collection.querySelector(
|
||||
"li[data-collection-empty-explain]",
|
||||
),
|
||||
entry = document.createElement("li"),
|
||||
counter = collection.querySelectorAll("li.entry").length, // Updated counter logic
|
||||
content = prototype.replace(/__name__/g, counter.toString()),
|
||||
event = new CustomEvent("collection-add-entry", {
|
||||
detail: new CollectionEventPayload(collection, entry),
|
||||
});
|
||||
|
||||
console.log(counter);
|
||||
console.log(content);
|
||||
|
||||
entry.innerHTML = content;
|
||||
entry.classList.add("entry");
|
||||
|
||||
if ("collectionRegular" in collection.dataset) {
|
||||
initializeRemove(collection, entry);
|
||||
if (empty_explain !== null) {
|
||||
empty_explain.remove();
|
||||
}
|
||||
}
|
||||
|
||||
collection.appendChild(entry);
|
||||
collection.dispatchEvent(event);
|
||||
window.dispatchEvent(event);
|
||||
collection.appendChild(entry);
|
||||
collection.dispatchEvent(event);
|
||||
window.dispatchEvent(event);
|
||||
};
|
||||
|
||||
const initializeRemove = (
|
||||
collection: HTMLUListElement,
|
||||
entry: HTMLLIElement,
|
||||
collection: HTMLUListElement,
|
||||
entry: HTMLLIElement,
|
||||
): void => {
|
||||
const button = buildRemoveButton(collection, entry);
|
||||
if (null === button) {
|
||||
return;
|
||||
}
|
||||
entry.appendChild(button);
|
||||
const button = buildRemoveButton(collection, entry);
|
||||
if (null === button) {
|
||||
return;
|
||||
}
|
||||
entry.appendChild(button);
|
||||
};
|
||||
|
||||
export const buildRemoveButton = (
|
||||
collection: HTMLUListElement,
|
||||
entry: HTMLLIElement,
|
||||
collection: HTMLUListElement,
|
||||
entry: HTMLLIElement,
|
||||
): HTMLButtonElement | null => {
|
||||
const button = document.createElement("button"),
|
||||
isPersisted = entry.dataset.collectionIsPersisted || "",
|
||||
content = collection.dataset.collectionButtonRemoveLabel || "",
|
||||
allowDelete = collection.dataset.collectionAllowDelete || "",
|
||||
event = new CustomEvent("collection-remove-entry", {
|
||||
detail: new CollectionEventPayload(collection, entry),
|
||||
});
|
||||
|
||||
if (allowDelete === "0" && isPersisted === "1") {
|
||||
return null;
|
||||
}
|
||||
button.classList.add("btn", "btn-delete", "remove-entry");
|
||||
button.textContent = content;
|
||||
button.addEventListener("click", (e: Event) => {
|
||||
e.preventDefault();
|
||||
entry.remove();
|
||||
collection.dispatchEvent(event);
|
||||
window.dispatchEvent(event);
|
||||
const button = document.createElement("button"),
|
||||
isPersisted = entry.dataset.collectionIsPersisted || "",
|
||||
content = collection.dataset.collectionButtonRemoveLabel || "",
|
||||
allowDelete = collection.dataset.collectionAllowDelete || "",
|
||||
event = new CustomEvent("collection-remove-entry", {
|
||||
detail: new CollectionEventPayload(collection, entry),
|
||||
});
|
||||
|
||||
return button;
|
||||
if (allowDelete === "0" && isPersisted === "1") {
|
||||
return null;
|
||||
}
|
||||
button.classList.add("btn", "btn-delete", "remove-entry");
|
||||
button.textContent = content;
|
||||
button.addEventListener("click", (e: Event) => {
|
||||
e.preventDefault();
|
||||
entry.remove();
|
||||
collection.dispatchEvent(event);
|
||||
window.dispatchEvent(event);
|
||||
});
|
||||
|
||||
return button;
|
||||
};
|
||||
|
||||
const collectionsInit = new Set<string>();
|
||||
const buttonsInit = new Set<string>();
|
||||
|
||||
const initialize = function (target: Document | Element): void {
|
||||
const addButtons: NodeListOf<HTMLButtonElement> = document.querySelectorAll(
|
||||
"button[data-collection-add-target]",
|
||||
),
|
||||
collections: NodeListOf<HTMLUListElement> = document.querySelectorAll(
|
||||
"ul[data-collection-regular]",
|
||||
);
|
||||
const addButtons: NodeListOf<HTMLButtonElement> = document.querySelectorAll(
|
||||
"button[data-collection-add-target]",
|
||||
),
|
||||
collections: NodeListOf<HTMLUListElement> = document.querySelectorAll(
|
||||
"ul[data-collection-regular]",
|
||||
);
|
||||
|
||||
for (let i = 0; i < addButtons.length; i++) {
|
||||
const addButton = addButtons[i];
|
||||
const uniqid = addButton.dataset.uniqid as string;
|
||||
if (buttonsInit.has(uniqid)) {
|
||||
continue;
|
||||
}
|
||||
buttonsInit.add(uniqid);
|
||||
addButton.addEventListener("click", (e: Event) => {
|
||||
e.preventDefault();
|
||||
handleAdd(e.target);
|
||||
});
|
||||
for (let i = 0; i < addButtons.length; i++) {
|
||||
const addButton = addButtons[i];
|
||||
const uniqid = addButton.dataset.uniqid as string;
|
||||
if (buttonsInit.has(uniqid)) {
|
||||
continue;
|
||||
}
|
||||
for (let i = 0; i < collections.length; i++) {
|
||||
const collection = collections[i];
|
||||
const uniqid = collection.dataset.uniqid as string;
|
||||
if (collectionsInit.has(uniqid)) {
|
||||
continue;
|
||||
}
|
||||
collectionsInit.add(uniqid);
|
||||
const entries: NodeListOf<HTMLLIElement> =
|
||||
collection.querySelectorAll(":scope > li");
|
||||
for (let j = 0; j < entries.length; j++) {
|
||||
if (entries[j].dataset.collectionEmptyExplain === "1") {
|
||||
continue;
|
||||
}
|
||||
initializeRemove(collections[i], entries[j]);
|
||||
}
|
||||
buttonsInit.add(uniqid);
|
||||
addButton.addEventListener("click", (e: Event) => {
|
||||
e.preventDefault();
|
||||
handleAdd(e.target);
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < collections.length; i++) {
|
||||
const collection = collections[i];
|
||||
const uniqid = collection.dataset.uniqid as string;
|
||||
if (collectionsInit.has(uniqid)) {
|
||||
continue;
|
||||
}
|
||||
collectionsInit.add(uniqid);
|
||||
const entries: NodeListOf<HTMLLIElement> =
|
||||
collection.querySelectorAll(":scope > li");
|
||||
for (let j = 0; j < entries.length; j++) {
|
||||
if (entries[j].dataset.collectionEmptyExplain === "1") {
|
||||
continue;
|
||||
}
|
||||
initializeRemove(collections[i], entries[j]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
initialize(document);
|
||||
initialize(document);
|
||||
});
|
||||
|
||||
window.addEventListener(
|
||||
"show-hide-show",
|
||||
(
|
||||
event: CustomEvent<{
|
||||
id: number;
|
||||
container: HTMLElement;
|
||||
froms: HTMLElement[];
|
||||
}>,
|
||||
) => {
|
||||
const container = event.detail.container as HTMLElement;
|
||||
initialize(container);
|
||||
},
|
||||
"show-hide-show",
|
||||
(
|
||||
event: CustomEvent<{
|
||||
id: number;
|
||||
container: HTMLElement;
|
||||
froms: HTMLElement[];
|
||||
}>,
|
||||
) => {
|
||||
const container = event.detail.container as HTMLElement;
|
||||
initialize(container);
|
||||
},
|
||||
);
|
||||
|
@@ -5,39 +5,39 @@ import NotificationReadAllToggle from "../../vuejs/_components/Notification/Noti
|
||||
const i18n = _createI18n({});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const elements = document.querySelectorAll(".notification_all_read");
|
||||
const elements = document.querySelectorAll(".notification_all_read");
|
||||
|
||||
elements.forEach((element) => {
|
||||
console.log("launch");
|
||||
createApp({
|
||||
template: `<notification-read-all-toggle @markAsRead="markAsRead" @markAsUnRead="markAsUnread"></notification-read-all-toggle>`,
|
||||
components: {
|
||||
NotificationReadAllToggle,
|
||||
},
|
||||
methods: {
|
||||
markAsRead(id: number) {
|
||||
const el = document.querySelector<HTMLDivElement>(
|
||||
`div.notification-status[data-notification-id="${id}"]`,
|
||||
);
|
||||
if (el === null) {
|
||||
return;
|
||||
}
|
||||
el.classList.add("read");
|
||||
el.classList.remove("unread");
|
||||
},
|
||||
markAsUnread(id: number) {
|
||||
const el = document.querySelector<HTMLDivElement>(
|
||||
`div.notification-status[data-notification-id="${id}"]`,
|
||||
);
|
||||
if (el === null) {
|
||||
return;
|
||||
}
|
||||
el.classList.remove("read");
|
||||
el.classList.add("unread");
|
||||
},
|
||||
},
|
||||
})
|
||||
.use(i18n)
|
||||
.mount(element);
|
||||
});
|
||||
elements.forEach((element) => {
|
||||
console.log("launch");
|
||||
createApp({
|
||||
template: `<notification-read-all-toggle @markAsRead="markAsRead" @markAsUnRead="markAsUnread"></notification-read-all-toggle>`,
|
||||
components: {
|
||||
NotificationReadAllToggle,
|
||||
},
|
||||
methods: {
|
||||
markAsRead(id: number) {
|
||||
const el = document.querySelector<HTMLDivElement>(
|
||||
`div.notification-status[data-notification-id="${id}"]`,
|
||||
);
|
||||
if (el === null) {
|
||||
return;
|
||||
}
|
||||
el.classList.add("read");
|
||||
el.classList.remove("unread");
|
||||
},
|
||||
markAsUnread(id: number) {
|
||||
const el = document.querySelector<HTMLDivElement>(
|
||||
`div.notification-status[data-notification-id="${id}"]`,
|
||||
);
|
||||
if (el === null) {
|
||||
return;
|
||||
}
|
||||
el.classList.remove("read");
|
||||
el.classList.add("unread");
|
||||
},
|
||||
},
|
||||
})
|
||||
.use(i18n)
|
||||
.mount(element);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user