|
|
|
@ -19,12 +19,12 @@ |
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
import { FileAction, Node, registerDavProperty, registerFileAction } from "@nextcloud/files"; |
|
|
|
|
import { FileAction, Node, registerDavProperty, registerFileAction } from '@nextcloud/files' |
|
|
|
|
import { translate as t } from '@nextcloud/l10n' |
|
|
|
|
|
|
|
|
|
import '../css/fileEntryInlineSystemTags.scss' |
|
|
|
|
|
|
|
|
|
const getNodeSystemTags = function (node: Node): string[] { |
|
|
|
|
const getNodeSystemTags = function(node: Node): string[] { |
|
|
|
|
const tags = node.attributes?.['system-tags']?.['system-tag'] as string|string[]|undefined |
|
|
|
|
|
|
|
|
|
if (tags === undefined) { |
|
|
|
@ -34,7 +34,7 @@ const getNodeSystemTags = function (node: Node): string[] { |
|
|
|
|
return [tags].flat() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const renderTag = function (tag: string, isMore: boolean = false): HTMLElement { |
|
|
|
|
const renderTag = function(tag: string, isMore = false): HTMLElement { |
|
|
|
|
const tagElement = document.createElement('li') |
|
|
|
|
tagElement.classList.add('files-list__system-tag') |
|
|
|
|
tagElement.textContent = tag |
|
|
|
@ -43,7 +43,7 @@ const renderTag = function (tag: string, isMore: boolean = false): HTMLElement { |
|
|
|
|
tagElement.classList.add('files-list__system-tag--more') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return tagElement; |
|
|
|
|
return tagElement |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const action = new FileAction({ |
|
|
|
@ -64,26 +64,26 @@ export const action = new FileAction({ |
|
|
|
|
systemTagsElement.classList.add('files-list__system-tags') |
|
|
|
|
|
|
|
|
|
if (tags.length === 1) { |
|
|
|
|
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tag {tag}', { tag: tags[0] })); |
|
|
|
|
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tag {tag}', { tag: tags[0] })) |
|
|
|
|
} else { |
|
|
|
|
var firstTags = tags.slice(0, -1).join(', '); |
|
|
|
|
var lastTag = tags[tags.length - 1]; |
|
|
|
|
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tags {firstTags} and {lastTag}', { firstTags, lastTag })); |
|
|
|
|
const firstTags = tags.slice(0, -1).join(', ') |
|
|
|
|
const lastTag = tags[tags.length - 1] |
|
|
|
|
systemTagsElement.setAttribute('aria-label', t('files', 'This file has the tags {firstTags} and {lastTag}', { firstTags, lastTag })) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
systemTagsElement.append(renderTag(tags[0])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// More tags than the one we're showing
|
|
|
|
|
if (tags.length > 1) { |
|
|
|
|
const moreTagElement = renderTag('+' + (tags.length - 1), true) |
|
|
|
|
moreTagElement.setAttribute('title', tags.slice(1).join(', ')); |
|
|
|
|
systemTagsElement.append(moreTagElement); |
|
|
|
|
moreTagElement.setAttribute('title', tags.slice(1).join(', ')) |
|
|
|
|
systemTagsElement.append(moreTagElement) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return systemTagsElement |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
order: 0 |
|
|
|
|
order: 0, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
registerDavProperty('nc:system-tags') |
|
|
|
|