From 92f5027c3cb17de4940436147a9653a787be55d7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 20 Feb 2022 16:53:06 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=95=E3=82=A3=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E8=BF=BD=E5=8A=A0=E6=83=85=E5=A0=B1=E3=82=92?= =?UTF-8?q?=E6=9C=80=E5=A4=A716=E3=81=BE=E3=81=A7=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #8225 Close #8234 --- CHANGELOG.md | 2 +- locales/ja-JP.yml | 2 +- .../src/server/api/endpoints/i/update.ts | 2 +- .../client/src/pages/settings/profile.vue | 127 ++++++------------ 4 files changed, 44 insertions(+), 89 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9c0ddf27..c78be1b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ You should also include the user name that made the change. - ノートの最大文字数を設定できる機能が廃止され、デフォルトで一律3000文字になりました ### Improvements -- +- プロフィールの追加情報を最大16まで保存できるように ### Bugfixes - Client: リアクションピッカーの高さが低くなったまま戻らないことがあるのを修正 @syuilo diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 840e1beee..df67fb89b 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1290,7 +1290,7 @@ _profile: youCanIncludeHashtags: "ハッシュタグを含めることができます。" metadata: "追加情報" metadataEdit: "追加情報を編集" - metadataDescription: "プロフィールに表として4つまでの追加情報を表示することができます。" + metadataDescription: "プロフィールに表として追加情報を表示することができます。" metadataLabel: "ラベル" metadataContent: "内容" changeAvatar: "アバター画像を変更" diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts index d800f23f8..3488082ab 100644 --- a/packages/backend/src/server/api/endpoints/i/update.ts +++ b/packages/backend/src/server/api/endpoints/i/update.ts @@ -79,7 +79,7 @@ export const paramDef = { bannerId: { type: 'string', format: 'misskey:id', nullable: true }, fields: { type: 'array', minItems: 0, - maxItems: 8, + maxItems: 16, items: { type: 'object', properties: { diff --git a/packages/client/src/pages/settings/profile.vue b/packages/client/src/pages/settings/profile.vue index 9b30d1c8e..e463a4271 100644 --- a/packages/client/src/pages/settings/profile.vue +++ b/packages/client/src/pages/settings/profile.vue @@ -32,8 +32,26 @@ - - {{ i18n.ts._profile.metadataEdit }} + + + + + +
+
+ + + + + + + + +
+ {{ i18n.ts.add }} + {{ i18n.ts.save }} +
+
@@ -52,6 +70,8 @@ import FormInput from '@/components/form/input.vue'; import FormTextarea from '@/components/form/textarea.vue'; import FormSwitch from '@/components/form/switch.vue'; import FormSelect from '@/components/form/select.vue'; +import FormSplit from '@/components/form/split.vue'; +import FormFolder from '@/components/form/folder.vue'; import FormSlot from '@/components/form/slot.vue'; import { host, langs } from '@/config'; import { selectFile } from '@/scripts/select-file'; @@ -72,23 +92,31 @@ const profile = reactive({ alwaysMarkNsfw: $i.alwaysMarkNsfw, }); -const additionalFields = reactive({ - fieldName0: $i.fields[0] ? $i.fields[0].name : null, - fieldValue0: $i.fields[0] ? $i.fields[0].value : null, - fieldName1: $i.fields[1] ? $i.fields[1].name : null, - fieldValue1: $i.fields[1] ? $i.fields[1].value : null, - fieldName2: $i.fields[2] ? $i.fields[2].name : null, - fieldValue2: $i.fields[2] ? $i.fields[2].value : null, - fieldName3: $i.fields[3] ? $i.fields[3].name : null, - fieldValue3: $i.fields[3] ? $i.fields[3].value : null, -}); - watch(() => profile, () => { save(); }, { deep: true, }); +const fields = reactive($i.fields.map(field => ({ name: field.name, value: field.value }))); + +function addField() { + fields.push({ + name: '', + value: '', + }); +} + +while (fields.length < 4) { + addField(); +} + +function saveFields() { + os.apiWithDialog('i/update', { + fields: fields.filter(field => field.name !== '' && field.value !== ''), + }); +} + function save() { os.apiWithDialog('i/update', { name: profile.name || null, @@ -123,79 +151,6 @@ function changeBanner(ev) { }); } -async function editMetadata() { - const { canceled, result } = await os.form(i18n.ts._profile.metadata, { - fieldName0: { - type: 'string', - label: i18n.ts._profile.metadataLabel + ' 1', - default: additionalFields.fieldName0, - }, - fieldValue0: { - type: 'string', - label: i18n.ts._profile.metadataContent + ' 1', - default: additionalFields.fieldValue0, - }, - fieldName1: { - type: 'string', - label: i18n.ts._profile.metadataLabel + ' 2', - default: additionalFields.fieldName1, - }, - fieldValue1: { - type: 'string', - label: i18n.ts._profile.metadataContent + ' 2', - default: additionalFields.fieldValue1, - }, - fieldName2: { - type: 'string', - label: i18n.ts._profile.metadataLabel + ' 3', - default: additionalFields.fieldName2, - }, - fieldValue2: { - type: 'string', - label: i18n.ts._profile.metadataContent + ' 3', - default: additionalFields.fieldValue2, - }, - fieldName3: { - type: 'string', - label: i18n.ts._profile.metadataLabel + ' 4', - default: additionalFields.fieldName3, - }, - fieldValue3: { - type: 'string', - label: i18n.ts._profile.metadataContent + ' 4', - default: additionalFields.fieldValue3, - }, - }); - if (canceled) return; - - additionalFields.fieldName0 = result.fieldName0; - additionalFields.fieldValue0 = result.fieldValue0; - additionalFields.fieldName1 = result.fieldName1; - additionalFields.fieldValue1 = result.fieldValue1; - additionalFields.fieldName2 = result.fieldName2; - additionalFields.fieldValue2 = result.fieldValue2; - additionalFields.fieldName3 = result.fieldName3; - additionalFields.fieldValue3 = result.fieldValue3; - - const fields = [ - { name: additionalFields.fieldName0, value: additionalFields.fieldValue0 }, - { name: additionalFields.fieldName1, value: additionalFields.fieldValue1 }, - { name: additionalFields.fieldName2, value: additionalFields.fieldValue2 }, - { name: additionalFields.fieldName3, value: additionalFields.fieldValue3 }, - ]; - - os.api('i/update', { - fields, - }).then(i => { - os.success(); - }).catch(err => { - os.alert({ - type: 'error', - text: err.id - }); - }); -} - defineExpose({ [symbols.PAGE_INFO]: { title: i18n.ts.profile,