From 1323d14ec7116e207b69caae3e8dbc91056d7403 Mon Sep 17 00:00:00 2001 From: apoyen <apoyen@grandlyon.com> Date: Wed, 29 Jul 2020 15:01:03 +0200 Subject: [PATCH] Feat : allow to set and update MapID for section --- web/components/management/section.js | 23 +++++++++++++++-------- web/services/model/section-model.js | 3 ++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/web/components/management/section.js b/web/components/management/section.js index a262d7d..18e003d 100644 --- a/web/components/management/section.js +++ b/web/components/management/section.js @@ -106,6 +106,12 @@ class Section { <input class="input" type="text" id="section-modal-name" /> </div> </div> + <div class="field"> + <label>Identifiant de carte</label> + <div class="control"> + <input class="input" type="number" id="section-modal-mapID" /> + </div> + </div> </section> <footer class="modal-card-foot"> <button id="section-modal-save" class="button is-success"> @@ -167,11 +173,9 @@ class Section { }); }); - document - .getElementById(`section-new`) - .addEventListener("click", () => { - this.newSection(this.area); - }); + document.getElementById(`section-new`).addEventListener("click", () => { + this.newSection(this.area); + }); } emptySections() { @@ -231,6 +235,7 @@ class Section { this.area = area; document.getElementById("section-modal-id").value = null; document.getElementById("section-modal-name").value = area.Name; + document.getElementById("section-modal-mapID").value = null; Common.toggleModal("section-modal", "section-modal-card"); } @@ -238,6 +243,7 @@ class Section { this.method = "PUT"; document.getElementById("section-modal-id").value = section.ID; document.getElementById("section-modal-name").value = section.Name; + document.getElementById("section-modal-mapID").value = section.MapID; Common.toggleModal("section-modal", "section-modal-card"); } @@ -250,7 +256,8 @@ class Section { this.method, parseInt(document.getElementById("section-modal-id").value), this.area.ID, - document.getElementById("section-modal-name").value + document.getElementById("section-modal-name").value, + document.getElementById("section-modal-mapID").value ); await this.displaySections(); Common.toggleModal("section-modal", "section-modal-card"); @@ -272,7 +279,6 @@ class Section { await this.SectionModel.deleteSections(section.ID); this.displaySections(); this.parent.deskHandler.emptyDesks(); - document.getElementById("desk-new").setAttribute("disabled", "true"); } async cloneSections(areaCloned, areaToClone) { @@ -286,7 +292,8 @@ class Section { "POST", null, areaCloned.ID, - sectionToClone.Name + sectionToClone.Name, + sectionToClone.MapID ); await sectionHandler.parent.deskHandler.cloneDesks( sectionCloned, diff --git a/web/services/model/section-model.js b/web/services/model/section-model.js index 96c4a28..4c177f3 100644 --- a/web/services/model/section-model.js +++ b/web/services/model/section-model.js @@ -44,7 +44,7 @@ class SectionModel { return this.sections; } - async saveSection(method, ID, AreaID, Name) { + async saveSection(method, ID, AreaID, Name, MapID) { try { const response = await fetch("/api/Section/" + ID, { method: method, @@ -55,6 +55,7 @@ class SectionModel { ID: ID, AreaID: AreaID, Name: Name, + MapID: MapID, }), }); if (response.status !== 200) { -- GitLab