Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix(systemtags): translations and etag method casing
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Oct 29, 2024
commit f536c86049205a45601476a7ce3961378a8f80c9
109 changes: 75 additions & 34 deletions apps/systemtags/src/components/SystemTagPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<NcDialog data-cy-systemtags-picker
:name="t('systemtags', 'Manage tags')"
:open="opened"
:class="'systemtags-picker--' + status"
class="systemtags-picker"
close-on-click-outside
out-transition
Expand Down Expand Up @@ -99,7 +100,7 @@ import { defineComponent } from 'vue'
import { emit } from '@nextcloud/event-bus'
import { sanitize } from 'dompurify'
import { showError, showInfo } from '@nextcloud/dialogs'
import { getLanguage, t } from '@nextcloud/l10n'
import { getLanguage, n, t } from '@nextcloud/l10n'
import escapeHTML from 'escape-html'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
Expand All @@ -122,10 +123,10 @@ type TagListCount = {
}

enum Status {
BASE,
LOADING,
CREATING_TAG,
DONE,
BASE = 'base',
LOADING = 'loading',
CREATING_TAG = 'creating-tag',
DONE = 'done',
}

export default defineComponent({
Expand Down Expand Up @@ -190,43 +191,79 @@ export default defineComponent({

statusMessage(): string {
if (this.toAdd.length === 0 && this.toRemove.length === 0) {
// should not happen™
return ''
}

if (this.toAdd.length === 1 && this.toRemove.length === 1) {
return t('systemtags', '{tag1} will be set and {tag2} will be removed from {count} files.', {
tag1: this.formatTagChip(this.toAdd[0]),
tag2: this.formatTagChip(this.toRemove[0]),
count: this.nodes.length,
}, undefined, { escape: false })
return n(
'systemtags',
'{tag1} will be set and {tag2} will be removed from 1 file.',
'{tag1} and {tag2} will be set and removed from {count} files.',
this.nodes.length,
{
tag1: this.formatTagChip(this.toAdd[0]),
tag2: this.formatTagChip(this.toRemove[0]),
count: this.nodes.length,
},
{ escape: false },
)
}

const tagsAdd = this.toAdd.map(this.formatTagChip)
const lastTagAdd = tagsAdd.pop() as string
const tagsRemove = this.toRemove.map(this.formatTagChip)
const lastTagRemove = tagsRemove.pop() as string

const addStringSingular = t('systemtags', '{tag} will be set to {count} files.', {
tag: lastTagAdd,
count: this.nodes.length,
}, undefined, { escape: false })

const removeStringSingular = t('systemtags', '{tag} will be removed from {count} files.', {
tag: lastTagRemove,
count: this.nodes.length,
}, undefined, { escape: false })

const addStringPlural = t('systemtags', '{tags} and {lastTag} will be set to {count} files.', {
tags: tagsAdd.join(', '),
lastTag: lastTagAdd,
count: this.nodes.length,
}, undefined, { escape: false })

const removeStringPlural = t('systemtags', '{tags} and {lastTag} will be removed from {count} files.', {
tags: tagsRemove.join(', '),
lastTag: lastTagRemove,
count: this.nodes.length,
}, undefined, { escape: false })
const addStringSingular = n(
'systemtags',
'{tag} will be set to 1 file.',
'{tag} will be set to {count} files.',
this.nodes.length,
{
tag: lastTagAdd,
count: this.nodes.length,
},
{ escape: false },
)

const removeStringSingular = n(
'systemtags',
'{tag} will be removed from 1 file.',
'{tag} will be removed from {count} files.',
this.nodes.length,
{
tag: lastTagRemove,
count: this.nodes.length,
},
{ escape: false },
)

const addStringPlural = n(
'systemtags',
'{tags} and {lastTag} will be set to 1 file.',
'{tags} and {lastTag} will be set to {count} files.',
this.nodes.length,
{
tags: tagsAdd.join(', '),
lastTag: lastTagAdd,
count: this.nodes.length,
},
{ escape: false },
)

const removeStringPlural = n(
'systemtags',
'{tags} and {lastTag} will be removed from 1 file.',
'{tags} and {lastTag} will be removed from {count} files.',
this.nodes.length,
{
tags: tagsRemove.join(', '),
lastTag: lastTagRemove,
count: this.nodes.length,
},
{ escape: false },
)

// Singular
if (this.toAdd.length === 1 && this.toRemove.length === 0) {
Expand All @@ -246,14 +283,14 @@ export default defineComponent({

// Mixed
if (this.toAdd.length > 1 && this.toRemove.length === 1) {
return `${addStringPlural}<br>${removeStringSingular}`
return `${addStringPlural} ${removeStringSingular}`
}
if (this.toAdd.length === 1 && this.toRemove.length > 1) {
return `${addStringSingular}<br>${removeStringPlural}`
return `${addStringSingular} ${removeStringPlural}`
}

// Both plural
return `${addStringPlural}<br>${removeStringPlural}`
return `${addStringPlural} ${removeStringPlural}`
},
},

Expand Down Expand Up @@ -452,6 +489,10 @@ export default defineComponent({
}
}

.systemtags-picker--done :deep(.empty-content__icon) {
opacity: 1;
}

// Rendered chip in note
.nc-chip {
display: inline !important;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/SystemTag/SystemTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getAccessLevel(): int {
/**
* {@inheritdoc}
*/
public function getEtag(): ?string {
public function getETag(): ?string {
return $this->etag;
}
}
2 changes: 1 addition & 1 deletion lib/public/SystemTag/ISystemTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ public function getAccessLevel(): int;
*
* @since 31.0.0
*/
public function getEtag(): ?string;
public function getETag(): ?string;
}