From 77f9c7a6a31600e820425acc266f90bbc467da97 Mon Sep 17 00:00:00 2001 From: Henintsoa Date: Tue, 16 Nov 2021 13:17:46 +0300 Subject: [PATCH] FIrst version carto debat --- src/main/webapp/assets/js/router.js | 2 +- src/main/webapp/assets/js/service/aren.js | 7 + src/main/webapp/assets/js/service/i18n.js | 2 +- src/main/webapp/assets/js/views/cartoTest.vue | 569 --------------- .../assets/js/views/createDebateSurCarte.vue | 2 +- .../webapp/assets/js/views/debateSurCarte.vue | 651 ++++++++++++++++++ .../assets/js/views/debatesSurCarte.vue | 4 +- .../js/views/documentDebatesSurCarte.vue | 46 +- src/main/webapp/assets/js/views/documents.vue | 2 +- .../js/views/documentsDebatesSurCarte.vue | 9 +- src/main/webapp/index.jsp | 12 +- 11 files changed, 713 insertions(+), 593 deletions(-) delete mode 100644 src/main/webapp/assets/js/views/cartoTest.vue create mode 100644 src/main/webapp/assets/js/views/debateSurCarte.vue diff --git a/src/main/webapp/assets/js/router.js b/src/main/webapp/assets/js/router.js index 32bca47..9e41cfc 100644 --- a/src/main/webapp/assets/js/router.js +++ b/src/main/webapp/assets/js/router.js @@ -21,11 +21,11 @@ const router = new VueRouter({ {path: '/votemajoritaire', component: vueLoader('views/votemajoritaire')}, {path: '/createVoteMajoritaire', component: vueLoader('views/createVoteMajoritaire')}, {path: '/votemajoritairedetails', component: vueLoader('views/votemajoritairedetails')}, - {path: '/carto', component: vueLoader('views/cartoTest')}, {path: '/creation-debats-sur-cartes', component: vueLoader('views/createDebateSurCarte')}, {path: '/documents-debats-sur-cartes', component: vueLoader('views/documentsDebatesSurCarte')}, {path: '/documents-debats-sur-cartes/:id', component: vueLoader('views/documentDebatesSurCarte')}, {path: '/debats-sur-cartes', component: vueLoader('views/debatesSurCarte')}, + {path: '/debats-sur-cartes/:id', component: vueLoader('views/debateSurCarte')}, {path: '*', component: vueLoader('views/404')}, ] }); \ No newline at end of file diff --git a/src/main/webapp/assets/js/service/aren.js b/src/main/webapp/assets/js/service/aren.js index 676889c..58a5ff0 100644 --- a/src/main/webapp/assets/js/service/aren.js +++ b/src/main/webapp/assets/js/service/aren.js @@ -120,11 +120,13 @@ function Entity(obj = {}) { function Category(obj = {}) { Entity.call(this, obj); + this.type = DebateType.BASIC; } Category.prototype.attrs = { id: Number, name: String, picture: String, + type: String, debatesCount: Number, lastCommentDate: Date, }; @@ -134,10 +136,15 @@ Category.prototype.oneToMany = { Category.prototype.debates = function () { return this.documents.map((document) => document.debates).flat(); }; +Category.prototype.is = function (type) { + return DebateType._value[this.type] == DebateType._value[type]; +} function Document(obj = {}) { Entity.call(this, obj); this.type = DebateType.BASIC; + this.meshLine = 1; + this.meshColumn = 1; } Document.prototype.attrs = { id: Number, diff --git a/src/main/webapp/assets/js/service/i18n.js b/src/main/webapp/assets/js/service/i18n.js index 44089ae..d420251 100644 --- a/src/main/webapp/assets/js/service/i18n.js +++ b/src/main/webapp/assets/js/service/i18n.js @@ -102,7 +102,7 @@ const messages = { guests: "Invité⋅e⋅s", debates: "Débats", new_debate: "Nouveau débat", - new_map_debate: "Nouveau débat sur caarte", + new_map_debate: "Nouveau débat sur carte", invite_in_debate: "Inviter au débat", SUPERADMIN: "Super administrateur⋅rice", SUPERADMIN: "Root", diff --git a/src/main/webapp/assets/js/views/cartoTest.vue b/src/main/webapp/assets/js/views/cartoTest.vue deleted file mode 100644 index fe6b7e3..0000000 --- a/src/main/webapp/assets/js/views/cartoTest.vue +++ /dev/null @@ -1,569 +0,0 @@ - - - diff --git a/src/main/webapp/assets/js/views/createDebateSurCarte.vue b/src/main/webapp/assets/js/views/createDebateSurCarte.vue index 24cd605..a2bff25 100644 --- a/src/main/webapp/assets/js/views/createDebateSurCarte.vue +++ b/src/main/webapp/assets/js/views/createDebateSurCarte.vue @@ -196,7 +196,7 @@ data( ) { return { debate: new Debate( ), - categories: ArenService.Store.Category, + categories: ArenService.Store.Category.filter(cat=>cat.is('CARTO')), institution: new Institution( ), search: "", step: 0, diff --git a/src/main/webapp/assets/js/views/debateSurCarte.vue b/src/main/webapp/assets/js/views/debateSurCarte.vue new file mode 100644 index 0000000..34948e3 --- /dev/null +++ b/src/main/webapp/assets/js/views/debateSurCarte.vue @@ -0,0 +1,651 @@ + + + diff --git a/src/main/webapp/assets/js/views/debatesSurCarte.vue b/src/main/webapp/assets/js/views/debatesSurCarte.vue index 1fd87df..32bb6f3 100644 --- a/src/main/webapp/assets/js/views/debatesSurCarte.vue +++ b/src/main/webapp/assets/js/views/debatesSurCarte.vue @@ -60,7 +60,9 @@ query: categoryId ? {category: categoryId, overview: true} : {overview: true}, onSuccess: debates => debates.forEach(d => { if (!this.categories.includes(d.document.category)) { - this.categories.push(d.document.category) + if(d.document.category.is("CARTO")){ + this.categories.push(d.document.category); + } } }) }); diff --git a/src/main/webapp/assets/js/views/documentDebatesSurCarte.vue b/src/main/webapp/assets/js/views/documentDebatesSurCarte.vue index 4d07eda..6e74581 100644 --- a/src/main/webapp/assets/js/views/documentDebatesSurCarte.vue +++ b/src/main/webapp/assets/js/views/documentDebatesSurCarte.vue @@ -26,6 +26,7 @@ -
+
- +
- +
- +
map image - + @@ -142,8 +142,8 @@ module.exports = { editionMode: false, selectedCarto: null, imgUrl: null, - nbOfLines: 0, - nbOfColumns: 0, + // nbOfLines: 0, + // nbOfColumns: 0, }; }, created() { @@ -163,12 +163,16 @@ module.exports = { onSuccess: (document) => { this.document = document; this.copyDocument(this.document, this.unmodifiedDocument); + this.imgUrl = document.mapLink; }, }); } else { this.document = new Document(); + this.document.type = "CARTO"; + this.document.mapLink=""; this.document.category = new Category(); this.document.category.id = this.$route.query.category; + this.document.category.type = "CARTO"; this.editionMode = true; } }, @@ -181,6 +185,7 @@ module.exports = { }, saveDocument() { this.editionMode = false; + //this.document.mapLink = this.getBase64Image(); ArenService.Documents.createOrUpdate({ data: this.document, onSuccess: (document) => { @@ -199,7 +204,28 @@ module.exports = { const file = event.target.files[0]; this.selectedCarto = file; this.imgUrl = URL.createObjectURL(file); + this.document.mapLink = this.getBase64Image(); }, + getBase64Image() { + // Create an empty canvas element + let img = document.getElementById("mapImg"); + var canvas = document.createElement("canvas"); + canvas.width = img.width; + canvas.height = img.height; + + // Copy the image contents to the canvas + var ctx = canvas.getContext("2d"); + ctx.drawImage(img, 0, 0); + + // Get the data-URL formatted image + // Firefox supports PNG and JPEG. You could check img.src to + // guess the original format, but be aware the using "image/jpg" + // will re-encode the image. + var dataURL = canvas.toDataURL("image/png"); + //let dt = dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); + console.log(dataURL); + return dataURL; + } }, components: { "wysiwyg-editor": vueLoader("components/widgets/wysiwygEditor"), diff --git a/src/main/webapp/assets/js/views/documents.vue b/src/main/webapp/assets/js/views/documents.vue index 71625ac..5239dc1 100644 --- a/src/main/webapp/assets/js/views/documents.vue +++ b/src/main/webapp/assets/js/views/documents.vue @@ -65,7 +65,7 @@ module.exports = { data( ) { return { - categories: ArenService.Store.Category + categories: ArenService.Store.Category.filter(cat=>!cat.is('CARTO')) }; }, created( ) { diff --git a/src/main/webapp/assets/js/views/documentsDebatesSurCarte.vue b/src/main/webapp/assets/js/views/documentsDebatesSurCarte.vue index 4ab7434..fef743d 100644 --- a/src/main/webapp/assets/js/views/documentsDebatesSurCarte.vue +++ b/src/main/webapp/assets/js/views/documentsDebatesSurCarte.vue @@ -65,7 +65,7 @@ module.exports = { data( ) { return { - categories: ArenService.Store.Category + categories: ArenService.Store.Category.filter(cat=>cat.is('CARTO')) }; }, created( ) { @@ -84,14 +84,17 @@ name: document.name + " - copie", author: document.author, content: document.content, - category: {id: document.category.id} + category: {id: document.category.id, type: "CARTO"} }); ArenService.Documents.duplicate({ id: document.id }); }, createOrUpdateCategory(category = {}) { - this.$refs.categoryModal.category = new Category(category); + let catg = new Category(category); + catg.type = "CARTO" + this.$refs.categoryModal.category = catg; + console.log(this.$refs.categoryModal.category); this.$refs.categoryModal.open((updatedCat) => { if (updatedCat) { ArenService.Categories.createOrUpdate({ diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 7850e00..3394055 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -111,14 +111,14 @@
  • Votes majoritaires
  • -
  • - Ouvrir un débat sur carte +
  • + Ouvrir dc
  • -
  • - Mes documents de débat sur carte +
  • + Mes documents dc
  • -
  • - Mes débats sur carte +
  • + Débats sur carte