Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
38a2af9
Erweiterungstätigkeiten zur IPN-Vorschlagsliste anhand von Präfixen a…
Apr 1, 2025
378489d
Umstellung Migrationen bzgl. Multi-Plattform-Support.
Apr 23, 2025
0586e80
Postgre Statements integrieren
Jun 17, 2025
a7665af
SQL-Formatierung in Migration verbessern
Jun 17, 2025
b2b0f39
Erweitere IPN-Suggest um Bauteilbeschreibung.
Jul 9, 2025
c7bc912
Anpassungen aus Analyse vornehmen
Jul 17, 2025
3100c83
IPN-Validierung für Parts überarbeiten
Aug 25, 2025
a2f5329
IPN-Vorschlagslogik um Konfiguration erweitert
Sep 25, 2025
f0748a2
Assemblies einführen
Mar 19, 2025
ca45064
Default-Sortierung für Assemblies per YAML-Konfiguration einführen
Mar 20, 2025
74e48d3
configuration.md: Info für Default-Sortierung zu Assemblies einfügen
Mar 20, 2025
1490029
Anpassungen aus Benutzersicht, um den Fokus auf die reine Baugruppen-…
Apr 2, 2025
290a9b3
Übersetzung zu "assembly.bom_import.template.kicad_pcbnew.table" anpa…
Apr 3, 2025
1cf396f
Assembly Konfiguration in BOM ausblenden, wenn bisher keine Zuordnung…
Apr 4, 2025
de80b5e
PartController -> new Methode Variablennamen korrigieren
Apr 11, 2025
33925b9
JSON Importer mit Minimaldaten weiterentwickeln. Validierung mit Viol…
Apr 11, 2025
5fbb1a8
Anpassungen zu JSON Importer vornehmen.
Apr 16, 2025
df85017
Umstellung Migrationen bzgl. Multi-Plattform-Support.
Apr 22, 2025
adbe310
Projekt BOM-Konfiguration um Assemblies bereinigen.
Jun 17, 2025
688e2f8
SQL-Formatierung in Migration verbessern
Jun 17, 2025
a47f6c2
Projekt-Importer um JSON/CSV Importer analog zu Assemblies erweitern
Jun 24, 2025
7e8d444
Part-Übersicht sowie -Detailansicht um Assembly Information erweitern
Jun 24, 2025
bdbaab9
Assembly um IPN-Eingabemöglichkeit und Automatismus zur Name-Angabe e…
Jun 26, 2025
2cbda93
Baugruppen Stückliste um referenzierte Baugruppe erweitern
Jul 3, 2025
70303ca
AssemblyBomEntriesDataTable anpassen
Jul 3, 2025
f93152c
Assembly Listenübersicht umsetzen
Jul 3, 2025
37b2380
Assembly Konstanten in .env einfügen bzw. anpassen
Jul 3, 2025
8009418
Assembly getReferencedAssemblies korrigieren
Jul 3, 2025
310461f
Füge Unterstützung für Datenquellen-Synonyme hinzu.
Jul 7, 2025
01f3f9d
Füge Validierung für zyklische Baugruppenreferenzen hinzu
Jul 8, 2025
4b72225
Anpassungen aus Analyse vornehmen
Jul 17, 2025
dbeb4cc
Stücklisten beim Löschen: Markieren von referenzierten Baugruppen als…
Jul 18, 2025
5c54191
Migration: Spaltenname korrigieren
Jul 21, 2025
d7e4db3
BOMImporter: Verbesserung des CSV-Parsing
Jul 22, 2025
ba001d6
Reihenfolge der Tabs in Baugruppenansicht korrigiert
Jul 22, 2025
a34589c
BOMImporter und AssemblyCycleValidator: Verbesserte Import-Logik
Jul 22, 2025
a0900c5
BOMValidator: Validierung für rekursive Baugruppen-Eintragsprüfung er…
Jul 24, 2025
0c29724
Tabs und BOMImporter: Verbesserte Anzeige und Validierung
Jul 24, 2025
03d8166
BOMImporter und AssemblyBomEntriesDataTable: Mountnames hinzugefügt
Jul 28, 2025
7abc37f
Füge Option für lesbares CSV beim Export hinzu (APS-3)
Sep 8, 2025
360fed1
Rebase auf Part-DB v2.1.2
Sep 10, 2025
4251b2a
Entferne Projektbezogene Logik bzw. Verweise auf Baugruppen, da nicht…
Sep 12, 2025
a682b87
Erweitere Exportfunktion um lesbare BOM-Option (PDF-Ausgabe).
Sep 15, 2025
9194d62
PDF Exportmöglichkeit zunächst nur anzeigen, wenn es sich um ein Asse…
Sep 17, 2025
9a037e9
Anzeige und Logik für zugehörige Build-Parts sowie Build-Tab bei Asse…
Sep 19, 2025
dc4461d
Korrigiere Route und Objekttyp
Sep 24, 2025
3d3d655
Revert "Füge Unterstützung für Datenquellen-Synonyme hinzu."
Sep 26, 2025
9b90a51
Anpassungen aus phpstan Analyse
Sep 26, 2025
654c2ed
IPN-Vorschlagslogik erweitert und Bauteil-IPN vereindeutigt
Sep 29, 2025
e13803e
BOMImporter: Schreibweise von Repository-Namen korrigieren
Sep 29, 2025
a1390b3
Füge Designator zu Stücklisten-Einträgen für Freitext-Angabe hinzu. E…
Sep 30, 2025
596a30d
Korrigiere Designator-Feld in EntityExporter.
Sep 30, 2025
6fa960d
Assemblies einführen
Mar 19, 2025
667b3fd
Default-Sortierung für Assemblies per YAML-Konfiguration einführen
Mar 20, 2025
fa4a044
configuration.md: Info für Default-Sortierung zu Assemblies einfügen
Mar 20, 2025
4718f02
Anpassungen aus Benutzersicht, um den Fokus auf die reine Baugruppen-…
Apr 2, 2025
8c973a3
Übersetzung zu "assembly.bom_import.template.kicad_pcbnew.table" anpa…
Apr 3, 2025
0246080
Assembly Konfiguration in BOM ausblenden, wenn bisher keine Zuordnung…
Apr 4, 2025
b227bac
PartController -> new Methode Variablennamen korrigieren
Apr 11, 2025
23e4b00
JSON Importer mit Minimaldaten weiterentwickeln. Validierung mit Viol…
Apr 11, 2025
748591c
Anpassungen zu JSON Importer vornehmen.
Apr 16, 2025
f79dc3a
Umstellung Migrationen bzgl. Multi-Plattform-Support.
Apr 22, 2025
df2ce45
Projekt BOM-Konfiguration um Assemblies bereinigen.
Jun 17, 2025
2066d20
SQL-Formatierung in Migration verbessern
Jun 17, 2025
ecbc8b4
Projekt-Importer um JSON/CSV Importer analog zu Assemblies erweitern
Jun 24, 2025
bba6197
Part-Übersicht sowie -Detailansicht um Assembly Information erweitern
Jun 24, 2025
4f9c20a
Assembly um IPN-Eingabemöglichkeit und Automatismus zur Name-Angabe e…
Jun 26, 2025
4e1c890
Baugruppen Stückliste um referenzierte Baugruppe erweitern
Jul 3, 2025
36e9939
AssemblyBomEntriesDataTable anpassen
Jul 3, 2025
10e6fb4
Assembly Listenübersicht umsetzen
Jul 3, 2025
c80c7d2
Assembly Konstanten in .env einfügen bzw. anpassen
Jul 3, 2025
175f664
Assembly getReferencedAssemblies korrigieren
Jul 3, 2025
9d9cedd
Füge Unterstützung für Datenquellen-Synonyme hinzu.
Jul 7, 2025
cbfe1d4
Füge Validierung für zyklische Baugruppenreferenzen hinzu
Jul 8, 2025
7162199
Erweiterungstätigkeiten zur IPN-Vorschlagsliste anhand von Präfixen a…
Apr 1, 2025
18a290b
Umstellung Migrationen bzgl. Multi-Plattform-Support.
Apr 23, 2025
66cb723
Postgre Statements integrieren
Jun 17, 2025
9c565cb
SQL-Formatierung in Migration verbessern
Jun 17, 2025
0dc7dbd
Erweitere IPN-Suggest um Bauteilbeschreibung.
Jul 9, 2025
ee54687
Benutzerdefinierten Bauteilstatus einführen
Mar 24, 2025
a680e6e
PartCustomStateController hinzufügen
Mar 24, 2025
3e1ea23
Umstellung Migrationen bzgl. Multi-Plattform-Support.
Apr 23, 2025
1194136
Postgre Statements integrieren
Jun 17, 2025
6976ab0
Semikolon in Migration entfernen
Jun 17, 2025
67480f2
Anpassungen aus Analyse vornehmen
Jul 17, 2025
8034bf0
Migration für PartCustomState aktualisieren
Jul 17, 2025
20c9038
Anpassungen aus Analyse vornehmen
Jul 17, 2025
86b5f7e
Anpassung Migration aus Zusammenführung Feature Branches
Jul 17, 2025
2cbfdc6
Stücklisten beim Löschen: Markieren von referenzierten Baugruppen als…
Jul 18, 2025
607050a
Migration: Spaltenname korrigieren
Jul 21, 2025
961b352
BOMImporter: Verbesserung des CSV-Parsing
Jul 22, 2025
06373b3
Reihenfolge der Tabs in Baugruppenansicht korrigiert
Jul 22, 2025
9acca25
BOMImporter und AssemblyCycleValidator: Verbesserte Import-Logik
Jul 22, 2025
a62866d
BOMValidator: Validierung für rekursive Baugruppen-Eintragsprüfung er…
Jul 24, 2025
c1cb843
Tabs und BOMImporter: Verbesserte Anzeige und Validierung
Jul 24, 2025
ff00ae9
BOMImporter und AssemblyBomEntriesDataTable: Mountnames hinzugefügt
Jul 28, 2025
b823d7d
IPN-Validierung für Parts überarbeiten
Aug 25, 2025
c79fc47
Füge Option für lesbares CSV beim Export hinzu (APS-3)
Sep 8, 2025
55828d8
Assemblies einführen
Mar 19, 2025
e1fd146
Default-Sortierung für Assemblies per YAML-Konfiguration einführen
Mar 20, 2025
968bf74
Anpassungen aus Benutzersicht, um den Fokus auf die reine Baugruppen-…
Apr 2, 2025
74ffec3
Übersetzung zu "assembly.bom_import.template.kicad_pcbnew.table" anpa…
Apr 3, 2025
b6f904a
Assembly Konfiguration in BOM ausblenden, wenn bisher keine Zuordnung…
Apr 4, 2025
907a321
JSON Importer mit Minimaldaten weiterentwickeln. Validierung mit Viol…
Apr 11, 2025
7a65c8a
Anpassungen zu JSON Importer vornehmen.
Apr 16, 2025
b046d41
Umstellung Migrationen bzgl. Multi-Plattform-Support.
Apr 22, 2025
65706d1
Projekt BOM-Konfiguration um Assemblies bereinigen.
Jun 17, 2025
33a8f28
Projekt-Importer um JSON/CSV Importer analog zu Assemblies erweitern
Jun 24, 2025
a141613
Part-Übersicht sowie -Detailansicht um Assembly Information erweitern
Jun 24, 2025
14b0665
Assembly um IPN-Eingabemöglichkeit und Automatismus zur Name-Angabe e…
Jun 26, 2025
c7aa730
Baugruppen Stückliste um referenzierte Baugruppe erweitern
Jul 3, 2025
292aefa
Assembly Listenübersicht umsetzen
Jul 3, 2025
d3dccc5
Füge Unterstützung für Datenquellen-Synonyme hinzu.
Jul 7, 2025
2648bd2
Füge Validierung für zyklische Baugruppenreferenzen hinzu
Jul 8, 2025
dc3279c
Rebase auf Part-DB v2.1.2
Sep 10, 2025
5e3a9ec
Entferne Projektbezogene Logik bzw. Verweise auf Baugruppen, da nicht…
Sep 12, 2025
82d867f
Erweitere Exportfunktion um lesbare BOM-Option (PDF-Ausgabe).
Sep 15, 2025
9df2c4d
PDF Exportmöglichkeit zunächst nur anzeigen, wenn es sich um ein Asse…
Sep 17, 2025
3f0738f
Anzeige und Logik für zugehörige Build-Parts sowie Build-Tab bei Asse…
Sep 19, 2025
773c95e
Korrekturen vornehmen
Oct 1, 2025
f7ec130
Merge remote-tracking branch 'origin/feature/create-assemblies' into …
Oct 1, 2025
0814d1c
Korrekturen vornehmen
Oct 1, 2025
4a717f8
Korrektur in messages.zh.xlf vornehmen
Oct 1, 2025
0943c43
Benutzerdefinierten Bauteilstatus einführen
Mar 24, 2025
e8e7c16
PartCustomStateController hinzufügen
Mar 24, 2025
a3db619
Umstellung Migrationen bzgl. Multi-Plattform-Support.
Apr 23, 2025
321aeb1
Postgre Statements integrieren
Jun 17, 2025
1ee32c6
Semikolon in Migration entfernen
Jun 17, 2025
4430642
Migration für PartCustomState aktualisieren
Jul 17, 2025
44d52d1
Benutzerdefinierten Bauteilstatus in TableSettings aufnehmen
Sep 24, 2025
0ac40c6
PartCustomStateControllerTest: Attribute für PHPUnit-Gruppen umgestellt
Sep 26, 2025
5a0cbb7
PartCustomState: Mapping für Parameter korrigieren
Sep 26, 2025
73a2b16
Merge remote-tracking branch 'origin/feature/custom-part-status' into…
Oct 1, 2025
7a58858
Merge remote-tracking branch 'origin/feature/automatic-ipn-generation…
Oct 1, 2025
5626437
Fehlende Übersetzung in messages.en.xlf ergänzen
Oct 1, 2025
f0bdbaf
TypeaheadController.php fehlende Methode ergänzen
Oct 1, 2025
9f42e75
Überarbeitung Mountnames- sowie Designator Angabe für Freitext. Expor…
Oct 1, 2025
5ab2cf5
Überarbeitungen: Subassemblies darstellen sowie Parameters losgelöst …
Oct 1, 2025
e9ee80c
Merge remote-tracking branch 'origin/feature/create-assemblies' into …
Oct 1, 2025
ec49a83
PartCustomState: Darstellung und Zuordnung von Anhängen ergänzt
Oct 10, 2025
fdc7a6d
Entferne Eingabefeld "Mountnames" sowie "Prices" bei Assembly-BOM Kon…
Oct 10, 2025
697b3a7
Merge remote-tracking branch 'origin/feature/custom-part-status' into…
Oct 10, 2025
fb07f2a
Merge remote-tracking branch 'origin/feature/create-assemblies' into …
Oct 10, 2025
08a3554
Füge eindeutigen Index zu parts.ipn wieder hinzu.
Oct 10, 2025
6589e0d
Regex-Konfigurationsmöglichkeit für IPN-Vorschläge einführen
Oct 13, 2025
f612d6e
Merge remote-tracking branch 'origin/feature/automatic-ipn-generation…
Oct 13, 2025
be8fb57
Migrationen zusammenführen
Oct 14, 2025
c653ddd
PartCustomState: Anpassungen bzgl. Tests
Oct 14, 2025
6cea41b
PartCustomStateEndpoint hinzufügen
Oct 14, 2025
61b0a58
Implementiere bevorzugte Sprachauswahl und Datenquellen-Synonyme
Oct 15, 2025
7c24e18
Anpassung aus Analyse
Oct 15, 2025
33b86c6
Merge remote-tracking branch 'origin/feature/custom-part-status' into…
Oct 15, 2025
24aabb3
Migration entfernen
Oct 15, 2025
3dabf57
Merge remote-tracking branch 'origin/feature/custom-data-source-label…
Oct 15, 2025
498f8bc
Füge "assembly" zu Datenquellen-Synonymen hinzu
Oct 15, 2025
51e7eea
Data-Source Synonyme: ergänze "assembly" zu Datenquellen und Baumansi…
Oct 15, 2025
0d7404d
Entferne "Mountnames" aus EntityExporter für Assemblies
Oct 15, 2025
4501a8d
Merge remote-tracking branch 'origin/feature/create-assemblies' into …
Oct 15, 2025
f7875ba
Anpassungen aus Analyse
Oct 16, 2025
8515887
Build-Funktionalität bei Assemblies entfernen. Soll letztlich nur bei…
Oct 16, 2025
1345974
Merge remote-tracking branch 'origin/feature/create-assemblies' into …
Oct 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ ERROR_PAGE_ADMIN_EMAIL=''
# If this is set to true, solutions to common problems are shown on error pages. Disable this, if you do not want your users to see them...
ERROR_PAGE_SHOW_HELP=1


