diff --git a/modele/Cellule.js b/modele/Cellule.js index 35496cc4e474cb8127416d803f5fc8e1da1e3262..b0295bc627a2bb7546b6764510e737efdbba5067 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 6a5832899c337b06fe4992d3f4cc687a5a36c045..b4bab166c26bdb8e47c31f7af647e8852248929d 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 b813ad38b267010a79ee1be78cc59ba2e7b18687..52f6a7f0b8621da564d7ec0e5f70fb61dea1ccd4 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 ef00cd7dc72a2bfa595522f769289266262e6b02..860cd42a8adafbb522dcc4a7ccf83e00366c5a49 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 80ff5c4ab53a25feb8f804dd58567f059e14c1af..ecfb2c791a741f5157c260e5b836af252a3a0cc0 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 a27af62042eedc0cd2e6b457d63b284d0400c950..72dffbbbe92a2d51b2167c519957c9c65c9a4fcd 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 c30ce27333fc103f5e2a1406e442bd273d6d1398..fc74922722739317f54e894eca6ecdf82fcf69f7 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 0a33d6e0f7d6b4bbaf162c830fdead40b0eebdca..555f42ddc7b83e8d77932372abffa4a528ab7932 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": {