Skip to content

Commit 6c29432

Browse files
author
Marcel Diegelmann
committed
Füge Baugruppen hinzu
1 parent c735bfd commit 6c29432

128 files changed

Lines changed: 32961 additions & 9218 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import {Controller} from "@hotwired/stimulus";
2+
3+
import "tom-select/dist/css/tom-select.bootstrap5.css";
4+
import '../../css/components/tom-select_extensions.css';
5+
import TomSelect from "tom-select";
6+
import {marked} from "marked";
7+
8+
export default class extends Controller {
9+
_tomSelect;
10+
11+
connect() {
12+
13+
let settings = {
14+
allowEmptyOption: true,
15+
plugins: ['dropdown_input', 'clear_button'],
16+
searchField: ["name", "description", "category", "footprint"],
17+
valueField: "id",
18+
labelField: "name",
19+
preload: "focus",
20+
render: {
21+
item: (data, escape) => {
22+
return '<span>' + (data.image ? "<img style='height: 1.5rem; margin-right: 5px;' ' src='" + data.image + "'/>" : "") + escape(data.name) + '</span>';
23+
},
24+
option: (data, escape) => {
25+
if(data.text) {
26+
return '<span>' + escape(data.text) + '</span>';
27+
}
28+
29+
let tmp = '<div class="row m-0">' +
30+
"<div class='col-2 p-0 d-flex align-items-center' style='max-width: 80px;'>" +
31+
(data.image ? "<img class='typeahead-image' src='" + data.image + "'/>" : "") +
32+
"</div>" +
33+
"<div class='col-10'>" +
34+
'<h6 class="m-0">' + escape(data.name) + '</h6>' +
35+
(data.description ? '<p class="m-0">' + marked.parseInline(data.description) + '</p>' : "") +
36+
(data.category ? '<p class="m-0"><span class="fa-solid fa-tags fa-fw"></span> ' + escape(data.category) : "");
37+
38+
return tmp + '</p>' +
39+
'</div></div>';
40+
}
41+
}
42+
};
43+
44+
45+
if (this.element.dataset.autocomplete) {
46+
const base_url = this.element.dataset.autocomplete;
47+
settings.valueField = "id";
48+
settings.load = (query, callback) => {
49+
const url = base_url.replace('__QUERY__', encodeURIComponent(query));
50+
51+
fetch(url)
52+
.then(response => response.json())
53+
.then(json => {callback(json);})
54+
.catch(() => {
55+
callback()
56+
});
57+
};
58+
59+
60+
this._tomSelect = new TomSelect(this.element, settings);
61+
//this._tomSelect.clearOptions();
62+
}
63+
}
64+
65+
disconnect() {
66+
super.disconnect();
67+
//Destroy the TomSelect instance
68+
this._tomSelect.destroy();
69+
}
70+
}

