Skip to content
Open
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
2 changes: 1 addition & 1 deletion css/office-main.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* extracted by css-entry-points-plugin */
@import './main-ChrxhTd_.chunk.css';
@import './main-C6G5yYHl.chunk.css';
25 changes: 23 additions & 2 deletions src/views/OfficeOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const MIME_CATEGORIES: Record<string, string> = {
'application/vnd.oasis.opendocument.graphics-template': t('office', 'Diagrams'),
}

// Every office mimetype we can open, regardless of the configured create format
// (doc_format). richdocuments only advertises the create-format mimes per creator
// (e.g. OOXML when doc_format=ooxml), so we drive the search and category filtering
// from this full set instead — otherwise existing ODF files would never be found.
const ALL_OFFICE_MIMES = Object.keys(MIME_CATEGORIES)

const currentUid = getCurrentUser()?.uid ?? null

const creators = ref<TemplateCreator[]>([])
Expand Down Expand Up @@ -92,7 +98,7 @@ const searchLabel = computed(() =>
const filteredFiles = computed(() => {
if (!activeCreator.value) return []

const byCategory = filterByMimes(allFiles.value, activeCreator.value.mimetypes)
const byCategory = filterByMimes(allFiles.value, categoryMimes(activeCreator.value))

let filtered = byCategory
if (activeFilter.value === 'mine') {
Expand Down Expand Up @@ -130,6 +136,16 @@ function categoryName(creator: TemplateCreator): string {
return creator.label
}

// All mimetypes belonging to the creator's category (both ODF and OOXML), so a
// category shows every openable file regardless of the configured create format.
// The creator's own mimes are always kept, so anything it advertises beyond our
// static map (and any creator mapping to no known category) is still covered.
function categoryMimes(creator: TemplateCreator): string[] {
const category = categoryName(creator)
const fromCategory = ALL_OFFICE_MIMES.filter(mime => MIME_CATEGORIES[mime] === category)
return [...new Set([...fromCategory, ...creator.mimetypes])]
}

function setCreator(creator: TemplateCreator) {
activeCreator.value = creator
}
Expand Down Expand Up @@ -234,7 +250,12 @@ async function fetchAll() {
activeCreator.value = creators.value[0] ?? null

if (creators.value.length > 0) {
const allMimes = creators.value.flatMap(c => c.mimetypes)
// Union our full static set (ODF + OOXML) with whatever the creators
// actually advertise, so we never drop a mime the server supports.
const allMimes = [...new Set([
...ALL_OFFICE_MIMES,
...creators.value.flatMap(c => c.mimetypes),
])]
allFiles.value = await getAllOfficeFiles(allMimes)
}
} catch {
Expand Down
Loading