Merge pull request #5177 from christianbeeznest/ofaj-21101-11

Social: Add fixes and improve Personal File Component - refs BT#21101
pull/5178/head
christianbeeznest 9 months ago committed by GitHub
commit 7180352a8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      assets/vue/mixins/ListMixin.js
  2. 3
      assets/vue/mixins/ShowMixin.js
  3. 5
      assets/vue/router/personalfile.js
  4. 126
      assets/vue/views/personalfile/List.vue
  5. 21
      assets/vue/views/personalfile/Shared.vue
  6. 4
      assets/vue/views/personalfile/Show.vue
  7. 6
      assets/vue/views/personalfile/Update.vue
  8. 9
      assets/vue/views/personalfile/Upload.vue
  9. 15
      src/CoreBundle/Entity/PersonalFile.php

@ -51,7 +51,10 @@ export default {
},
deletedResource(item) {
this.showMessage(this.$i18n.t('{resource} deleted', {'resource': item['resourceNode'].title}));
const message = this.$i18n && this.$i18n.t
? this.$t('{resource} created', {'resource': item['resourceNode'].title})
: `${item['resourceNode'].title} created`;
this.showMessage(message);
this.onUpdateOptions(this.options);
},

@ -53,6 +53,9 @@ export default {
},
},
methods: {
goBack() {
this.$router.go(-1);
},
list() {
console.log('show mixin list');
this.$router

@ -15,11 +15,6 @@ export default {
path: '',
component: () => import('../views/personalfile/List.vue')
},
// {
// name: 'PersonalFileCreate',
// path: 'new',
// component: () => import('../views/personalfile/Create.vue')
// },
{
name: 'PersonalFileUploadFile',
path: 'upload',

@ -24,7 +24,7 @@
@click="sharedDocumentHandler()"
/>
<Button
:disabled="!selectedItems || !selectedItems.length"
v-if="selectedItems.length"
class="btn btn--danger"
icon="pi pi-trash"
label="Delete"
@ -108,13 +108,13 @@
<div class="flex flex-row gap-2">
<Button
class="btn btn--primary"
icon="fa fa-info-circle"
icon="pi pi-info-circle"
@click="showHandler(slotProps.data)"
/>
<Button
v-if="isAuthenticated"
class="btn btn--primary p-mr-2"
icon="pi pi-pencil"
icon="pi pi-share-alt"
@click="editHandler(slotProps.data)"
/>
<Button
@ -131,6 +131,7 @@
<template #body="slotProps">
<div class="flex flex-row gap-2">
<Button
v-if="isFromEditor"
class="p-button-sm p-button p-mr-2"
label="Select"
@click="returnToEditor(slotProps.data)"
@ -138,13 +139,6 @@
</div>
</template>
</Column>
<!-- <template #paginatorLeft>-->
<!-- <Button type="button" icon="pi pi-refresh" class="p-button-text" />-->
<!-- </template>-->
<!-- <template #paginatorRight>-->
<!-- <Button type="button" icon="pi pi-cloud" class="p-button-text" />-->
<!-- </template>-->
</DataTable>
<Dialog
@ -187,35 +181,14 @@
</template>
</Dialog>
<Dialog
v-model:visible="deleteItemDialog"
:modal="true"
:style="{ width: '450px' }"
header="Confirm"
>
<Dialog v-model:visible="deleteItemDialog" :modal="true" :style="{ width: '450px' }" header="Confirm">
<div class="confirmation-content">
<i
class="pi pi-exclamation-triangle p-mr-3"
style="font-size: 2rem"
/>
<span v-if="item"
>Are you sure you want to delete <b>{{ item.title }}</b
>?</span
>
<i class="pi pi-exclamation-triangle p-mr-3" style="font-size: 2rem"></i>
<span>Are you sure you want to delete <b>{{ itemToDelete?.title }}</b>?</span>
</div>
<template #footer>
<Button
class="p-button-text"
icon="pi pi-times"
label="No"
@click="deleteItemDialog = false"
/>
<Button
class="p-button-text"
icon="pi pi-check"
label="Yes"
@click="deleteItemButton"
/>
<Button class="p-button-text" icon="pi pi-times" label="No" @click="deleteItemDialog = false" />
<Button class="p-button-text" icon="pi pi-check" label="Yes" @click="deleteItemButton" />
</template>
</Dialog>
@ -230,7 +203,7 @@
class="pi pi-exclamation-triangle p-mr-3"
style="font-size: 2rem"
/>
<span v-if="item">Are you sure you want to delete the selected items?</span>
<span v-if="item">{{ $t('Are you sure you want to delete the selected items?') }}</span>
</div>
<template #footer>
<Button
@ -247,6 +220,19 @@
/>
</template>
</Dialog>
<Dialog v-model:visible="detailsDialogVisible" :header="selectedItem.title || 'Item Details'" :modal="true" :style="{ width: '50%' }">
<div v-if="Object.keys(selectedItem).length > 0">
<p><strong>Title:</strong> {{ selectedItem.resourceNode.title }}</p>
<p><strong>Modified:</strong> {{ relativeDatetime(selectedItem.resourceNode.updatedAt) }}</p>
<p><strong>Size:</strong> {{ prettyBytes(selectedItem.resourceNode.resourceFile.size) }}</p>
<p><strong>URL:</strong> <a :href="selectedItem.contentUrl" target="_blank">Open File</a></p>
</div>
<template #footer>
<Button class="p-button-text" label="Close" @click="closeDetailsDialog" />
</template>
</Dialog>
</template>
<script>
@ -267,11 +253,9 @@ export default {
name: "PersonalFileList",
servicePrefix: "PersonalFile",
components: {
//8Toolbar,
ActionCell,
ResourceIcon,
ResourceFileLink,
//DocumentsFilterForm,
DataFilter,
},
mixins: [ListMixin],
@ -311,14 +295,13 @@ export default {
options: [],
selectedItems: [],
// prime vue
itemDialog: false,
deleteItemDialog: false,
deleteMultipleDialog: false,
item: {},
filters: { shared: 0, loadNode: 1 },
submitted: false,
prettyBytes,
relativeDatetime
relativeDatetime,
t,
}
return data
@ -326,11 +309,8 @@ export default {
created() {
this.resetList = true
this.onUpdateOptions(this.options)
this.isFromEditor = window.location.search.includes('editor=tinymce');
},
/*mounted() {
this.resetList = true;
this.onUpdateOptions(this.options);
},*/
computed: {
// From crud.js list function
...mapGetters("resourcenode", {
@ -358,7 +338,24 @@ export default {
view: "view",
}),
},
data() {
return {
itemDialog: false,
detailsDialogVisible: false,
deleteItemDialog: false,
selectedItem: {},
itemToDelete: null,
isFromEditor: false,
};
},
methods: {
showHandler(item) {
this.selectedItem = item;
this.detailsDialogVisible = true;
},
closeDetailsDialog() {
this.detailsDialogVisible = false;
},
// prime
onPage(event) {
this.options.itemsPerPage = event.rows
@ -405,7 +402,7 @@ export default {
gid: 0,
sid: 0,
cid: 0,
visibility: RESOURCE_LINK_PUBLISHED, // visible by default
visibility: RESOURCE_LINK_PUBLISHED,
},
])
@ -422,7 +419,9 @@ export default {
this.itemDialog = true
},
confirmDeleteItem(item) {
this.item = item
console.log('confirmDeleteItem :::', item)
this.item = { ...item }
this.itemToDelete = { ...item }
this.deleteItemDialog = true
},
confirmDeleteMultiple() {
@ -437,15 +436,24 @@ export default {
})
this.deleteMultipleDialog = false
this.selectedItems = null
//this.$toast.add({severity:'success', summary: 'Successful', detail: 'Products Deleted', life: 3000});*/
},
deleteItemButton() {
console.log("deleteItem")
this.deleteItem(this.item)
//this.items = this.items.filter(val => val.iid !== this.item.iid);
this.deleteItemDialog = false
this.item = {}
this.onUpdateOptions(this.options)
console.log("deleteItem", this.itemToDelete);
if (this.itemToDelete && this.itemToDelete.id) {
this.deleteItem(this.itemToDelete)
.then(() => {
this.$toast.add({ severity: 'success', summary: 'Success', detail: 'Item deleted successfully', life: 3000 });
this.deleteItemDialog = false;
this.itemToDelete = null;
this.onUpdateOptions(this.options);
})
.catch(error => {
console.error("Error deleting the item:", error);
this.$toast.add({ severity: 'error', summary: 'Error', detail: 'An error occurred while deleting the item', life: 3000 });
});
} else {
console.error("No item to delete or item ID is missing");
}
},
onRowSelected(items) {
this.selected = items
@ -486,20 +494,12 @@ export default {
},
async deleteSelected() {
console.log("deleteSelected")
/*for (let i = 0; i < this.selected.length; i++) {
let item = this.selected[i];
//this.deleteHandler(item);
this.deleteItem(item);
}*/
this.deleteMultipleAction(this.selected)
this.onRequest({
pagination: this.pagination,
})
console.log("end -- deleteSelected")
},
//...actions,
// From ListMixin
...mapActions("personalfile", {
getPage: "fetchAll",
createWithFormData: "createWithFormData",

@ -1,4 +1,5 @@
<template>
<Button :label="$t('Back')" icon="pi pi-chevron-left" @click="goBack" />
<DataTable
v-model:filters="filters"
v-model:selection="selectedItems"
@ -70,7 +71,7 @@
<div class="flex flex-row gap-2">
<Button
class="btn btn--primary"
icon="fa fa-info-circle"
icon="pi pi-info-circle"
@click="showHandler(slotProps.data)"
/>
</div>
@ -89,6 +90,7 @@ import DataFilter from "../../components/DataFilter"
import isEmpty from "lodash/isEmpty"
import { useFormatDate } from "../../composables/formatDate"
import prettyBytes from "pretty-bytes"
import { useI18n } from "vue-i18n"
export default {
name: "PersonalFileShared",
@ -101,18 +103,19 @@ export default {
DataFilter,
},
data() {
const { t } = useI18n()
const { relativeDatetime } = useFormatDate()
return {
sortBy: "title",
sortDesc: false,
columns: [
{ label: this.$i18n.t("Title"), field: "title", name: "title", sortable: true },
{ label: this.$i18n.t("Modified"), field: "resourceNode.updatedAt", name: "updatedAt", sortable: true },
{ label: this.$i18n.t("Size"), field: "resourceNode.resourceFile.size", name: "size", sortable: true },
{ label: this.$i18n.t("Actions"), name: "action", sortable: false },
{ label: t("Title"), field: "title", name: "title", sortable: true },
{ label: t("Modified"), field: "resourceNode.updatedAt", name: "updatedAt", sortable: true },
{ label: t("Size"), field: "resourceNode.resourceFile.size", name: "size", sortable: true },
{ label: t("Actions"), name: "action", sortable: false },
],
pageOptions: [10, 20, 50, this.$i18n.t("All")],
pageOptions: [10, 20, 50, t("All")],
selected: [],
isBusy: true,
options: [],
@ -126,6 +129,7 @@ export default {
submitted: false,
relativeDatetime,
prettyBytes,
t,
}
},
created() {
@ -164,6 +168,9 @@ export default {
}),
},
methods: {
goBack() {
this.$router.go(-1)
},
// This is a copy of the ListMixin, it doesnt adds the resourceNode
onUpdateOptions({ page, itemsPerPage, sortBy, sortDesc, totalItems } = {}) {
console.log("onUpdateOptions")
@ -246,4 +253,4 @@ export default {
}),
},
}
</script>
</script>

@ -1,5 +1,6 @@
<template>
<div>
<Button :label="$t('Back')" icon="pi pi-chevron-left" @click="goBack" />
<Toolbar
v-if="item && isCurrentTeacher"
:handle-delete="del"
@ -160,6 +161,9 @@ export default {
}),
},
methods: {
goBack() {
this.$router.go(-1);
},
...mapActions("personalfile", {
deleteItem: "del",
reset: "resetShow",

@ -1,4 +1,5 @@
<template>
<Button :label="$t('Back')" icon="pi pi-chevron-left" @click="goBack" class="mb-4" />
<div v-if="!isLoading && item">
<!-- :handle-delete="del"-->
<Toolbar
@ -51,6 +52,9 @@ export default {
...mapGetters("personalfile", ["find"]),
},
methods: {
goBack() {
this.$router.go(-1);
},
...mapActions("personalfile", {
createReset: "resetCreate",
deleteItem: "del",
@ -62,4 +66,4 @@ export default {
}),
},
}
</script>
</script>

@ -25,7 +25,7 @@ import "@uppy/image-editor/dist/style.css"
import Uppy from "@uppy/core"
import Webcam from "@uppy/webcam"
import { Dashboard } from "@uppy/vue"
import { useRoute } from "vue-router"
import { useRoute, useRouter } from "vue-router"
import { ENTRYPOINT } from "../../config/entrypoint"
const XHRUpload = require("@uppy/xhr-upload")
@ -48,6 +48,7 @@ export default {
setup() {
const parentResourceNodeId = ref(null)
const route = useRoute()
const router = useRouter();
const store = useStore()
const user = computed(() => store.getters["security/getUser"])
@ -91,6 +92,10 @@ export default {
parentResourceNodeId: parentResourceNodeId.value,
})
uppy.value.on("complete", (result) => {
router.push({ name: "PersonalFileList" });
});
return {
uppy,
}
@ -121,4 +126,4 @@ export default {
...mapActions("personalfile", ["uploadMany", "createFile"]),
},
}
</script>
</script>

@ -119,6 +119,10 @@ class PersonalFile extends AbstractResource implements ResourceInterface, String
#[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)]
protected string $title;
#[Groups(['personal_file:read'])]
#[ORM\Column(name: 'comment', type: 'text', nullable: true)]
private ?string $comment = null;
public function __toString(): string
{
return $this->getTitle();
@ -141,6 +145,17 @@ class PersonalFile extends AbstractResource implements ResourceInterface, String
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getResourceIdentifier(): int
{
return $this->getId();

Loading…
Cancel
Save