###################################################################################
# SAML Single sign on-settings
###################################################################################
Expand Down
70 changes: 70 additions & 0 deletions assets/controllers/elements/assembly_select_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {Controller} from "@hotwired/stimulus";

import "tom-select/dist/css/tom-select.bootstrap5.css";
import '../../css/components/tom-select_extensions.css';
import TomSelect from "tom-select";
import {marked} from "marked";

export default class extends Controller {
_tomSelect;

connect() {

let settings = {
allowEmptyOption: true,
plugins: ['dropdown_input', 'clear_button'],
searchField: ["name", "description", "category", "footprint"],
valueField: "id",
labelField: "name",
preload: "focus",
render: {
item: (data, escape) => {
return '<span>' + (data.image ? "<img style='height: 1.5rem; margin-right: 5px;' ' src='" + data.image + "'/>" : "") + escape(data.name) + '</span>';
},
option: (data, escape) => {
if(data.text) {
return '<span>' + escape(data.text) + '</span>';
}

let tmp = '<div class="row m-0">' +
"<div class='col-2 p-0 d-flex align-items-center' style='max-width: 80px;'>" +
(data.image ? "<img class='typeahead-image' src='" + data.image + "'/>" : "") +
"</div>" +
"<div class='col-10'>" +
'<h6 class="m-0">' + escape(data.name) + '</h6>' +
(data.description ? '<p class="m-0">' + marked.parseInline(data.description) + '</p>' : "") +
(data.category ? '<p class="m-0"><span class="fa-solid fa-tags fa-fw"></span> ' + escape(data.category) : "");

return tmp + '</p>' +
'</div></div>';
}
}
};


if (this.element.dataset.autocomplete) {
const base_url = this.element.dataset.autocomplete;
settings.valueField = "id";
settings.load = (query, callback) => {
const url = base_url.replace('__QUERY__', encodeURIComponent(query));

fetch(url)
.then(response => response.json())
.then(json => {callback(json);})
.catch(() => {
callback()
});
};


this._tomSelect = new TomSelect(this.element, settings);
//this._tomSelect.clearOptions();
}
}

disconnect() {
super.disconnect();
//Destroy the TomSelect instance
this._tomSelect.destroy();
}
}
9 changes: 9 additions & 0 deletions assets/controllers/elements/ckeditor_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export default class extends Controller {
editor_div.classList.add(...new_classes.split(","));
}

