Include IFC file name

TODO: move UI routines to Stimulus
This commit is contained in:
Nicolò P 2025-04-02 17:29:54 +02:00
parent 34d1506483
commit 96bb0388a8
4 changed files with 12 additions and 1 deletions

View File

@ -16,7 +16,12 @@ export default class extends Controller {
if (event.currentTarget === this.buildingFormTarget) {
const options = this.prepare(
JSON.stringify({name: this.buildingTarget.value}),
JSON.stringify(
{
name: this.buildingTarget.value,
ifc: localStorage.getItem('loaded-ifc'),
}
),
'POST'
);

View File

@ -3,6 +3,7 @@
import BIM from './bim.js';
/**
* @todo Move to Stimulus?
* @namespace UI
*/
const UI = {};
@ -20,12 +21,15 @@ UI.setScene = function (container) {
*/
UI.ifcLoader = function (container, btnId = 'load-ifc') {
const loadBtn = document.querySelector(`#${btnId}`);
const nameInput = document.querySelector('[data-form-target="building"]');
let model = null;
loadBtn.onchange = async function () {
const files = this.files;
model = await BIM.loadIfc(new Uint8Array(await files[0].arrayBuffer()), files[0].name);
// Set a raycaster to select objects
BIM.setupHighligther(model);
localStorage.setItem('loaded-ifc', files[0].name);
nameInput.value = files[0].name.replace('.ifc', '');
}
return model;

View File

@ -54,6 +54,7 @@ final class ProjectController extends AbstractController
$project = new Project();
$project->setUser($user);
$project->setBuilding($building);
$project->setIfc($data->get('ifc'));
$project->setCreatedAt($datetime);
$project->setLastModified($datetime);
$em->persist($project);

View File

@ -28,6 +28,7 @@
</label>
</div>
<form class="form" data-form-target="buildingForm" data-action="submit->form#submit" method="post">
<label class="label">Nome edificio</label>
<div class="field has-addons">
<div class="control">
<input class="input" type="text"