From 026d1e4ac5717493651cf6aa26915dcc5c06888a Mon Sep 17 00:00:00 2001 From: Lucas <lucas.villaume8@etu.univ-lorraine.fr> Date: Sat, 25 Nov 2023 22:39:35 +0100 Subject: [PATCH] Fix quelques bugs --- modele/Cellule.js | 5 ++++- modele/Component.js | 4 +++- modele/Document.js | 5 ++++- modele/Expression.js | 4 +++- modele/Feuille.js | 18 ++++++++++-------- modele/Nombre.js | 6 +++++- modele/Texte.js | 6 +++++- package.json | 2 +- 8 files changed, 35 insertions(+), 15 deletions(-) diff --git a/modele/Cellule.js b/modele/Cellule.js index 35496cc..b0295bc 100644 --- a/modele/Cellule.js +++ b/modele/Cellule.js @@ -1,11 +1,14 @@ +const Component = require("./Component"); + class Cellule extends Component{ #numero; #expression; - constructor(numero) { + constructor(numero, expression = null) { super(); this.#numero = numero; + this.#expression = expression; } setExpression(expression){ diff --git a/modele/Component.js b/modele/Component.js index 6a58328..b4bab16 100644 --- a/modele/Component.js +++ b/modele/Component.js @@ -8,4 +8,6 @@ class Component{ getNom(){ return this.#nom; } -} \ No newline at end of file +} + +module.exports = Component; \ No newline at end of file diff --git a/modele/Document.js b/modele/Document.js index b813ad3..52f6a7f 100644 --- a/modele/Document.js +++ b/modele/Document.js @@ -1,3 +1,6 @@ +const Component = require("./Component"); +const Feuille = require("./Feuille"); + class Document extends Component{ #feuilles; @@ -52,7 +55,7 @@ class Document extends Component{ toJSON(){ let feuillesJSON = []; - feuilles.forEach(feuille => feuillesJSON.push(feuille.toJSON())); + this.#feuilles.forEach(feuille => feuillesJSON.push(feuille.toJSON())); return { id: this.#id, diff --git a/modele/Expression.js b/modele/Expression.js index ef00cd7..860cd42 100644 --- a/modele/Expression.js +++ b/modele/Expression.js @@ -20,4 +20,6 @@ class Expression{ toJSON(){ return this.#contenu; } -} \ No newline at end of file +} + +module.exports = Expression; \ No newline at end of file diff --git a/modele/Feuille.js b/modele/Feuille.js index 80ff5c4..ecfb2c7 100644 --- a/modele/Feuille.js +++ b/modele/Feuille.js @@ -1,17 +1,17 @@ -const e = require("express"); +const Component = require("./Component"); class Feuille extends Component{ #cells; #parent; //objet Document - constructor(){ - super("Sans titre", parent = null); - this.#cells = [[]]; //TODO: définir la taille de la feuille + constructor(parent = null){ + super("Sans titre"); + this.#cells = [[],[]]; //TODO: définir la taille de la feuille } - addCell(cell){ - this.#cells.push(cell); + addCell(cell,row){ + this.#cells[row].push(cell); } removeCell(id){ @@ -23,9 +23,11 @@ class Feuille extends Component{ } toJSON(){ - let cellsJSON = []; - cells.forEach(cell => cellsJSON.push(cell.toJSON())); + + for (let i = 0; i < this.#cells.length; i++){ + this.#cells[i].forEach(cell => cellsJSON.push(cell.toJSON())); + } return { nom: super.getNom(), diff --git a/modele/Nombre.js b/modele/Nombre.js index a27af62..72dffbb 100644 --- a/modele/Nombre.js +++ b/modele/Nombre.js @@ -1,3 +1,5 @@ +const Expression = require("./Expression"); + class Nombre extends Expression{ constructor(content){ @@ -11,4 +13,6 @@ class Nombre extends Expression{ isNombre(){ return true; } -} \ No newline at end of file +} + +module.exports = Nombre; \ No newline at end of file diff --git a/modele/Texte.js b/modele/Texte.js index c30ce27..fc74922 100644 --- a/modele/Texte.js +++ b/modele/Texte.js @@ -1,3 +1,5 @@ +const Expression = require("./Expression"); + class Texte extends Expression{ constructor(content){ @@ -11,4 +13,6 @@ class Texte extends Expression{ isTexte(){ return true; } -} \ No newline at end of file +} + +module.exports = Texte; \ No newline at end of file diff --git a/package.json b/package.json index 0a33d6e..555f42d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "collabsheet", - "version": "0.0.1", + "version": "0.2.1", "description": "Tableau collaboratif", "main": "index.js", "scripts": { -- GitLab