From cb136e635d8227fe0f5e4dc4d4665dbe5f31cf9b Mon Sep 17 00:00:00 2001
From: samunohito <46447427+samunohito@users.noreply.github.com>
Date: Tue, 27 Feb 2024 21:00:03 +0900
Subject: [PATCH] separate sort order component
---
.../pages/admin/custom-emojis-manager.impl.ts | 20 +++
.../custom-emojis-manager.local.list.vue | 115 ++----------------
.../custom-emojis-manager.local.register.vue | 12 +-
... => custom-emojis-manager.logs-folder.vue} | 45 ++++---
.../admin/custom-emojis-manager.remote.vue | 111 ++---------------
...ustom-emojis-manager.sort-order-folder.vue | 112 +++++++++++++++++
6 files changed, 175 insertions(+), 240 deletions(-)
rename packages/frontend/src/pages/admin/{custom-emojis-manager.logs.vue => custom-emojis-manager.logs-folder.vue} (66%)
create mode 100644 packages/frontend/src/pages/admin/custom-emojis-manager.sort-order-folder.vue
diff --git a/packages/frontend/src/pages/admin/custom-emojis-manager.impl.ts b/packages/frontend/src/pages/admin/custom-emojis-manager.impl.ts
index 900217c683..3bf0404a97 100644
--- a/packages/frontend/src/pages/admin/custom-emojis-manager.impl.ts
+++ b/packages/frontend/src/pages/admin/custom-emojis-manager.impl.ts
@@ -5,6 +5,26 @@ export type RequestLogItem = {
error?: string;
};
+export const gridSortOrderKeys = [
+ 'name',
+ 'category',
+ 'aliases',
+ 'type',
+ 'license',
+ 'host',
+ 'uri',
+ 'publicUrl',
+ 'isSensitive',
+ 'localOnly',
+ 'updatedAt',
+];
+export type GridSortOrderKey = typeof gridSortOrderKeys[number];
+
+export type GridSortOrder = {
+ key: GridSortOrderKey;
+ direction: 'ASC' | 'DESC';
+}
+
export function emptyStrToUndefined(value: string | null) {
return value ? value : undefined;
}
diff --git a/packages/frontend/src/pages/admin/custom-emojis-manager.local.list.vue b/packages/frontend/src/pages/admin/custom-emojis-manager.local.list.vue
index d79d582f76..adc581e499 100644
--- a/packages/frontend/src/pages/admin/custom-emojis-manager.local.list.vue
+++ b/packages/frontend/src/pages/admin/custom-emojis-manager.local.list.vue
@@ -118,26 +118,7 @@
-
-
- {{ i18n.ts._customEmojisManager._gridCommon.sortOrder }}
-
-
+
@@ -150,15 +131,7 @@
-
-
- {{ i18n.ts._customEmojisManager._gridCommon.registrationLogs }}
-
- {{ i18n.ts._customEmojisManager._gridCommon.registrationLogsCaption }}
-
-
-
-
+
@@ -188,7 +161,7 @@ import * as os from '@/os.js';
import {
emptyStrToEmptyArray,
emptyStrToNull,
- emptyStrToUndefined,
+ emptyStrToUndefined, GridSortOrder,
RequestLogItem,
roleIdsParser,
} from '@/pages/admin/custom-emojis-manager.impl.js';
@@ -200,13 +173,12 @@ import { validators } from '@/components/grid/cell-validators.js';
import { GridCellValidationEvent, GridCellValueChangeEvent, GridEvent } from '@/components/grid/grid-event.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkPagingButtons from '@/components/MkPagingButtons.vue';
-import XRegisterLogs from '@/pages/admin/custom-emojis-manager.logs.vue';
+import XRegisterLogsFolder from '@/pages/admin/custom-emojis-manager.logs-folder.vue';
+import XSortOrderFolder from '@/pages/admin/custom-emojis-manager.sort-order-folder.vue';
import MkFolder from '@/components/MkFolder.vue';
import MkSelect from '@/components/MkSelect.vue';
import { deviceKind } from '@/scripts/device-kind.js';
import { GridSetting } from '@/components/grid/grid.js';
-import MkTagItem from '@/components/MkTagItem.vue';
-import { MenuItem } from '@/types/menu.js';
import { selectFile } from '@/scripts/select-file.js';
import { copyGridDataToClipboard, removeDataFromGrid } from '@/components/grid/grid-utils.js';
@@ -228,23 +200,6 @@ type GridItem = {
originalUrl?: string | null;
}
-const gridSortOrderKeys = [
- 'name',
- 'category',
- 'aliases',
- 'type',
- 'license',
- 'isSensitive',
- 'localOnly',
- 'updatedAt',
-];
-type GridSortOrderKey = typeof gridSortOrderKeys[number];
-
-type GridSortOrder = {
- key: GridSortOrderKey;
- direction: 'ASC' | 'DESC';
-}
-
function setupGrid(): GridSetting {
const required = validators.required();
const regex = validators.regex(/^[a-zA-Z0-9_]+$/);
@@ -538,33 +493,8 @@ async function onQueryRolesEditClicked() {
queryRoles.value = result.result;
}
-function onToggleSortOrderButtonClicked(order: GridSortOrder) {
- switch (order.direction) {
- case 'ASC':
- order.direction = 'DESC';
- break;
- case 'DESC':
- order.direction = 'ASC';
- break;
- }
-}
-
-function onRemoveSortOrderButtonClicked(key: GridSortOrderKey) {
- sortOrders.value = sortOrders.value.filter(it => it.key !== key);
-}
-
-function onAddSortOrderButtonClicked(ev: MouseEvent) {
- const menuItems: MenuItem[] = gridSortOrderKeys
- .filter(key => !sortOrders.value.map(it => it.key).includes(key))
- .map(it => {
- return {
- text: it,
- action: () => {
- sortOrders.value.push({ key: it, direction: 'ASC' });
- },
- };
- });
- os.contextMenu(menuItems, ev);
+function onSortOrderUpdate(_sortOrders: GridSortOrder[]) {
+ sortOrders.value = _sortOrders;
}
async function onSearchRequest() {
@@ -751,37 +681,6 @@ onMounted(async () => {
gap: 8px;
}
-.sortOrderArea {
- display: flex;
- flex-direction: row;
- align-items: flex-start;
- justify-content: flex-start;
-}
-
-.sortOrderAreaTags {
- display: flex;
- flex-direction: row;
- align-items: flex-start;
- justify-content: flex-start;
- flex-wrap: wrap;
- gap: 8px;
-}
-
-.sortOrderAddButton {
- display: flex;
- justify-content: center;
- align-items: center;
- box-sizing: border-box;
- min-width: 2.0em;
- min-height: 2.0em;
- max-width: 2.0em;
- max-height: 2.0em;
- padding: 8px;
- margin-left: auto;
- border-radius: 9999px;
- background-color: var(--buttonBg);
-}
-
.gridArea {
overflow: scroll;
padding-top: 8px;
diff --git a/packages/frontend/src/pages/admin/custom-emojis-manager.local.register.vue b/packages/frontend/src/pages/admin/custom-emojis-manager.local.register.vue
index 135b16ef41..a8fb290737 100644
--- a/packages/frontend/src/pages/admin/custom-emojis-manager.local.register.vue
+++ b/packages/frontend/src/pages/admin/custom-emojis-manager.local.register.vue
@@ -25,15 +25,7 @@
-
-
- {{ i18n.ts._customEmojisManager._gridCommon.registrationLogs }}
-
- {{ i18n.ts._customEmojisManager._gridCommon.registrationLogsCaption }}
-
-
-
-
+
-
-
-
- {{ i18n.ts._customEmojisManager._logs.showSuccessLogSwitch }}
-
-
-
-
-
-
- {{ i18n.ts._customEmojisManager._logs.failureLogNothing }}
+
+
+ {{ i18n.ts._customEmojisManager._gridCommon.registrationLogs }}
+
+ {{ i18n.ts._customEmojisManager._gridCommon.registrationLogsCaption }}
+
+
+
+
+
+ {{ i18n.ts._customEmojisManager._logs.showSuccessLogSwitch }}
+
+
+
+
+
+
+ {{ i18n.ts._customEmojisManager._logs.failureLogNothing }}
+
+
+ {{ i18n.ts._customEmojisManager._logs.logNothing }}
+
-
- {{ i18n.ts._customEmojisManager._logs.logNothing }}
-
-
+
+
+