PersonalFile: Add "shared" page in order to get shared personal files

Remove console.logs
ListMixin loads resourceNode if this.filters['loadNode'] == 1
pull/3924/head
Julio Montoya 3 years ago
parent 98884d9934
commit a309858b4a
  1. 40
      assets/vue/App.vue
  2. 26
      assets/vue/mixins/ListMixin.js
  3. 8
      assets/vue/mixins/UploadMixin.js
  4. 6
      assets/vue/router/index.js
  5. 14
      assets/vue/views/documents/DocumentManager.vue
  6. 28
      assets/vue/views/documents/List.vue
  7. 35
      assets/vue/views/personalfile/List.vue
  8. 230
      assets/vue/views/personalfile/Shared.vue
  9. 2
      src/CoreBundle/DataProvider/Extension/PersonalFileExtension.php

@ -84,23 +84,11 @@ export default {
watch: {
$route() {
console.log('App.vue watch $route');
console.log(this.$route.name);
//let content = document.getElementById("sectionMainContent");
//console.log('App.vue watch $route');
//console.log(this.$route.name);
this.legacyContent = '';
/*if (content && false === this.contentLoaded) {
console.log('updated ok ');
content.style.display = 'block';
this.legacyContent = content.outerHTML;
if (document.querySelector("#sectionMainContent")) {
console.log('remove sectionMainContent ');
document.querySelector("#sectionMainContent").remove();
}
}*/
// This code below will handle the legacy content to be loaded.
let url = window.location.href;
var n = url.indexOf("main/");
if (n > 0) {
@ -121,27 +109,6 @@ export default {
console.log('Replace URL', url);
window.location.replace(url);
/*axios.get(url, {
params: {
from_vue: 1
},
})
.then((response) => {
console.log('updated page using axios');
this.legacyContent = response.data;
}).catch(function (error) {
if (error.response) {
// Request made and server responded
console.log(error.response.status);
console.log(error.response.data);
} else if (error.request) {
// The request was made but no response was received
console.log(error.request);
} else {
console.log('Error', error.message);
}
});*/
}
} else {
if (this.firstTime) {
@ -199,8 +166,7 @@ export default {
}
axios.interceptors.response.use(undefined, (err) => {
console.log('interceptor');
console.log(err.response.status);
//console.log('interceptor');console.log(err.response.status);
return new Promise(() => {
// Unauthorized.

@ -27,7 +27,6 @@ export default {
page: 1,
itemsPerPage: 10
},
//filters: {}
};
},
watch: {
@ -49,7 +48,6 @@ export default {
},
deletedItem(item) {
//console.log('deletedItem');
this.showMessage(this.$i18n.t('{resource} deleted', {'resource': item['resourceNode'].title}));
this.onUpdateOptions(this.options);
},
@ -59,6 +57,7 @@ export default {
},
items() {
this.options.totalItems = this.totalItems;
}
},
methods: {
@ -97,18 +96,22 @@ export default {
onUpdateOptions({ page, itemsPerPage, sortBy, sortDesc, totalItems } = {}) {
console.log('ListMixin.js: onUpdateOptions');
//this.resetList = true;
this.resetList = true;
let params = {
...this.filters
}
if (itemsPerPage > 0) {
params = { ...params, itemsPerPage, page };
if (1 === this.filters['loadNode']) {
params[`resourceNode.parent`] = this.$route.params.node;
}
if (this.$route.params.node) {
/*if (this.$route.params.node) {
params[`resourceNode.parent`] = this.$route.params.node;
}*/
if (itemsPerPage > 0) {
params = { ...params, itemsPerPage, page };
}
// prime
@ -129,7 +132,6 @@ export default {
}*/
console.log(params);
this.resetList = true;
this.getPage(params).then(() => {
this.options.sortBy = sortBy;
this.options.sortDesc = sortDesc;
@ -195,7 +197,6 @@ export default {
sharedDocumentHandler() {
let folderParams = this.$route.query;
folderParams['shared'] = 1;
this.$router.push({ name: `${this.$options.servicePrefix}Shared` , query: folderParams});
},
@ -207,15 +208,6 @@ export default {
if (item) {
folderParams['id'] = item['@id'];
}
/*let cid = toInteger(this.$route.query.cid);
let sid = toInteger(this.$route.query.sid);
let gid = toInteger(this.$route.query.gid);
folderParams['cid'] = cid;
folderParams['sid'] = sid;
folderParams['gid'] = gid;*/
console.log(folderParams);
this.$router.push({

@ -7,14 +7,6 @@ export default {
formatDateTime,
onCreated(item) {
this.showMessage(this.$i18n.t('{resource} created', {'resource': item['resourceNode'].title}));
const createForm = this.$refs.createForm;
let folderParams = this.$route.query;
/*this.$router.push({
name: `${this.$options.servicePrefix}List`,
params: {id: item['@id']},
query: folderParams
});*/
},
onUploadForm() {
console.log('onUploadForm');

@ -94,9 +94,9 @@ const router = createRouter({
});
router.beforeEach((to, from, next) => {
console.log('beforeEach');
//console.log('beforeEach');
if (to.matched.some(record => record.meta.requiresAuth)) {
console.log('requiresAuth');
//console.log('requiresAuth');
// this route requires auth, check if logged in
// if not, redirect to login page.
if (store.getters['security/isAuthenticated']) {
@ -108,7 +108,7 @@ router.beforeEach((to, from, next) => {
});
}
} else {
console.log('next');
//console.log('next');
next(); // make sure to always call next()!
}
});

@ -152,21 +152,11 @@ export default {
},
created() {
console.log('created - vue/views/documents/List.vue');
/*const route = useRoute();
let nodeId = route.params['node'];
if (!isEmpty(nodeId)) {
this.findResourceNode('/api/resource_nodes/' + nodeId);
}
this.onUpdateOptions(this.options);*/
//this.initFilters1();
/*
this.onRequest({
pagination: this.pagination,
});*/
this.filters['loadNode'] = 1;
},
mounted() {
console.log('mounted - vue/views/documents/List.vue');
this.filters['loadNode'] = 1;
this.onUpdateOptions(this.options);
},
computed: {

@ -305,6 +305,7 @@ import { ref, reactive, onMounted, computed } from 'vue';
import { useStore } from 'vuex';
import isEmpty from 'lodash/isEmpty';
import moment from "moment";
import toInteger from "lodash/toInteger";
export default {
name: 'DocumentsList',
@ -350,33 +351,13 @@ export default {
},
created() {
console.log('created - vue/views/documents/List.vue');
/*const route = useRoute();
let nodeId = route.params['node'];
if (!isEmpty(nodeId)) {
this.findResourceNode('/api/resource_nodes/' + nodeId);
}
this.onUpdateOptions(this.options);*/
//this.initFilters1();
/*
this.onRequest({
pagination: this.pagination,
});*/
this.filters['loadNode'] = 1;
},
mounted() {
this.filters['loadNode'] = 1;
console.log('mounted - vue/views/documents/List.vue');
const route = useRoute()
/*let nodeId = route.params['node'];
if (!isEmpty(nodeId)) {
this.findResourceNode('/api/resource_nodes/' + nodeId);
}*/
this.onUpdateOptions(this.options);
/*this.onRequest({
pagination: this.pagination,
});*/
// Detect when scrolled to bottom.
/*const listElm = document.querySelector('#documents');
listElm.addEventListener('scroll', e => {
@ -429,7 +410,7 @@ export default {
methods: {
// prime
onPage(event) {
console.log(event);
console.log('onPage');
console.log(event.page);
console.log(event.sortField);
console.log(event.sortOrder);
@ -451,7 +432,6 @@ export default {
// ctx.sortBy ==> Field key for sorting by (or null for no sorting)
// ctx.sortDesc ==> true if sorting descending, false otherwise
},
openNew() {
this.item = {};
this.submitted = false;

@ -4,6 +4,7 @@
<div class="flex flex-row gap-2" >
<Button label="New folder" icon="fa fa-folder-plus" class="btn btn-primary" @click="openNew" />
<Button label="Upload" icon="fa fa-file-upload" class="btn btn-primary" @click="uploadDocumentHandler()" />
<Button label="Shared" icon="fa fa-file-upload" class="btn btn-success" @click="sharedDocumentHandler()" />
<Button label="Delete" icon="pi pi-trash" class="btn btn-danger " @click="confirmDeleteMultiple" :disabled="!selectedItems || !selectedItems.length" />
</div>
</div>
@ -26,12 +27,8 @@
:rowsPerPageOptions="[5, 10, 20, 50]"
responsiveLayout="scroll"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords}"
:globalFilterFields="['resourceNode.title', 'resourceNode.updatedAt']">
<span v-if="isCurrentTeacher">
<Column selectionMode="multiple" style="width: 3rem" :exportable="false"></Column>
</span>
:globalFilterFields="['resourceNode.title', 'resourceNode.updatedAt']"
>
<Column field="resourceNode.title" :header="$t('Title')" :sortable="true">
<template #body="slotProps">
<div v-if="slotProps.data && slotProps.data.resourceNode && slotProps.data.resourceNode.resourceFile">
@ -130,17 +127,15 @@ import { mapActions, mapGetters } from 'vuex';
import { mapFields } from 'vuex-map-fields';
import ListMixin from '../../mixins/ListMixin';
import ActionCell from '../../components/ActionCell.vue';
//import Toolbar from '../../components/Toolbar.vue';
import ResourceFileIcon from '../../components/documents/ResourceFileIcon.vue';
import ResourceFileLink from '../../components/documents/ResourceFileLink.vue';
import { useRoute } from 'vue-router'
import DataFilter from '../../components/DataFilter';
//import DocumentsFilterForm from '../../components/personalfile/Filter';
import { ref, reactive, onMounted, computed } from 'vue';
import { useStore } from 'vuex';
import isEmpty from 'lodash/isEmpty';
import moment from "moment";
export default {
name: 'PersonalFileList',
@ -180,28 +175,18 @@ export default {
deleteItemDialog: false,
deleteMultipleDialog: false,
item: {},
filters: {},
filters: {shared: 0, loadNode: 1},
submitted: false,
};
},
created() {
console.log('CREATED');
let resourceNodeId = this.currentUser.resourceNode['id'];
if (isEmpty(this.$route.params.node)) {
this.$route.params.node = resourceNodeId;
}
//this.item.parentResourceNodeId = this.$route.params.node;
this.filters['resourceNode.parent'] = resourceNodeId;
},
mounted() {
const route = useRoute()
/*let nodeId = route.params['node'];
if (!isEmpty(nodeId)) {
this.findResourceNode('/api/resource_nodes/' + nodeId);
}*/
console.log(this.options);
this.resetList = true;
this.onUpdateOptions(this.options);
},
/*mounted() {
this.resetList = true;
this.onUpdateOptions(this.options);
},*/
computed: {
// From crud.js list function
...mapGetters('resourcenode', {

@ -0,0 +1,230 @@
<template>
<DataTable
class="p-datatable-sm"
:value="itemsShared"
v-model:selection="selectedItems"
dataKey="iid"
v-model:filters="filters"
filterDisplay="menu"
:lazy="true"
:paginator="true"
:rows="10"
:totalRecords="totalItems"
:loading="isLoading"
@page="onPage($event)"
@sort="sortingChanged($event)"
paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
:rowsPerPageOptions="[5, 10, 20, 50]"
responsiveLayout="scroll"
currentPageReportTemplate="Showing {first} to {last} of {totalRecords}"
:globalFilterFields="['resourceNode.title', 'resourceNode.updatedAt']"
>
<Column field="resourceNode.title" :header="$t('Title')" :sortable="true">
<template #body="slotProps">
<div v-if="slotProps.data && slotProps.data.resourceNode && slotProps.data.resourceNode.resourceFile">
<ResourceFileLink :resource="slotProps.data" />
</div>
<div v-else>
<a
v-if="slotProps.data"
@click="handleClick(slotProps.data)"
class="cursor-pointer " >
<v-icon icon="mdi-folder"/>
{{ slotProps.data.resourceNode.title }}
</a>
</div>
</template>
</Column>
<Column field="resourceNode.resourceFile.size" :header="$t('Size')" :sortable="true">
<template #body="slotProps">
{{
slotProps.data.resourceNode.resourceFile ? $filters.prettyBytes(slotProps.data.resourceNode.resourceFile.size) : ''
}}
</template>
</Column>
<Column field="resourceNode.updatedAt" :header="$t('Modified')" :sortable="true">
<template #body="slotProps">
{{$luxonDateTime.fromISO(slotProps.data.resourceNode.updatedAt).toRelative() }}
</template>
</Column>
<Column :exportable="false">
<template #body="slotProps">
<div class="flex flex-row gap-2">
<Button icon="fa fa-info-circle" class="btn btn-primary " @click="showHandler(slotProps.data)" />
</div>
</template>
</Column>
</DataTable>
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
import { mapFields } from 'vuex-map-fields';
import ListMixin from '../../mixins/ListMixin';
import ActionCell from '../../components/ActionCell.vue';
import ResourceFileIcon from '../../components/documents/ResourceFileIcon.vue';
import ResourceFileLink from '../../components/documents/ResourceFileLink.vue';
import { useRoute } from 'vue-router'
import DataFilter from '../../components/DataFilter';
import isEmpty from 'lodash/isEmpty';
import toInteger from "lodash/toInteger";
export default {
name: 'PersonalFileShared',
servicePrefix: 'PersonalFile',
components: {
//8Toolbar,
ActionCell,
ResourceFileIcon,
ResourceFileLink,
DataFilter
},
data() {
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}
],
pageOptions: [10, 20, 50, this.$i18n.t('All')],
selected: [],
isBusy: true,
options: [],
selectedItems: [],
// prime vue
itemDialog: false,
deleteItemDialog: false,
deleteMultipleDialog: false,
item: {},
filters: {shared: 1, loadNode: 0},
submitted: false,
};
},
created() {
this.resetList = true;
console.log('CREATED SHARED');
},
mounted() {
console.log('MOUNTED SHARED');
this.resetList = true;
},
computed: {
// From crud.js list function
...mapGetters('resourcenode', {
resourceNode: 'getResourceNode'
}),
...mapGetters({
'isAuthenticated': 'security/isAuthenticated',
'isAdmin': 'security/isAdmin',
'currentUser': 'security/getUser',
}),
...mapGetters('personalfile', {
itemsShared: 'list',
}),
//...getters
// From ListMixin
...mapFields('personalfile', {
deletedItem: 'deleted',
error: 'error',
isLoading: 'isLoading',
resetList: 'resetList',
totalItems: 'totalItems',
view: 'view'
}),
},
methods: {
// This is a copy of the ListMixin, it doesnt adds the resourceNode
onUpdateOptions({ page, itemsPerPage, sortBy, sortDesc, totalItems } = {}) {
console.log('onUpdateOptions');
this.resetList = true;
let params = {
...this.filters
}
if (itemsPerPage > 0) {
params = { ...params, itemsPerPage, page };
}
// prime
if (!isEmpty(sortBy)) {
params[`order[${sortBy}]`] = sortDesc ? 'desc' : 'asc'
}
let type = this.$route.query.type;
params = { ...params, type };
// vuetify
/*if (!isEmpty(sortBy) && !isEmpty(sortDesc)) {
params[`order[${sortBy[0]}]`] = sortDesc[0] ? 'desc' : 'asc'
}*/
console.log(params);
this.getPage(params).then(() => {
this.options.sortBy = sortBy;
this.options.sortDesc = sortDesc;
this.options.itemsPerPage = itemsPerPage;
this.options.totalItems = totalItems;
});
},
showHandler(item) {
let folderParams = this.$route.query;
if (item) {
folderParams['id'] = item['@id'];
}
console.log(folderParams);
this.$router.push({
name: `${this.$options.servicePrefix}Show`,
query: folderParams
});
},
// prime
onPage(event) {
console.log('onPage');
console.log(event);
console.log(event.page);
console.log(event.sortField);
console.log(event.sortOrder);
this.options.itemsPerPage = event.rows;
this.options.page = event.page + 1;
this.options.sortBy = event.sortField;
this.options.sortDesc = event.sortOrder === -1;
this.onUpdateOptions(this.options);
},
sortingChanged(event) {
console.log('sortingChanged');
console.log(event);
this.options.sortBy = event.sortField;
this.options.sortDesc = event.sortOrder === -1;
this.onUpdateOptions(this.options);
// ctx.sortBy ==> Field key for sorting by (or null for no sorting)
// ctx.sortDesc ==> true if sorting descending, false otherwise
},
//...actions,
// From ListMixin
...mapActions('personalfile', {
getPage: 'fetchAll',
create: 'create',
deleteItem: 'del',
deleteMultipleAction: 'delMultiple'
}),
...mapActions('resourcenode', {
findResourceNode: 'findResourceNode',
}),
}
};
</script>

@ -77,7 +77,7 @@ final class PersonalFileExtension implements QueryCollectionExtensionInterface /
;
$queryBuilder
->orWhere('links.user = :userLink')
->andWhere('links.user = :userLink')
->setParameter('userLink', $user)
;
} else {

Loading…
Cancel
Save