Skip to content

Commit

Permalink
feat: Update notes overview to realy on the overview extensions - EXO…
Browse files Browse the repository at this point in the history
  • Loading branch information
sofyenne authored Oct 14, 2024
1 parent e5655e5 commit 1dfa3d9
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,11 @@ public Page getNoteByIdAndLang(Long pageId, Identity userIdentity, String source
page.setMetadatas(retrieveMetadataItems(pageId + "-" + lang, userIdentity.getUserId()));
}
}
if (publishedVersion == null && lang != null) {
//no version with lang, set the latest version without lang id
publishedVersion = dataStorage.getPublishedVersionByPageIdAndLang(pageId, null);
page.setLatestVersionId(publishedVersion == null ? null : publishedVersion.getId());
}
return page;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ public Response getNote(@Parameter(description = "NoteBook Type", required = tru
}
if (StringUtils.isNotBlank(lang)) {
note = noteService.getNoteByIdAndLang(Long.valueOf(note.getId()), identity, source, lang);
} else {
PageVersion pageVersion = noteService.getPublishedVersionByPageIdAndLang(Long.valueOf(note.getId()), null);
note.setLatestVersionId(pageVersion == null ? null : pageVersion.getId());
}
String content = note.getContent();
if (content.contains(Utils.NOTE_LINK)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export default {
this.$root.$on('close-featured-image-byOverlay', this.closeFeaturedImageDrawerByOverlay);
document.addEventListener('note-custom-plugins', this.openCustomPluginsDrawer);
document.addEventListener('notes-editor-extensions-updated', this.refreshEditorExtensions);
document.addEventListener('notes-extensions-updated', this.refreshEditorExtensions);
},
methods: {
metadataUpdated(properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,26 @@
width="100%"
max-height="400" />
<div class="notes-title">
<span
ref="noteTitle"
class="title text-color">
<p ref="noteTitle" class="title text-color text-break">
<span>
{{ noteTitle }}
</span>
<notes-translation-menu
:note="note"
:translations="translations"
:selected-translation="selectedTranslation"
@change-translation="changeTranslation" />
</span>
<span>
<notes-translation-menu
note="note"
:translations="translations"
:selected-translation="selectedTranslation"
@change-translation="changeTranslation" />
</span>
<extension-registry-components
v-if="overviewExtensions.length > 0"
name="NotesOverview"
type="notes-overview-extensions"
:params="extensionParams"
element-class="ms-3"
parent-element="span"
element="span" />
</p>
</div>
<p
v-if="hasSummary"
Expand Down Expand Up @@ -363,7 +373,8 @@ export default {
translationsMenu: false,
originalVersion: { value: '', text: this.$t('notes.label.translation.originalVersion') },
illustrationBaseUrl: `${eXo.env.portal.context}/${eXo.env.portal.rest}/notes/illustration/`,
initialized: false
initialized: false,
overviewExtensions: [],
};
},
watch: {
Expand Down Expand Up @@ -401,6 +412,19 @@ export default {
}
},
computed: {
extensionParams() {
return {
entityId: this.entityId,
entityType: this.entityType,
editMode: false
};
},
entityId() {
return this.note?.draftPage && this.note?.id || this.note.latestVersionId;
},
entityType() {
return this.note.draftPage && 'WIKI_DRAFT_PAGES' || 'WIKI_PAGE_VERSIONS';
},
hasSummary() {
return this.note?.properties?.summary?.length;
},
Expand Down Expand Up @@ -612,6 +636,8 @@ export default {
this.$root.$on('open-note-history', this.openNoteVersionsHistoryDrawer);
this.$root.$on('open-note-treeview-export', this.openNoteTreeView);
this.$root.$on('open-note-import-drawer', this.openImportDrawer);
document.addEventListener('notes-extensions-updated', this.refreshOverviewExtensions);
this.refreshOverviewExtensions();
},
mounted() {
Expand Down Expand Up @@ -1035,6 +1061,7 @@ export default {
this.note.lang = note.lang;
this.noteContent = note.content;
this.note.title = note.title;
this.note.latestVersionId = note.latestVersionId;
this.noteTitle = !this.note.parentPageId && this.note.title==='Home' ? `${this.$t('notes.label.noteHome')}` : this.note.title;
}
this.updateURL();
Expand Down Expand Up @@ -1068,6 +1095,9 @@ export default {
if (this.initialized) {
this.$root.$emit('refresh-treeView-items', this.note);
}
},
refreshOverviewExtensions() {
this.overviewExtensions = extensionRegistry.loadComponents('NotesOverview') || [];
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
width="36"
min-width="36"
height="36"
class="mt-n2 pa-0 ms-5"
class="pa-0 ms-5"
:class="langButtonColor"
icon>
<v-icon
Expand Down
4 changes: 4 additions & 0 deletions notes-webapp/src/main/webapp/vue-app/notes/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import * as notesService from '../../javascript/eXo/wiki/notesService.js';
// get overrided components if exists
if (extensionRegistry) {
const components = extensionRegistry.loadComponents('notes');
const overviewComponents = extensionRegistry.loadComponents('NotesOverview');
if (overviewComponents.length > 0) {
components.push(...overviewComponents);
}
if (components && components.length > 0) {
components.forEach(cmp => {
Vue.component(cmp.componentName, cmp.componentOptions);
Expand Down

0 comments on commit 1dfa3d9

Please sign in to comment.