Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@
@deselect="selected = selected.filter(id => id !== $event)"
@scroll="scroll"
@editTitleDescription="showTitleDescriptionModal"
/>
>
<template #pagination>
<slot name="pagination"></slot>
</template>
</NodePanel>
</DraggableRegion>
</VFadeTransition>
<ResourceDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
/>
</template>
</VList>
<slot name="pagination"></slot>
</div>

</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GETTERS = {
canManage: jest.fn(() => true),
},
contentNode: {
getContentNodeChildren: () => jest.fn(() => []),
getContentNodeChildren: () => jest.fn(() => ({ results: [], more: null })),
getContentNodeAncestors: () => jest.fn(() => []),
getContentNode: () => jest.fn(() => ({})),
getTopicAndResourceCounts: () => jest.fn(() => ({ topicCount: 0, resourceCount: 0 })),
Expand All @@ -35,7 +35,7 @@ const ACTIONS = {
loadContentNode: jest.fn(),
headContentNode: () => jest.fn(),
loadContentNodes: jest.fn(),
loadChildren: jest.fn(),
loadChildren: jest.fn(() => ({ results: [], more: null })),
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@
/>
</div>
</template>
<template #pagination>
<div class="pagination-container">
<KButton v-if="more" :disabled="moreLoading" @click="loadMore">
{{ $tr('showMore') }}
</KButton>
</div>
</template>
</CurrentTopicView>
</VContent>
</TreeViewBase>
Expand Down Expand Up @@ -192,6 +199,8 @@
},
loading: true,
listElevated: false,
more: null,
moreLoading: false,
};
},
computed: {
Expand Down Expand Up @@ -285,25 +294,30 @@
},
},
created() {
let childrenPromise;
// If viewing the root-level node, don't request anything, since the NodePanel.created
// hook will make a redundant request
if (this.nodeId === this.rootId) {
childrenPromise = Promise.resolve();
} else {
childrenPromise = this.loadContentNodes({ parent: this.rootId });
}
Promise.all([childrenPromise, this.loadAncestors({ id: this.nodeId })]).then(() => {
this.loading = false;
this.jumpToLocation();
});
const childrenPromise = this.loadChildren({ parent: this.rootId });
Promise.all([childrenPromise, this.loadAncestors({ id: this.nodeId })]).then(
([childrenResponse]) => {
this.loading = false;
this.more = childrenResponse.more || null;
this.jumpToLocation();
}
);
},
methods: {
...mapMutations('contentNode', {
collapseAll: 'COLLAPSE_ALL_EXPANDED',
setExpanded: 'SET_EXPANSION',
}),
...mapActions('contentNode', ['loadAncestors', 'loadContentNodes']),
...mapActions('contentNode', ['loadAncestors', 'loadChildren', 'loadContentNodes']),
loadMore() {
if (this.more && !this.moreLoading) {
this.moreLoading = true;
this.loadContentNodes(this.more).then(response => {
this.more = response.more || null;
this.moreLoading = false;
});
}
},
verifyContentNodeId(id) {
this.nodeNotFound = false;
return this.$store.dispatch('contentNode/headContentNode', id).catch(() => {
Expand Down Expand Up @@ -400,6 +414,7 @@
openCurrentLocationButton: 'Expand to current folder location',
updatedResourcesReadyForReview: 'Updated resources are ready for review',
closeDrawer: 'Close',
showMore: 'Show more',
},
};

Expand Down Expand Up @@ -447,4 +462,10 @@
}
}

.pagination-container {
display: flex;
justify-content: flex-start;
margin: 4px;
}

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import * as publicApi from 'shared/data/public';
import db from 'shared/data/db';

export function loadContentNodes(context, params = {}) {
return ContentNode.where(params).then(contentNodes => {
return ContentNode.where(params).then(response => {
const contentNodes = response.results ? response.results : response;
context.commit('ADD_CONTENTNODES', contentNodes);
return contentNodes;
return response;
});
}

Expand Down Expand Up @@ -70,7 +71,7 @@ export function loadContentNodeByNodeId(context, nodeId) {
}

export function loadChildren(context, { parent, published = null, complete = null }) {
const params = { parent };
const params = { parent, max_results: 25 };
if (published !== null) {
params.published = published;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const CHANGE_TYPES_LOOKUP = invert(CHANGE_TYPES);

// Tables
export const CHANGES_TABLE = 'changesForSyncing';
export const PAGINATION_TABLE = 'pagination';

export const TABLE_NAMES = {
SESSION: 'session',
Expand Down
8 changes: 6 additions & 2 deletions contentcuration/contentcuration/frontend/shared/data/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Sentry from '@sentry/vue';
import mapValues from 'lodash/mapValues';
import { CHANGES_TABLE, TABLE_NAMES } from './constants';
import { CHANGES_TABLE, PAGINATION_TABLE, TABLE_NAMES } from './constants';
import db from './db';
import { INDEXEDDB_RESOURCES } from './registry';
import { startSyncing, stopSyncing, syncOnChanges } from './serverSync';
Expand All @@ -14,14 +14,18 @@ export function setupSchema() {
if (!Object.keys(resources).length) {
console.warn('No resources defined!'); // eslint-disable-line no-console
}
// Version incremented to 3 to add new index on CHANGES_TABLE.
// Version incremented to 2 to add Bookmark table and new index on CHANGES_TABLE.
// Version incremented to 3 to add:
// new index on CHANGES_TABLE.
// PAGINATION_TABLE.
db.version(3).stores({
// A special table for logging unsynced changes
// Dexie.js appears to have a table for this,
// but it seems to squash and remove changes in ways
// that I do not currently understand, so we engage
// in somewhat duplicative behaviour instead.
[CHANGES_TABLE]: 'rev++,[table+key],server_rev,type',
[PAGINATION_TABLE]: '[table+queryString]',
...mapValues(INDEXEDDB_RESOURCES, value => value.schema),
});
}
Expand Down
Loading