Added functionality to select article.
This commit is contained in:
@@ -91,11 +91,11 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
|
||||
// Article
|
||||
async loadArticle(articleID: number) {
|
||||
try {
|
||||
const entity: Article = await $fetch<Article>(this.config.public.url + '/article/' + articleID, {
|
||||
const article: Article = await $fetch<Article>(this.config.public.url + '/article/' + articleID, {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
this.article = entity;
|
||||
this.article = article;
|
||||
this.addNotification(false, 'Artikel geladen: ' + this.article.name);
|
||||
} catch {
|
||||
this.article = null;
|
||||
@@ -103,6 +103,22 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
|
||||
}
|
||||
},
|
||||
|
||||
// TODO: Check if function from view can be replaced with store method
|
||||
async loadArticles(): Promise<Array<Article>> {
|
||||
console.log("Test");
|
||||
try {
|
||||
const articles: Array<Article> = await $fetch<Array<Article>>(this.config.public.url + '/articles', {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
this.addNotification(false, 'Artikelliste geladen');
|
||||
return articles;
|
||||
} catch {
|
||||
this.addNotification(true, 'Fehler beim laden der Artikeliste');
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
async createArticle(article: Article) {
|
||||
try {
|
||||
this.article = await $fetch<Article>(this.config.public.url + '/article', {
|
||||
@@ -132,9 +148,5 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
|
||||
this.addNotification(true, 'Es ist kein Artikel ausgewählt');
|
||||
}
|
||||
},
|
||||
|
||||
clearEntity() {
|
||||
this.article = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user