// Automatic synchronization of source input
editor.model.document.on("change:data", () => {
editor.updateSourceElement();

// Dispatch the input event for further treatment
const event = new Event("input");
this.element.dispatchEvent(event);
});

//This return is important! Otherwise we get mysterious errors in the console
//See: https://github.com/ckeditor/ckeditor5/issues/5897#issuecomment-628471302
return editor;
Expand Down
250 changes: 250 additions & 0 deletions assets/controllers/elements/ipn_suggestion_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
import { Controller } from "@hotwired/stimulus";
import "../../css/components/autocomplete_bootstrap_theme.css";

export default class extends Controller {
static targets = ["input"];
static values = {
partId: Number,
partCategoryId: Number,
partDescription: String,
suggestions: Object,
commonSectionHeader: String, // Dynamic header for common Prefixes
partIncrementHeader: String, // Dynamic header for new possible part increment
suggestUrl: String,
};

connect() {
this.configureAutocomplete();
this.watchCategoryChanges();
this.watchDescriptionChanges();
}

templates = {
commonSectionHeader({ title, html }) {
return html`
<section class="aa-Source">
<div class="aa-SourceHeader">
<span class="aa-SourceHeaderTitle">${title}</span>
<div class="aa-SourceHeaderLine"></div>
</div>
</section>
`;
},
partIncrementHeader({ title, html }) {
return html`
<section class="aa-Source">
<div class="aa-SourceHeader">
<span class="aa-SourceHeaderTitle">${title}</span>
<div class="aa-SourceHeaderLine"></div>
</div>
</section>
`;
},
list({ html }) {
return html`
<ul class="aa-List" role="listbox"></ul>
`;
},
item({ suggestion, description, html }) {
return html`
<li class="aa-Item" role="option" data-suggestion="${suggestion}" aria-selected="false">
<div class="aa-ItemWrapper">
<div class="aa-ItemContent">
<div class="aa-ItemIcon aa-ItemIcon--noBorder">
<svg viewBox="0 0 24 24" fill="currentColor">
<path d="M12 21c4.971 0 9-4.029 9-9s-4.029-9-9-9-9 4.029-9 9 4.029 9 9 9z"></path>
</svg>
</div>
<div class="aa-ItemContentBody">
<div class="aa-ItemContentTitle">${suggestion}</div>
<div class="aa-ItemContentDescription">${description}</div>
</div>
</div>
</div>
</li>
`;
},
};

configureAutocomplete() {
const inputField = this.inputTarget;
const commonPrefixes = this.suggestionsValue.commonPrefixes || [];
const prefixesPartIncrement = this.suggestionsValue.prefixesPartIncrement || [];
const commonHeader = this.commonSectionHeaderValue;
const partIncrementHeader = this.partIncrementHeaderValue;

if (!inputField || (!commonPrefixes.length && !prefixesPartIncrement.length)) return;

// Check whether the panel should be created at the update
if (this.isPanelInitialized) {
const existingPanel = inputField.parentNode.querySelector(".aa-Panel");
if (existingPanel) {
// Only remove the panel in the update phase

existingPanel.remove();
}
}

// Create panel
const panel = document.createElement("div");
panel.classList.add("aa-Panel");
panel.style.display = "none";

// Create panel layout
const panelLayout = document.createElement("div");
panelLayout.classList.add("aa-PanelLayout", "aa-Panel--scrollable");

// Section for prefixes part increment
if (prefixesPartIncrement.length) {
const partIncrementSection = document.createElement("section");
partIncrementSection.classList.add("aa-Source");

const partIncrementHeaderHtml = this.templates.partIncrementHeader({
title: partIncrementHeader,
html: String.raw,
});
partIncrementSection.innerHTML += partIncrementHeaderHtml;

const partIncrementList = document.createElement("ul");
partIncrementList.classList.add("aa-List");
partIncrementList.setAttribute("role", "listbox");

prefixesPartIncrement.forEach((prefix) => {
const itemHTML = this.templates.item({
suggestion: prefix.title,
description: prefix.description,
html: String.raw,
});
partIncrementList.innerHTML += itemHTML;
});

partIncrementSection.appendChild(partIncrementList);
panelLayout.appendChild(partIncrementSection);
}

// Section for common prefixes
if (commonPrefixes.length) {
const commonSection = document.createElement("section");
commonSection.classList.add("aa-Source");

const commonSectionHeader = this.templates.commonSectionHeader({
title: commonHeader,
html: String.raw,
});
commonSection.innerHTML += commonSectionHeader;

const commonList = document.createElement("ul");
commonList.classList.add("aa-List");
commonList.setAttribute("role", "listbox");

commonPrefixes.forEach((prefix) => {
const itemHTML = this.templates.item({
suggestion: prefix.title,
description: prefix.description,
html: String.raw,
});
commonList.innerHTML += itemHTML;
});

commonSection.appendChild(commonList);
panelLayout.appendChild(commonSection);
}

panel.appendChild(panelLayout);
inputField.parentNode.appendChild(panel);

inputField.addEventListener("focus", () => {
panel.style.display = "block";
});

inputField.addEventListener("blur", () => {
setTimeout(() => {
panel.style.display = "none";
}, 100);
});

// Selection of an item
panelLayout.addEventListener("mousedown", (event) => {
const target = event.target.closest("li");

if (target) {
inputField.value = target.dataset.suggestion;
panel.style.display = "none";
}
});

this.isPanelInitialized = true;
};

watchCategoryChanges() {
const categoryField = document.querySelector('[data-ipn-suggestion="categoryField"]');
const descriptionField = document.querySelector('[data-ipn-suggestion="descriptionField"]');
this.previousCategoryId = Number(this.partCategoryIdValue);

if (categoryField) {
categoryField.addEventListener("change", () => {
const categoryId = Number(categoryField.value);
const description = String(descriptionField?.value ?? '');

// Check whether the category has changed compared to the previous ID
if (categoryId !== this.previousCategoryId) {
this.fetchNewSuggestions(categoryId, description);
this.previousCategoryId = categoryId;
}
});
}
}

watchDescriptionChanges() {
const categoryField = document.querySelector('[data-ipn-suggestion="categoryField"]');
const descriptionField = document.querySelector('[data-ipn-suggestion="descriptionField"]');
this.previousDescription = String(this.partDescriptionValue);

if (descriptionField) {
descriptionField.addEventListener("input", () => {
const categoryId = Number(categoryField.value);
const description = String(descriptionField?.value ?? '');

// Check whether the description has changed compared to the previous one
if (description !== this.previousDescription) {
this.fetchNewSuggestions(categoryId, description);
this.previousDescription = description;
}
});
}
}

fetchNewSuggestions(categoryId, description) {
const baseUrl = this.suggestUrlValue;
const partId = this.partIdValue;
const truncatedDescription = description.length > 150 ? description.substring(0, 150) : description;
const encodedDescription = this.base64EncodeUtf8(truncatedDescription);
const url = `${baseUrl}?partId=${partId}&categoryId=${categoryId}` + (description !== '' ? `&description=${encodedDescription}` : '');

fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
})
.then((response) => {
if (!response.ok) {
throw new Error(`Error when calling up the IPN-suggestions: ${response.status}`);
}
return response.json();
})
.then((data) => {
this.suggestionsValue = data;
this.configureAutocomplete();
})
.catch((error) => {
console.error("Errors when loading the new IPN-suggestions:", error);
});
};

base64EncodeUtf8(text) {
const utf8Bytes = new TextEncoder().encode(text);
return btoa(String.fromCharCode(...utf8Bytes));
};
}
2 changes: 1 addition & 1 deletion assets/controllers/elements/part_select_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class extends Controller {

let settings = {
allowEmptyOption: true,
plugins: ['dropdown_input'],
plugins: ['dropdown_input', 'clear_button'],
searchField: ["name", "description", "category", "footprint"],
valueField: "id",
labelField: "name",
Expand Down
Loading