assets/controllers/elements/part_select_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class extends Controller {
1212

1313
let settings = {
1414
allowEmptyOption: true,
15-
plugins: ['dropdown_input'],
15+
plugins: ['dropdown_input', 'clear_button'],
1616
searchField: ["name", "description", "category", "footprint"],
1717
valueField: "id",
1818
labelField: "name",
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Controller } from "@hotwired/stimulus";
2+
3+
export default class extends Controller {
4+
5+
static values = {
6+
classes: Array
7+
};
8+
9+
connect() {
10+
this.displayCheckbox = this.element.querySelector("#display");
11+
this.displaySelect = this.element.querySelector("select#display");
12+
13+
if (this.displayCheckbox) {
14+
this.toggleContainers(this.displayCheckbox.checked);
15+
16+
this.displayCheckbox.addEventListener("change", (event) => {
17+
this.toggleContainers(event.target.checked);
18+
});
19+
}
20+
21+
if (this.displaySelect) {
22+
this.toggleContainers(this.hasDisplaySelectValue());
23+
24+
this.displaySelect.addEventListener("change", () => {
25+
this.toggleContainers(this.hasDisplaySelectValue());
26+
});
27+
}
28+
29+
}
30+
31+
/**
32+
* Check whether a value was selected in the selectbox
33+
* @returns {boolean} True when a value has not been selected that is not empty
34+
*/
35+
hasDisplaySelectValue() {
36+
return this.displaySelect && this.displaySelect.value !== "";
37+
}
38+
39+
/**
40+
* Hides specified containers if the state is active (checkbox checked or select with value).
41+
*
42+
* @param {boolean} isActive - True when the checkbox is activated or the selectbox has a value.
43+
*/
44+
toggleContainers(isActive) {
45+
if (!Array.isArray(this.classesValue) || this.classesValue.length === 0) {
46+
return;
47+
}
48+
49+
this.classesValue.forEach((cssClass) => {
50+
const elements = document.querySelectorAll(`.${cssClass}`);
51+
52+
if (!elements.length) {
53+
return;
54+
}
55+
56+
elements.forEach((element) => {
57+
element.style.display = isActive ? "none" : "";
58+
});
59+
});
60+
}
61+
62+
}

assets/controllers/pages/dont_check_quantity_checkbox_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default class extends Controller {
3838

3939
connect() {
4040
//Add event listener to the checkbox
41-
this.getCheckbox().addEventListener('change', this.toggleInputLimits.bind(this));
41+
this.getCheckbox()?.addEventListener('change', this.toggleInputLimits.bind(this));
4242
}
4343

4444
toggleInputLimits() {

assets/css/app/images.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@
6161
.object-fit-cover {
6262
object-fit: cover;
6363
}
64+
65+
.assembly-table-image {
66+
max-height: 40px;
67+
object-fit: contain;
68+
}

assets/js/lib/datatables.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
//CHANGED jbtronics: Preserve the get parameters (needed so we can pass additional params to query)
1919
$.fn.initDataTables.defaults.url = window.location.origin + window.location.pathname + window.location.search;
2020

21+
$.fn.dataTable.ext.errMode = function(settings, helpPage, message) {
22+
if (message.includes('ColReorder')) {
23+
console.warn('ColReorder does not fit the number of columns', message);
24+
}
25+
};
26+
2127
var root = this,
2228
config = $.extend({}, $.fn.initDataTables.defaults, config),
2329
state = ''
@@ -105,7 +111,6 @@
105111
}
106112
}
107113

108-
109114
root.html(data.template);
110115
dt = $('table', root).DataTable(dtOpts);
111116
if (config.state !== 'none') {

config/permissions.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ perms: # Here comes a list with all Permission names (they have a perm_[name] co
121121
<<: *PART_CONTAINING
122122
label: "perm.projects"
123123

124+
assemblies:
125+
<<: *PART_CONTAINING
126+
label: "perm.assemblies"
127+
124128
attachment_types:
125129
<<: *PART_CONTAINING
126130
label: "perm.part.attachment_types"

config/services.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ services:
164164
arguments:
165165
$saml_enabled: '%partdb.saml.enabled%'
166166

167+
App\Validator\Constraints\AssemblySystem\AssemblyCycleValidator:
168+
tags: [ 'validator.constraint_validator' ]
169+
167170
####################################################################################################################
168171
# Table settings
169172
####################################################################################################################

docs/configuration.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ bundled with Part-DB. Set `DATABASE_MYSQL_SSL_VERIFY_CERT` if you want to accept
137137
time).
138138
Also specify the default order of the columns. This is a comma separated list of column names. Available columns
139139
are: `name`, `id`, `ipn`, `description`, `category`, `footprint`, `manufacturer`, `storage_location`, `amount`, `minamount`, `partUnit`, `addedDate`, `lastModified`, `needs_review`, `favorite`, `manufacturing_status`, `manufacturer_product_number`, `mass`, `tags`, `attachments`, `edit`.
140+
* `TABLE_ASSEMBLIES_DEFAULT_COLUMNS`: The columns in assemblies tables, which are visible by default (when loading table for first time).
141+
Also specify the default order of the columns. This is a comma separated list of column names. Available columns
142+
are: `name`, `id`, `ipn`, `description`, `referencedAssemblies`, `edit`, `addedDate`, `lastModified`.
143+
* `TABLE_ASSEMBLIES_BOM_DEFAULT_COLUMNS`: The columns in assemblies bom tables, which are visible by default (when loading table for first time).
144+
Also specify the default order of the columns. This is a comma separated list of column names. Available columns
145+
are: `quantity`, `name`, `id`, `ipn`, `description`, `category`, `footprint`, `manufacturer`, `designator`, `mountnames`, `storage_location`, `amount`, `addedDate`, `lastModified`.
146+
* `CREATE_ASSEMBLY_USE_IPN_PLACEHOLDER_IN_NAME`: Use an %%ipn%% placeholder in the name of a assembly. Placeholder is replaced with the ipn input while saving.
140147

141148
### History/Eventlog-related settings
142149

0 commit comments

Comments
 (0)