-
-
+
+
+
+
-
-
+
+
-
-
+
-
-
+
+
-
Guida al Markdown
+
+ Guida al Markdown
+
-
-
+
@@ -124,40 +158,51 @@
-
-
+
+
-
-
Su quali piattaforme vorresti pubblicare l'articolo?
+
+
+ Su quali piattaforme vorresti pubblicare l'articolo?
+
-
+
-
+
-
@@ -211,54 +262,13 @@
aria-labelledby="headingTwo"
data-bs-parent="#accordionAggiungi"
>
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -286,10 +296,11 @@ import "leaflet/dist/leaflet.css";
import "leaflet/dist/leaflet-src.js";
import loggers from "@/plugins/ConsoleLoggers";
import axios from "axios";
-import Cherry from 'cherry-markdown/dist/cherry-markdown.core';
+import Cherry from "cherry-markdown/dist/cherry-markdown.core";
import { API_BASE_URL, checkPagePermission } from "@/plugins/AuthUtils";
import { showToast } from "@/plugins/ToastManager";
-import ArticleListItem from "@/components/ArticleListItem.vue";
+import { getString } from "@/plugins/Translations.js"
+import ArticlesSearchForm from "@/components/ArticlesSearchForm.vue";
library.add(
faChevronRight,
@@ -309,19 +320,20 @@ Marker.prototype.options.icon = icon({
iconAnchor: [12, 41],
popupAnchor: [1, -34],
tooltipAnchor: [16, -28],
- shadowSize: [41, 41],
+ shadowSize: [41, 41]
});
export default {
- components: { ArticleListItem },
+ components: { ArticlesSearchForm },
data() {
return {
articles: [],
canLoadMore: true,
deletedPageOffset: 0,
- articlecontent: {ita: {}, eng: {}},
+ articlecontent: { ita: {}, eng: {} },
cherryInstance: null,
- selectedLanguage: 'ita'
+ selectedLanguage: "ita",
+ requestbody: {}
};
},
mounted() {
@@ -334,14 +346,11 @@ export default {
this.cherryInstance = this.startEditor();
if (store.darkModeEnabled) {
- this.cherryInstance.setTheme('dark');
+ this.cherryInstance.setTheme("dark");
}
-
// First accordion (add articles)
$("#accordionAggiungi").on("show.bs.collapse", function () {
-
-
// Fill the authors select
var array = JSON.parse(JSON.stringify(store.perms));
var authors = JSON.parse(JSON.stringify(store.authorizedauthors));
@@ -371,52 +380,17 @@ export default {
buttons: {
clear: true
}
- },
+ }
}
);
- // Second accordion (remove articles)
- $("#collapseTwo").on("show.bs.collapse", () => {
- idau = 0;
- $("#selectMittenteDel").empty();
- // Fill the authors select
- var array = JSON.parse(JSON.stringify(store.perms));
- var authors = JSON.parse(JSON.stringify(store.authorizedauthors));
-
- $("#selectMittenteDel").append('
');
- array.forEach((perm) => {
- if (perm.grant == "authors") {
- $("#selectMittenteDel").append(
- '
"
- );
- idau++;
- }
- });
-
- // Refresh the list of articles of the selected author
- $("#selectMittenteDel").change(() => {
- this.getArticlesFromAuthor();
- });
-
- // Refresh the list of articles based on the changed title
- $("#titoloArticoloDel").change(() => {
- this.getArticlesFromAuthor();
- });
- });
-
// Fetch categories and fill the select
axios
.get(API_BASE_URL + "/tags")
.then((response) => {
response.data.tags.forEach((cat) => {
- var catname =
- cat.name.charAt(0).toUpperCase() + cat.name.slice(1).toLowerCase();
$("#selectcategoria").append(
- '
"
+ '
"
);
});
})
@@ -425,8 +399,7 @@ export default {
loggers.mainLogger.error("articoli", error);
});
-
- $('#datetimepickerdelay').on('change.td', () => this.isDelayed = true);
+ $("#datetimepickerdelay").on("change.td", () => (this.isDelayed = true));
// INSERTION FORM: On submission, check for field requirements and perform additional check on the image url field
const forms = document.querySelectorAll("#articolo");
@@ -443,14 +416,13 @@ export default {
event.stopPropagation();
// Generate the number from the selected platforms
- var selectedplats = 0
- var allchecks = []
+ var selectedplats = 0;
+ var allchecks = [];
$("#extraplat input").each(function () {
allchecks.push(this);
if (this.checked) {
selectedplats += parseInt(this.value);
}
-
});
// Additional checks
@@ -460,12 +432,12 @@ export default {
// Check if at least one platform is selected
if (selectedplats == 0) {
- allchecks.forEach(element => {
+ allchecks.forEach((element) => {
$(element).addClass("is-invalid");
});
validPlat = false;
} else {
- allchecks.forEach(element => {
+ allchecks.forEach((element) => {
$(element).removeClass("is-invalid");
});
validPlat = true;
@@ -475,19 +447,15 @@ export default {
validBody = this.cherryInstance.getMarkdown() != "";
// Check if the image url is valid
- var thumbnail = "",
- datetime;
+ var datetime;
if (
- $("#copertinaArticolo").val() != "" &&
- !$("#copertinaArticolo")
- .val()
- .match(/^(http|https):\/\/[^ "]+$/)
+ this.requestbody.image != "" &&
+ !this.requestbody.image.match(/^(http|https):\/\/[^ "]+$/)
) {
$("#copertinaArticolo").addClass("is-invalid");
validImageUrl = false;
} else {
$("#copertinaArticolo").removeClass("is-invalid");
- thumbnail = $("#copertinaArticolo").val();
validImageUrl = true;
}
@@ -499,66 +467,67 @@ export default {
$("#submit").attr("disabled", true);
$("#submit").html("Invio...");
- this.articlecontent[this.selectedLanguage].title = $("#titoloArticolo").val();
- this.articlecontent[this.selectedLanguage].subtitle = $("#sottotitoloArticolo").val() || null;
- this.articlecontent[this.selectedLanguage].content = this.cherryInstance.getMarkdown();
-
- var data = {
- content: [
- {
- title: this.articlecontent.ita.title,
- subtitle: this.articlecontent.ita.subtitle,
- content: this.articlecontent.ita.content,
- },
- {
- title: this.articlecontent.eng.title,
- subtitle: this.articlecontent.eng.subtitle,
- content: this.articlecontent.eng.content,
- }
- ],
- author_id: parseInt($("#selectmittente").val()),
- tag: $("#selectcategoria").val(),
- platforms: selectedplats,
- };
+ this.articlecontent[this.selectedLanguage].title =
+ $("#titoloArticolo").val();
+ this.articlecontent[this.selectedLanguage].subtitle =
+ $("#sottotitoloArticolo").val() || null;
+ this.articlecontent[this.selectedLanguage].content =
+ this.cherryInstance.getMarkdown();
+
+ (this.requestbody.content = [
+ {
+ title: this.articlecontent.ita.title,
+ subtitle: this.articlecontent.ita.subtitle,
+ content: this.articlecontent.ita.content
+ },
+ {
+ title: this.articlecontent.eng.title,
+ subtitle: this.articlecontent.eng.subtitle,
+ content: this.articlecontent.eng.content
+ }
+ ]),
+ //author_id: parseInt($("#selectmittente").val()),
+ //tag: $("#selectcategoria").val(),
+ (this.requestbody.platforms = selectedplats);
if (this.articlecontent.eng.title == null) {
- data.content.pop();
+ this.requestbody.content.pop();
}
datetime = window.extraorario.dates;
if (datetime != null) {
- data["target_time"] = datetime.picked[0];
+ this.requestbody.target_time = datetime.picked[0];
}
if (marker != null) {
- data["latitude"] = marker.getLatLng().lat;
- data["longitude"] = marker.getLatLng().lng;
+ this.requestbody.latitude = marker.getLatLng().lat;
+ this.requestbody.longitude = marker.getLatLng().lng;
}
- if (thumbnail != "") {
- data["image"] = thumbnail;
+ if (this.requestbody.image == "") {
+ this.requestbody.image = null;
}
var delayedrelease = window.datetimepickerdelay.dates;
if (delayedrelease.picked.length > 0) {
- data["hidden_until"] = delayedrelease.picked[0];
+ this.requestbody.hidden_until = delayedrelease.picked[0];
}
-
+
axios
- .post(API_BASE_URL + "/articles", data, {
+ .post(API_BASE_URL + "/articles", this.requestbody, {
headers: {
"Content-Type": "application/json",
Authorization:
- "Bearer " + localStorage.getItem("polifemo_access_token"),
- },
+ "Bearer " + localStorage.getItem("polifemo_access_token")
+ }
})
// If the request is successful, show a success toast, close and reset the form
.then(function (response) {
showToast("Articolo creato con successo", "success");
var myCollapse = document.getElementById("collapseOne");
new bootstrap.Collapse(myCollapse, {
- toggle: true,
+ toggle: true
});
form.classList.remove("was-validated");
loggers.mainLogger.info(
@@ -604,11 +573,6 @@ export default {
}
});
- // If an article is deleted, remove it from the list
- this.emitter.on("article-deleted", (id) => {
- this.articles = this.articles.filter((article) => article.id != id);
- });
-
// Initialize extra libraries (leaflet, tempusdominus).
// Only needed if the article needs "extra" fields (location and/or date)
document
@@ -620,7 +584,7 @@ export default {
document.getElementById("extramappa").style.height = "400px";
mappa = L.map("extramappa").setView([45.47812, 9.22818], 18);
L.tileLayer("https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", {
- maxZoom: 20,
+ maxZoom: 20
}).addTo(mappa);
mappa.on("click", function (e) {
@@ -634,8 +598,8 @@ export default {
document.getElementById("extraorario"),
{
display: {
- theme: store.darkModeEnabled ? "dark" : "light", // Display the correct theme based on the stored preference
- },
+ theme: store.darkModeEnabled ? "dark" : "light" // Display the correct theme based on the stored preference
+ }
}
);
@@ -654,94 +618,28 @@ export default {
},
methods: {
- getArticlesFromAuthor(more) {
- var id = $("#selectMittenteDel").val();
- var titolo = $("#titoloArticoloDel").val();
- // The empty author is selected
- if (id == 0) {
- return;
- }
- if (more) {
- this.deletedPageOffset++;
- $("#loadMore").html(
- "
"
- );
- }
-
- $("#loading").removeClass("d-none");
- var path =
- "/articles?author_id=" +
- id +
- "&limit=3&sort=date&platform=3&pageOffset=" +
- this.deletedPageOffset;
- if (titolo != "") {
- this.deletedPageOffset = 0;
- path += "&title=" + titolo;
- }
- axios
- .get(API_BASE_URL + path)
- .then(
- (response) => {
- if (more) {
- this.articles = this.articles.concat(response.data.articles);
- } else {
- this.articles = [];
- this.articles = response.data.articles;
- }
- if (response.data.articles.length < 3) {
- this.canLoadMore = false;
- } else {
- this.canLoadMore = true;
- }
- },
- (error) => {
- if (error.response.status == 404) {
- if (more) {
- this.canLoadMore = false;
- return;
- }
- this.articles = [];
- showToast("Nessun articolo trovato", "info");
- return;
- } else {
- loggers.mainLogger.error(
- "articoli",
- "Error while fetching articles"
- );
- loggers.mainLogger.error("articoli", error);
- showToast(
- "Errore nel caricamento degli articoli: " +
- (error.response.data.error || error.response.data.title),
- "error"
- );
- }
- }
- )
- .finally(() => {
- $("#loading").addClass("d-none");
- $("#loadMore").html("Carica altri");
- });
- return;
- },
saveAndLoadArticleContent(el) {
// If the button clicked is the english one, save the italian content and load the english one
if (el.id == "btnradioita") {
this.articlecontent.eng.title = $("#titoloArticolo").val();
- this.articlecontent.eng.subtitle = $("#sottotitoloArticolo").val();
+ this.articlecontent.eng.subtitle = $("#sottArticolo").val();
this.articlecontent.eng.content = this.cherryInstance.getMarkdown();
$("#titoloArticolo").val(this.articlecontent.ita.title);
- $("#sottotitoloArticolo").val(this.articlecontent.ita.subtitle);
- this.cherryInstance = this.startEditor(this.articlecontent.ita.content || "");
-
+ $("#sottArticolo").val(this.articlecontent.ita.subtitle);
+ this.cherryInstance = this.startEditor(
+ this.articlecontent.ita.content || ""
+ );
} else {
this.articlecontent.ita.title = $("#titoloArticolo").val();
- this.articlecontent.ita.subtitle = $("#sottotitoloArticolo").val();
+ this.articlecontent.ita.subtitle = $("#sottArticolo").val();
this.articlecontent.ita.content = this.cherryInstance.getMarkdown();
$("#titoloArticolo").val(this.articlecontent.eng.title);
- $("#sottotitoloArticolo").val(this.articlecontent.eng.subtitle);
- this.cherryInstance = this.startEditor(this.articlecontent.eng.content || "");
+ $("#sottArticolo").val(this.articlecontent.eng.subtitle);
+ this.cherryInstance = this.startEditor(
+ this.articlecontent.eng.content || ""
+ );
///this.startEditor(this.cherryInstance, this.articlecontent.eng.content || "# hello");
}
},
@@ -751,35 +649,45 @@ export default {
var editor = $("#editor-wrapper").children()[0];
$(editor).remove();
//$("#editor-wrapper").empty();
- $("#editor-wrapper").append("
");
-
+ $("#editor-wrapper").append(
+ "
"
+ );
+
return new Cherry({
- id: 'markdown-editor',
- value: value || '',
+ id: "markdown-editor",
+ value: value || "",
toolbars: {
showToolbar: true,
toolbar: [
- 'bold',
- 'italic',
- 'strikethrough',
- 'underline',
- 'sub',
- 'sup',
- 'quote',
- '|',
- 'size',
- '|',
- 'checklist',
- 'list',
- 'link',
- 'table'
+ "bold",
+ "italic",
+ "strikethrough",
+ "underline",
+ "sub",
+ "sup",
+ "quote",
+ "|",
+ "size",
+ "|",
+ "checklist",
+ "list",
+ "link",
+ "table"
+ ],
+ bubble: [
+ "bold",
+ "italic",
+ "underline",
+ "strikethrough",
+ "sub",
+ "sup",
+ "quote"
],
- bubble: ['bold', 'italic', 'underline', 'strikethrough', 'sub', 'sup', 'quote'],
float: []
},
- locale: 'en_US'
+ locale: "en_US"
});
}
- },
+ }
};
diff --git a/src/views/PermissionsView.vue b/src/views/PermissionsView.vue
index a9417bf..6d921ea 100644
--- a/src/views/PermissionsView.vue
+++ b/src/views/PermissionsView.vue
@@ -14,7 +14,7 @@
Attenzione!
-
diff --git a/vite.config.js b/vite.config.js
index 0fbfa5a..7979718 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -8,7 +8,7 @@ export default defineConfig({
base: "/",
resolve: {
alias: {
- "@": fileURLToPath(new URL("./src", import.meta.url)),
- },
- },
+ "@": fileURLToPath(new URL("./src", import.meta.url))
+ }
+ }
});