diff --git a/public/js/components/DashboardWidget/Url.js b/public/js/components/DashboardWidget/Url.js index 11502abe4..b2df0d450 100755 --- a/public/js/components/DashboardWidget/Url.js +++ b/public/js/components/DashboardWidget/Url.js @@ -1,81 +1,84 @@ import AbstractWidget from './Abstract'; export default { - name: 'WidgetsUrl', - data: () => ({ - links: null, - title_input: '', - url_input: '', - isPhrasenLoaded: false, - }), - mixins: [ - AbstractWidget - ], - computed: { - tagName() { - return this.config.tag !== undefined && this.config.tag.length > 0 ? this.config.tag : 'Meine Urls'; - } + name: "WidgetsUrl", + data: () => ({ + title_input: "", + url_input: "", + isPhrasenLoaded: false, + }), + mixins: [AbstractWidget], + computed: { + tagName() { + return this.config.tag !== undefined && this.config.tag.length > 0 + ? this.config.tag + : this.$p.t("bookmark", "myBookmarks"); }, - methods: { - async fetchBookmarks(){ - await this.$fhcApi.factory.bookmark.getBookmarks() - .then(res => res.data) - .then(result => { - this.links = result; - }) - .catch(); - }, - async confirmDelete() { - if (await this.$fhcAlert.confirmDelete() === false) - return; - }, - addLink(){ - //let linkId = this.links.length; + emptyBookmarks() { + if (this.shared instanceof Array && this.shared.length == 0) return true; - this.$fhcApi.factory.bookmark.insertBookmark({ - tag: this.config.tag, - title: this.title_input, - url: this.url_input - }) - .then(res => res.data) - .then(result => { - this.$fhcAlert.alertInfo("bookmark added"); - }) - .catch(); + if (!this.shared) return true; - // reset the values for the title and url inputs - this.title_input = ''; - this.url_input = ''; - - // refetch the bookmarks to see the updates - this.fetchBookmarks(); - - }, - async removeLink(bookmark_id){ - await this.confirmDelete(); - this.$fhcApi.factory.bookmark.deleteBookmark(bookmark_id) - .then(res => res.data) - .then(result => { - this.$fhcAlert.alertInfo(this.$p.t('bookmark','bookmarkDeleted')); - }) - .catch(); - - // refetch the bookmarks to see the updates - this.fetchBookmarks(); - } + return false; }, - - created() { - this.$p.loadCategory('bookmark').then(()=>{ - this.isPhrasenLoaded = true; + }, + methods: { + async fetchBookmarks() { + await this.$fhcApi.factory.bookmark + .getBookmarks() + .then((res) => res.data) + .then((result) => { + this.shared = result; }) - //this.links = TEST_LINKS; - // this.links = TEST_KEINE_LINKS; + .catch(); }, - async mounted(){ - await this.fetchBookmarks(); + async confirmDelete() { + if ((await this.$fhcAlert.confirmDelete()) === false) return; }, - template: /*html*/` + addLink() { + this.$fhcApi.factory.bookmark + .insertBookmark({ + tag: this.config.tag, + title: this.title_input, + url: this.url_input, + }) + .then((res) => res.data) + .then((result) => { + this.$fhcAlert.alertInfo("bookmark added"); + }) + .catch(); + + // reset the values for the title and url inputs + this.title_input = ""; + this.url_input = ""; + + // refetch the bookmarks to see the updates + this.fetchBookmarks(); + }, + async removeLink(bookmark_id) { + await this.confirmDelete(); + this.$fhcApi.factory.bookmark + .deleteBookmark(bookmark_id) + .then((res) => res.data) + .then((result) => { + this.$fhcAlert.alertInfo(this.$p.t("bookmark", "bookmarkDeleted")); + }) + .catch(); + + // refetch the bookmarks to see the updates + this.fetchBookmarks(); + }, + }, + + created() { + this.$p.loadCategory("bookmark").then(() => { + this.isPhrasenLoaded = true; + }); + }, + async mounted() { + await this.fetchBookmarks(); + }, + template: /*html*/ `