From 126b3839ddbfe1cea62973a617a5e2bd85aaf04c Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Thu, 30 Nov 2023 23:45:13 +0100 Subject: [PATCH] upd: add basic search widget Closes transfem-org/Sharkey#181 --- locales/en-US.yml | 1 + locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + .../frontend/src/components/MkWidgets.vue | 7 + .../src/components/SkSearchResultWindow.vue | 30 ++++ .../frontend/src/widgets/WidgetSearch.vue | 156 ++++++++++++++++++ packages/frontend/src/widgets/index.ts | 2 + 7 files changed, 198 insertions(+) create mode 100644 packages/frontend/src/components/SkSearchResultWindow.vue create mode 100644 packages/frontend/src/widgets/WidgetSearch.vue diff --git a/locales/en-US.yml b/locales/en-US.yml index e9c6d1cb3b..9376dcecb2 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1981,6 +1981,7 @@ _widgets: _userList: chooseList: "Select a list" clicker: "Clicker" + search: "Search" _cw: hide: "Hide" show: "Show content" diff --git a/locales/index.d.ts b/locales/index.d.ts index 6aabc72732..1615a72caa 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -2126,6 +2126,7 @@ export interface Locale { "chooseList": string; }; "clicker": string; + "search": string; }; "_cw": { "hide": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 98202a77e9..bab0c02d32 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2030,6 +2030,7 @@ _widgets: _userList: chooseList: "リストを選択" clicker: "クリッカー" + search: "検索" _cw: hide: "隠す" diff --git a/packages/frontend/src/components/MkWidgets.vue b/packages/frontend/src/components/MkWidgets.vue index 95f8950fb8..35300a3bf3 100644 --- a/packages/frontend/src/components/MkWidgets.vue +++ b/packages/frontend/src/components/MkWidgets.vue @@ -65,6 +65,13 @@ const props = defineProps<{ edit: boolean; }>(); +// This will not be available for now as I don't think this is needed +// const notesSearchAvailable = (($i == null && instance.policies.canSearchNotes) || ($i != null && $i.policies.canSearchNotes)); +/* if (!notesSearchAvailable) { + const wid = widgetDefs.findIndex(widget => widget === 'search'); + widgetDefs.splice(wid, 1); +} */ + const emit = defineEmits<{ (ev: 'updateWidgets', widgets: Widget[]): void; (ev: 'addWidget', widget: Widget): void; diff --git a/packages/frontend/src/components/SkSearchResultWindow.vue b/packages/frontend/src/components/SkSearchResultWindow.vue new file mode 100644 index 0000000000..5a0412685a --- /dev/null +++ b/packages/frontend/src/components/SkSearchResultWindow.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/packages/frontend/src/widgets/WidgetSearch.vue b/packages/frontend/src/widgets/WidgetSearch.vue new file mode 100644 index 0000000000..37d92323ec --- /dev/null +++ b/packages/frontend/src/widgets/WidgetSearch.vue @@ -0,0 +1,156 @@ + + + + + diff --git a/packages/frontend/src/widgets/index.ts b/packages/frontend/src/widgets/index.ts index 405c49ab06..ae3bd09c86 100644 --- a/packages/frontend/src/widgets/index.ts +++ b/packages/frontend/src/widgets/index.ts @@ -33,6 +33,7 @@ export default function(app: App) { app.component('WidgetAichan', defineAsyncComponent(() => import('./WidgetAichan.vue'))); app.component('WidgetUserList', defineAsyncComponent(() => import('./WidgetUserList.vue'))); app.component('WidgetClicker', defineAsyncComponent(() => import('./WidgetClicker.vue'))); + app.component('WidgetSearch', defineAsyncComponent(() => import('./WidgetSearch.vue'))); } export const widgets = [ @@ -63,4 +64,5 @@ export const widgets = [ 'aichan', 'userList', 'clicker', + 'search', ];