Compare commits
18 Commits
meeting-me
...
entity-sel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d32cca4f53 | ||
|
|
4004d9fe52 | ||
|
|
2f99d0b416 | ||
|
|
9c3002f9c7 | ||
|
|
82fd7cddf7 | ||
|
|
10f2920e11 | ||
|
|
75c89b471c | ||
|
|
a804877a08 | ||
|
|
f7441f39e7 | ||
|
|
e647af0777 | ||
| 2049c9b6ec | |||
| 637fc10e64 | |||
| 37d4dcc1a8 | |||
| c369c76c1a | |||
| 86caf793aa | |||
| 499fbd2cb3 | |||
| a4a9293bc2 | |||
| 9ac9f1d4a3 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "timesafari",
|
"name": "timesafari",
|
||||||
"version": "1.1.0-beta",
|
"version": "1.1.1-beta",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "timesafari",
|
"name": "timesafari",
|
||||||
"version": "1.1.0-beta",
|
"version": "1.1.1-beta",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor-community/electron": "^5.0.1",
|
"@capacitor-community/electron": "^5.0.1",
|
||||||
"@capacitor-community/sqlite": "6.0.2",
|
"@capacitor-community/sqlite": "6.0.2",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dialog {
|
.dialog {
|
||||||
@apply bg-white p-4 rounded-lg w-full max-w-lg;
|
@apply bg-white p-4 rounded-lg w-full max-w-lg max-h-[calc(100vh-3rem)] overflow-y-auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Markdown content styling to restore list elements */
|
/* Markdown content styling to restore list elements */
|
||||||
|
|||||||
@@ -77,12 +77,86 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Description -->
|
<!-- Emoji Section -->
|
||||||
<p class="font-medium overflow-hidden">
|
<div
|
||||||
<a
|
v-if="hasEmojis || isRegistered"
|
||||||
class="block cursor-pointer overflow-hidden text-ellipsis"
|
class="float-right ml-3 mb-1 bg-white rounded border border-slate-300 px-1.5 py-0.5 max-w-[240px]"
|
||||||
@click="emitLoadClaim(record.jwtId)"
|
>
|
||||||
|
<div class="flex items-center justify-between gap-1">
|
||||||
|
<!-- Existing Emojis Display -->
|
||||||
|
<div v-if="hasEmojis" class="flex flex-wrap gap-1">
|
||||||
|
<button
|
||||||
|
v-for="(count, emoji) in record.emojiCount"
|
||||||
|
:key="emoji"
|
||||||
|
class="inline-flex items-center gap-0.5 px-1 py-0.5 text-xs bg-slate-50 hover:bg-slate-100 rounded border border-slate-200 transition-colors cursor-pointer"
|
||||||
|
:class="{
|
||||||
|
'bg-blue-50 border-blue-200': isUserEmojiWithoutLoading(emoji),
|
||||||
|
'opacity-75 cursor-wait': loadingEmojis,
|
||||||
|
}"
|
||||||
|
:title="
|
||||||
|
loadingEmojis
|
||||||
|
? 'Loading...'
|
||||||
|
: !emojisOnActivity?.isResolved
|
||||||
|
? 'Click to load your emojis'
|
||||||
|
: isUserEmojiWithoutLoading(emoji)
|
||||||
|
? 'Click to remove your emoji'
|
||||||
|
: 'Click to add this emoji'
|
||||||
|
"
|
||||||
|
:disabled="!isRegistered"
|
||||||
|
@click="toggleThisEmoji(emoji)"
|
||||||
|
>
|
||||||
|
<!-- Show spinner when loading -->
|
||||||
|
<div v-if="loadingEmojis" class="animate-spin text-xs">
|
||||||
|
<font-awesome icon="spinner" class="fa-spin" />
|
||||||
|
</div>
|
||||||
|
<span v-else class="text-sm leading-none">{{ emoji }}</span>
|
||||||
|
<span class="text-xs text-slate-600 font-medium leading-none">{{
|
||||||
|
count
|
||||||
|
}}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Add Emoji Button -->
|
||||||
|
<button
|
||||||
|
v-if="isRegistered"
|
||||||
|
class="inline-flex px-1 py-0.5 text-xs bg-slate-100 hover:bg-slate-200 rounded border border-slate-300 transition-colors items-center justify-center ml-2 ml-auto"
|
||||||
|
:title="showEmojiPicker ? 'Close emoji picker' : 'Add emoji'"
|
||||||
|
@click="toggleEmojiPicker"
|
||||||
|
>
|
||||||
|
<span class="px-2 text-sm leading-none">{{
|
||||||
|
showEmojiPicker ? "x" : "😊"
|
||||||
|
}}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Emoji Picker (placeholder for now) -->
|
||||||
|
<div
|
||||||
|
v-if="showEmojiPicker"
|
||||||
|
class="mt-1 p-1.5 bg-slate-50 rounded border border-slate-300"
|
||||||
>
|
>
|
||||||
|
<!-- Temporary emoji buttons for testing -->
|
||||||
|
<div class="flex flex-wrap gap-3 mt-1">
|
||||||
|
<button
|
||||||
|
v-for="emoji in QUICK_EMOJIS"
|
||||||
|
:key="emoji"
|
||||||
|
class="p-0.5 hover:bg-slate-200 rounded text-base transition-opacity"
|
||||||
|
:class="{
|
||||||
|
'opacity-75 cursor-wait': loadingEmojis,
|
||||||
|
}"
|
||||||
|
:disabled="loadingEmojis"
|
||||||
|
@click="toggleThisEmoji(emoji)"
|
||||||
|
>
|
||||||
|
<!-- Show spinner when loading -->
|
||||||
|
<div v-if="loadingEmojis" class="animate-spin text-sm">⟳</div>
|
||||||
|
<span v-else>{{ emoji }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Description -->
|
||||||
|
<p class="font-medium">
|
||||||
|
<a class="block cursor-pointer" @click="emitLoadClaim(record.jwtId)">
|
||||||
<vue-markdown
|
<vue-markdown
|
||||||
:source="truncatedDescription"
|
:source="truncatedDescription"
|
||||||
class="markdown-content"
|
class="markdown-content"
|
||||||
@@ -91,7 +165,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="relative flex justify-between gap-4 max-w-[40rem] mx-auto mt-4"
|
class="clear-right relative flex justify-between gap-4 max-w-[40rem] mx-auto mt-4"
|
||||||
>
|
>
|
||||||
<!-- Source -->
|
<!-- Source -->
|
||||||
<div
|
<div
|
||||||
@@ -254,17 +328,24 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Prop, Vue, Emit } from "vue-facing-decorator";
|
import { Component, Prop, Vue, Emit } from "vue-facing-decorator";
|
||||||
import { GiveRecordWithContactInfo } from "@/interfaces/give";
|
import VueMarkdown from "vue-markdown-render";
|
||||||
|
|
||||||
|
import { logger } from "../utils/logger";
|
||||||
|
import {
|
||||||
|
createAndSubmitClaim,
|
||||||
|
getHeaders,
|
||||||
|
isHiddenDid,
|
||||||
|
} from "../libs/endorserServer";
|
||||||
import EntityIcon from "./EntityIcon.vue";
|
import EntityIcon from "./EntityIcon.vue";
|
||||||
import { isHiddenDid } from "../libs/endorserServer";
|
|
||||||
import ProjectIcon from "./ProjectIcon.vue";
|
import ProjectIcon from "./ProjectIcon.vue";
|
||||||
import { createNotifyHelpers, NotifyFunction } from "@/utils/notify";
|
import { createNotifyHelpers, NotifyFunction, TIMEOUTS } from "@/utils/notify";
|
||||||
import {
|
import {
|
||||||
NOTIFY_PERSON_HIDDEN,
|
NOTIFY_PERSON_HIDDEN,
|
||||||
NOTIFY_UNKNOWN_PERSON,
|
NOTIFY_UNKNOWN_PERSON,
|
||||||
} from "@/constants/notifications";
|
} from "@/constants/notifications";
|
||||||
import { TIMEOUTS } from "@/utils/notify";
|
import { EmojiSummaryRecord, GenericVerifiableCredential } from "@/interfaces";
|
||||||
import VueMarkdown from "vue-markdown-render";
|
import { GiveRecordWithContactInfo } from "@/interfaces/give";
|
||||||
|
import { PromiseTracker } from "@/libs/util";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
@@ -274,15 +355,24 @@ import VueMarkdown from "vue-markdown-render";
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class ActivityListItem extends Vue {
|
export default class ActivityListItem extends Vue {
|
||||||
|
readonly QUICK_EMOJIS = ["👍", "👏", "❤️", "🎉", "😊", "😆", "🔥"];
|
||||||
|
|
||||||
@Prop() record!: GiveRecordWithContactInfo;
|
@Prop() record!: GiveRecordWithContactInfo;
|
||||||
@Prop() lastViewedClaimId?: string;
|
@Prop() lastViewedClaimId?: string;
|
||||||
@Prop() isRegistered!: boolean;
|
@Prop() isRegistered!: boolean;
|
||||||
@Prop() activeDid!: string;
|
@Prop() activeDid!: string;
|
||||||
|
@Prop() apiServer!: string;
|
||||||
|
|
||||||
isHiddenDid = isHiddenDid;
|
isHiddenDid = isHiddenDid;
|
||||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||||
$notify!: NotifyFunction;
|
$notify!: NotifyFunction;
|
||||||
|
|
||||||
|
// Emoji-related data
|
||||||
|
showEmojiPicker = false;
|
||||||
|
loadingEmojis = false; // Track if emojis are currently loading
|
||||||
|
|
||||||
|
emojisOnActivity: PromiseTracker<EmojiSummaryRecord[]> | null = null; // load this only when needed
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.notify = createNotifyHelpers(this.$notify);
|
this.notify = createNotifyHelpers(this.$notify);
|
||||||
}
|
}
|
||||||
@@ -346,5 +436,186 @@ export default class ActivityListItem extends Vue {
|
|||||||
day: "numeric",
|
day: "numeric",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emoji-related computed properties and methods
|
||||||
|
get hasEmojis(): boolean {
|
||||||
|
return Object.keys(this.record.emojiCount).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
triggerUserEmojiLoad(): PromiseTracker<EmojiSummaryRecord[]> {
|
||||||
|
if (!this.emojisOnActivity) {
|
||||||
|
const promise = new Promise<EmojiSummaryRecord[]>((resolve) => {
|
||||||
|
(async () => {
|
||||||
|
this.axios
|
||||||
|
.get(
|
||||||
|
`${this.apiServer}/api/v2/report/emoji?parentHandleId=${encodeURIComponent(this.record.handleId)}`,
|
||||||
|
{ headers: await getHeaders(this.activeDid) },
|
||||||
|
)
|
||||||
|
.then((response) => {
|
||||||
|
const userEmojiRecords = response.data.data.filter(
|
||||||
|
(e: EmojiSummaryRecord) => e.issuerDid === this.activeDid,
|
||||||
|
);
|
||||||
|
resolve(userEmojiRecords);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
logger.error("Error loading user emojis:", error);
|
||||||
|
resolve([]);
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.emojisOnActivity = new PromiseTracker(promise);
|
||||||
|
}
|
||||||
|
return this.emojisOnActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param emoji - The emoji to check.
|
||||||
|
* @returns True if the emoji is in the user's emojis, false otherwise.
|
||||||
|
*
|
||||||
|
* @note This method is quick and synchronous, and can check resolved emojis
|
||||||
|
* without triggering a server request. Returns false if emojis haven't been loaded yet.
|
||||||
|
*/
|
||||||
|
isUserEmojiWithoutLoading(emoji: string): boolean {
|
||||||
|
if (this.emojisOnActivity?.isResolved && this.emojisOnActivity.value) {
|
||||||
|
return this.emojisOnActivity.value.some(
|
||||||
|
(record) => record.text === emoji,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async toggleEmojiPicker() {
|
||||||
|
this.triggerUserEmojiLoad(); // trigger it, but don't wait for it to complete
|
||||||
|
this.showEmojiPicker = !this.showEmojiPicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
async toggleThisEmoji(emoji: string) {
|
||||||
|
// Start loading indicator
|
||||||
|
this.loadingEmojis = true;
|
||||||
|
this.showEmojiPicker = false; // always close the picker when an emoji is clicked
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.triggerUserEmojiLoad(); // trigger just in case
|
||||||
|
|
||||||
|
const userEmojiList = await this.emojisOnActivity!.promise; // must wait now that they've chosen
|
||||||
|
|
||||||
|
const userHasEmoji: boolean = userEmojiList.some(
|
||||||
|
(record) => record.text === emoji,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (userHasEmoji) {
|
||||||
|
this.$notify(
|
||||||
|
{
|
||||||
|
group: "modal",
|
||||||
|
type: "confirm",
|
||||||
|
title: "Remove Emoji",
|
||||||
|
text: `Do you want to remove your ${emoji} ?`,
|
||||||
|
yesText: "Remove",
|
||||||
|
onYes: async () => {
|
||||||
|
await this.removeEmoji(emoji);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TIMEOUTS.MODAL,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// User doesn't have this emoji, add it
|
||||||
|
await this.submitEmoji(emoji);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// Remove loading indicator
|
||||||
|
this.loadingEmojis = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async submitEmoji(emoji: string) {
|
||||||
|
try {
|
||||||
|
// Create an Emoji claim and send to the server
|
||||||
|
const emojiClaim: GenericVerifiableCredential = {
|
||||||
|
"@context": "https://endorser.ch",
|
||||||
|
"@type": "Emoji",
|
||||||
|
text: emoji,
|
||||||
|
parentItem: { lastClaimId: this.record.jwtId },
|
||||||
|
};
|
||||||
|
const claim = await createAndSubmitClaim(
|
||||||
|
emojiClaim,
|
||||||
|
this.activeDid,
|
||||||
|
this.apiServer,
|
||||||
|
this.axios,
|
||||||
|
);
|
||||||
|
if (claim.success && !claim.embeddedRecordError) {
|
||||||
|
// Update emoji count
|
||||||
|
this.record.emojiCount[emoji] =
|
||||||
|
(this.record.emojiCount[emoji] || 0) + 1;
|
||||||
|
|
||||||
|
// Create a new emoji record (we'll get the actual jwtId from the server response later)
|
||||||
|
const newEmojiRecord: EmojiSummaryRecord = {
|
||||||
|
issuerDid: this.activeDid,
|
||||||
|
jwtId: claim.claimId || "",
|
||||||
|
text: emoji,
|
||||||
|
parentHandleId: this.record.jwtId,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Update user emojis list by creating a new promise with the updated data
|
||||||
|
// (Trigger shouldn't be necessary since all calls should come through a toggle, but just in case someone calls this directly)
|
||||||
|
this.triggerUserEmojiLoad();
|
||||||
|
const currentEmojis = await this.emojisOnActivity!.promise; // must wait now that they've clicked one
|
||||||
|
this.emojisOnActivity = new PromiseTracker(
|
||||||
|
Promise.resolve([...currentEmojis, newEmojiRecord]),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.notify.error("Failed to add emoji.", TIMEOUTS.STANDARD);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error submitting emoji:", error);
|
||||||
|
this.notify.error("Got error adding emoji.", TIMEOUTS.STANDARD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async removeEmoji(emoji: string) {
|
||||||
|
try {
|
||||||
|
// Create an Emoji claim and send to the server
|
||||||
|
const emojiClaim: GenericVerifiableCredential = {
|
||||||
|
"@context": "https://endorser.ch",
|
||||||
|
"@type": "Emoji",
|
||||||
|
text: emoji,
|
||||||
|
parentItem: { lastClaimId: this.record.jwtId },
|
||||||
|
};
|
||||||
|
const claim = await createAndSubmitClaim(
|
||||||
|
emojiClaim,
|
||||||
|
this.activeDid,
|
||||||
|
this.apiServer,
|
||||||
|
this.axios,
|
||||||
|
);
|
||||||
|
if (claim.success && !claim.embeddedRecordError) {
|
||||||
|
// Update emoji count
|
||||||
|
const newCount = Math.max(0, (this.record.emojiCount[emoji] || 0) - 1);
|
||||||
|
if (newCount === 0) {
|
||||||
|
delete this.record.emojiCount[emoji];
|
||||||
|
} else {
|
||||||
|
this.record.emojiCount[emoji] = newCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update user emojis list by creating a new promise with the updated data
|
||||||
|
// (Trigger shouldn't be necessary since all calls should come through a toggle, but just in case someone calls this directly)
|
||||||
|
this.triggerUserEmojiLoad();
|
||||||
|
const currentEmojis = await this.emojisOnActivity!.promise; // must wait now that they've clicked one
|
||||||
|
this.emojisOnActivity = new PromiseTracker(
|
||||||
|
Promise.resolve(
|
||||||
|
currentEmojis.filter(
|
||||||
|
(record) =>
|
||||||
|
record.issuerDid === this.activeDid && record.text !== emoji,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.notify.error("Failed to remove emoji.", TIMEOUTS.STANDARD);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error removing emoji:", error);
|
||||||
|
this.notify.error("Got error removing emoji.", TIMEOUTS.STANDARD);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,12 +2,55 @@
|
|||||||
GiftedDialog.vue to provide a reusable grid layout * for displaying people,
|
GiftedDialog.vue to provide a reusable grid layout * for displaying people,
|
||||||
projects, and special entities with selection. * * @author Matthew Raymer */
|
projects, and special entities with selection. * * @author Matthew Raymer */
|
||||||
<template>
|
<template>
|
||||||
<ul :class="gridClasses">
|
<!-- Quick Search -->
|
||||||
|
<div id="QuickSearch" class="mb-4 flex items-center text-sm">
|
||||||
|
<input
|
||||||
|
v-model="searchTerm"
|
||||||
|
type="text"
|
||||||
|
placeholder="Search…"
|
||||||
|
class="block w-full rounded-l border border-r-0 border-slate-400 px-3 py-1.5 placeholder:italic placeholder:text-slate-400 focus:outline-none"
|
||||||
|
@input="handleSearchInput"
|
||||||
|
@keydown.enter="performSearch"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-show="isSearching && searchTerm"
|
||||||
|
class="border-y border-slate-400 ps-2 py-1.5 text-center text-slate-400"
|
||||||
|
>
|
||||||
|
<font-awesome
|
||||||
|
icon="spinner"
|
||||||
|
class="fa-spin-pulse leading-[1.1]"
|
||||||
|
></font-awesome>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
:disabled="!searchTerm"
|
||||||
|
class="px-2 py-1.5 rounded-r bg-white border border-l-0 border-slate-400 text-slate-400 disabled:cursor-not-allowed"
|
||||||
|
@click="clearSearch"
|
||||||
|
>
|
||||||
|
<font-awesome
|
||||||
|
:icon="searchTerm ? 'times' : 'magnifying-glass'"
|
||||||
|
class="fa-fw"
|
||||||
|
></font-awesome>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="searchTerm && !isSearching && filteredEntities.length === 0"
|
||||||
|
class="mb-4 text-sm italic text-slate-500 text-center"
|
||||||
|
>
|
||||||
|
“{{ searchTerm }}” doesn't match any
|
||||||
|
{{ entityType === "people" ? "people" : "projects" }}. Try a different
|
||||||
|
search.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul
|
||||||
|
ref="scrollContainer"
|
||||||
|
class="border-t border-slate-300 mb-4 max-h-[60vh] overflow-y-auto"
|
||||||
|
>
|
||||||
<!-- Special entities (You, Unnamed) for people grids -->
|
<!-- Special entities (You, Unnamed) for people grids -->
|
||||||
<template v-if="entityType === 'people'">
|
<template v-if="entityType === 'people'">
|
||||||
<!-- "You" entity -->
|
<!-- "You" entity -->
|
||||||
<SpecialEntityCard
|
<SpecialEntityCard
|
||||||
v-if="showYouEntity"
|
v-if="showYouEntity && !searchTerm.trim()"
|
||||||
entity-type="you"
|
entity-type="you"
|
||||||
label="You"
|
label="You"
|
||||||
icon="hand"
|
icon="hand"
|
||||||
@@ -21,6 +64,7 @@ projects, and special entities with selection. * * @author Matthew Raymer */
|
|||||||
|
|
||||||
<!-- "Unnamed" entity -->
|
<!-- "Unnamed" entity -->
|
||||||
<SpecialEntityCard
|
<SpecialEntityCard
|
||||||
|
v-if="showUnnamedEntity && !searchTerm.trim()"
|
||||||
entity-type="unnamed"
|
entity-type="unnamed"
|
||||||
:label="unnamedEntityName"
|
:label="unnamedEntityName"
|
||||||
icon="circle-question"
|
icon="circle-question"
|
||||||
@@ -38,16 +82,60 @@ projects, and special entities with selection. * * @author Matthew Raymer */
|
|||||||
|
|
||||||
<!-- Entity cards (people or projects) -->
|
<!-- Entity cards (people or projects) -->
|
||||||
<template v-if="entityType === 'people'">
|
<template v-if="entityType === 'people'">
|
||||||
<PersonCard
|
<!-- When showing contacts without search: split into recent and alphabetical -->
|
||||||
v-for="person in displayedEntities as Contact[]"
|
<template v-if="!searchTerm.trim()">
|
||||||
:key="person.did"
|
<!-- Recently Added Section -->
|
||||||
:person="person"
|
<template v-if="recentContacts.length > 0">
|
||||||
:conflicted="isPersonConflicted(person.did)"
|
<li
|
||||||
:show-time-icon="true"
|
class="text-xs font-semibold text-slate-500 uppercase pt-5 pb-1.5 px-2 border-b border-slate-300"
|
||||||
:notify="notify"
|
>
|
||||||
:conflict-context="conflictContext"
|
Recently Added
|
||||||
@person-selected="handlePersonSelected"
|
</li>
|
||||||
/>
|
<PersonCard
|
||||||
|
v-for="person in recentContacts"
|
||||||
|
:key="person.did"
|
||||||
|
:person="person"
|
||||||
|
:conflicted="isPersonConflicted(person.did)"
|
||||||
|
:show-time-icon="true"
|
||||||
|
:notify="notify"
|
||||||
|
:conflict-context="conflictContext"
|
||||||
|
@person-selected="handlePersonSelected"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Alphabetical Section -->
|
||||||
|
<template v-if="alphabeticalContacts.length > 0">
|
||||||
|
<li
|
||||||
|
class="text-xs font-semibold text-slate-500 uppercase pt-5 pb-1.5 px-2 border-b border-slate-300"
|
||||||
|
>
|
||||||
|
Everyone Else
|
||||||
|
</li>
|
||||||
|
<PersonCard
|
||||||
|
v-for="person in alphabeticalContacts"
|
||||||
|
:key="person.did"
|
||||||
|
:person="person"
|
||||||
|
:conflicted="isPersonConflicted(person.did)"
|
||||||
|
:show-time-icon="true"
|
||||||
|
:notify="notify"
|
||||||
|
:conflict-context="conflictContext"
|
||||||
|
@person-selected="handlePersonSelected"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- When searching: show filtered results normally -->
|
||||||
|
<template v-else>
|
||||||
|
<PersonCard
|
||||||
|
v-for="person in displayedEntities as Contact[]"
|
||||||
|
:key="person.did"
|
||||||
|
:person="person"
|
||||||
|
:conflicted="isPersonConflicted(person.did)"
|
||||||
|
:show-time-icon="true"
|
||||||
|
:notify="notify"
|
||||||
|
:conflict-context="conflictContext"
|
||||||
|
@person-selected="handlePersonSelected"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-else-if="entityType === 'projects'">
|
<template v-else-if="entityType === 'projects'">
|
||||||
@@ -63,28 +151,27 @@ projects, and special entities with selection. * * @author Matthew Raymer */
|
|||||||
@project-selected="handleProjectSelected"
|
@project-selected="handleProjectSelected"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Show All navigation -->
|
|
||||||
<ShowAllCard
|
|
||||||
v-if="shouldShowAll"
|
|
||||||
:entity-type="entityType"
|
|
||||||
:route-name="showAllRoute"
|
|
||||||
:query-params="showAllQueryParams"
|
|
||||||
/>
|
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Prop, Vue, Emit } from "vue-facing-decorator";
|
import { Component, Prop, Vue, Emit, Watch } from "vue-facing-decorator";
|
||||||
|
import { useInfiniteScroll } from "@vueuse/core";
|
||||||
import PersonCard from "./PersonCard.vue";
|
import PersonCard from "./PersonCard.vue";
|
||||||
import ProjectCard from "./ProjectCard.vue";
|
import ProjectCard from "./ProjectCard.vue";
|
||||||
import SpecialEntityCard from "./SpecialEntityCard.vue";
|
import SpecialEntityCard from "./SpecialEntityCard.vue";
|
||||||
import ShowAllCard from "./ShowAllCard.vue";
|
|
||||||
import { Contact } from "../db/tables/contacts";
|
import { Contact } from "../db/tables/contacts";
|
||||||
import { PlanData } from "../interfaces/records";
|
import { PlanData } from "../interfaces/records";
|
||||||
import { NotificationIface } from "../constants/app";
|
import { NotificationIface } from "../constants/app";
|
||||||
import { UNNAMED_ENTITY_NAME } from "@/constants/entities";
|
import { UNNAMED_ENTITY_NAME } from "@/constants/entities";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants for infinite scroll configuration
|
||||||
|
*/
|
||||||
|
const INITIAL_BATCH_SIZE = 20;
|
||||||
|
const INCREMENT_SIZE = 20;
|
||||||
|
const RECENT_CONTACTS_COUNT = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EntityGrid - Unified grid layout for displaying people or projects
|
* EntityGrid - Unified grid layout for displaying people or projects
|
||||||
*
|
*
|
||||||
@@ -93,7 +180,6 @@ import { UNNAMED_ENTITY_NAME } from "@/constants/entities";
|
|||||||
* - Special entity integration (You, Unnamed)
|
* - Special entity integration (You, Unnamed)
|
||||||
* - Conflict detection integration
|
* - Conflict detection integration
|
||||||
* - Empty state messaging
|
* - Empty state messaging
|
||||||
* - Show All navigation
|
|
||||||
* - Event delegation for entity selection
|
* - Event delegation for entity selection
|
||||||
* - Warning notifications for conflicted entities
|
* - Warning notifications for conflicted entities
|
||||||
* - Template streamlined with computed CSS properties
|
* - Template streamlined with computed CSS properties
|
||||||
@@ -104,7 +190,6 @@ import { UNNAMED_ENTITY_NAME } from "@/constants/entities";
|
|||||||
PersonCard,
|
PersonCard,
|
||||||
ProjectCard,
|
ProjectCard,
|
||||||
SpecialEntityCard,
|
SpecialEntityCard,
|
||||||
ShowAllCard,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class EntityGrid extends Vue {
|
export default class EntityGrid extends Vue {
|
||||||
@@ -112,14 +197,21 @@ export default class EntityGrid extends Vue {
|
|||||||
@Prop({ required: true })
|
@Prop({ required: true })
|
||||||
entityType!: "people" | "projects";
|
entityType!: "people" | "projects";
|
||||||
|
|
||||||
|
// Search state
|
||||||
|
searchTerm = "";
|
||||||
|
isSearching = false;
|
||||||
|
searchTimeout: NodeJS.Timeout | null = null;
|
||||||
|
filteredEntities: Contact[] | PlanData[] = [];
|
||||||
|
|
||||||
|
// Infinite scroll state
|
||||||
|
displayedCount = INITIAL_BATCH_SIZE;
|
||||||
|
infiniteScrollReset?: () => void;
|
||||||
|
scrollContainer?: HTMLElement;
|
||||||
|
|
||||||
/** Array of entities to display */
|
/** Array of entities to display */
|
||||||
@Prop({ required: true })
|
@Prop({ required: true })
|
||||||
entities!: Contact[] | PlanData[];
|
entities!: Contact[] | PlanData[];
|
||||||
|
|
||||||
/** Maximum number of entities to display */
|
|
||||||
@Prop({ default: 10 })
|
|
||||||
maxItems!: number;
|
|
||||||
|
|
||||||
/** Active user's DID */
|
/** Active user's DID */
|
||||||
@Prop({ required: true })
|
@Prop({ required: true })
|
||||||
activeDid!: string;
|
activeDid!: string;
|
||||||
@@ -140,18 +232,14 @@ export default class EntityGrid extends Vue {
|
|||||||
@Prop({ default: true })
|
@Prop({ default: true })
|
||||||
showYouEntity!: boolean;
|
showYouEntity!: boolean;
|
||||||
|
|
||||||
|
/** Whether to show the "Unnamed" entity for people grids */
|
||||||
|
@Prop({ default: true })
|
||||||
|
showUnnamedEntity!: boolean;
|
||||||
|
|
||||||
/** Whether the "You" entity is selectable */
|
/** Whether the "You" entity is selectable */
|
||||||
@Prop({ default: true })
|
@Prop({ default: true })
|
||||||
youSelectable!: boolean;
|
youSelectable!: boolean;
|
||||||
|
|
||||||
/** Route name for "Show All" navigation */
|
|
||||||
@Prop({ default: "" })
|
|
||||||
showAllRoute!: string;
|
|
||||||
|
|
||||||
/** Query parameters for "Show All" navigation */
|
|
||||||
@Prop({ default: () => ({}) })
|
|
||||||
showAllQueryParams!: Record<string, string>;
|
|
||||||
|
|
||||||
/** Notification function from parent component */
|
/** Notification function from parent component */
|
||||||
@Prop()
|
@Prop()
|
||||||
notify?: (notification: NotificationIface, timeout?: number) => void;
|
notify?: (notification: NotificationIface, timeout?: number) => void;
|
||||||
@@ -160,42 +248,31 @@ export default class EntityGrid extends Vue {
|
|||||||
@Prop({ default: "other party" })
|
@Prop({ default: "other party" })
|
||||||
conflictContext!: string;
|
conflictContext!: string;
|
||||||
|
|
||||||
/** Whether to hide the "Show All" navigation */
|
|
||||||
@Prop({ default: false })
|
|
||||||
hideShowAll!: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to determine which entities to display (allows parent control)
|
* Function to determine which entities to display (allows parent control)
|
||||||
*
|
*
|
||||||
* This function prop allows parent components to customize which entities
|
* This function prop allows parent components to customize which entities
|
||||||
* are displayed in the grid, enabling advanced filtering, sorting, and
|
* are displayed in the grid, enabling advanced filtering and sorting.
|
||||||
* display logic beyond the default simple slice behavior.
|
* Note: Infinite scroll is disabled when this prop is provided.
|
||||||
*
|
*
|
||||||
* @param entities - The full array of entities (Contact[] or PlanData[])
|
* @param entities - The full array of entities (Contact[] or PlanData[])
|
||||||
* @param entityType - The type of entities being displayed ("people" or "projects")
|
* @param entityType - The type of entities being displayed ("people" or "projects")
|
||||||
* @param maxItems - The maximum number of items to display (from maxItems prop)
|
|
||||||
* @returns Filtered/sorted array of entities to display
|
* @returns Filtered/sorted array of entities to display
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* // Custom filtering: only show contacts with profile images
|
* // Custom filtering: only show contacts with profile images
|
||||||
* :display-entities-function="(entities, type, max) =>
|
* :display-entities-function="(entities, type) =>
|
||||||
* entities.filter(e => e.profileImageUrl).slice(0, max)"
|
* entities.filter(e => e.profileImageUrl)"
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* // Custom sorting: sort projects by name
|
* // Custom sorting: sort projects by name
|
||||||
* :display-entities-function="(entities, type, max) =>
|
* :display-entities-function="(entities, type) =>
|
||||||
* entities.sort((a, b) => a.name.localeCompare(b.name)).slice(0, max)"
|
* entities.sort((a, b) => a.name.localeCompare(b.name))"
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* // Advanced logic: different limits for different entity types
|
|
||||||
* :display-entities-function="(entities, type, max) =>
|
|
||||||
* type === 'projects' ? entities.slice(0, 5) : entities.slice(0, max)"
|
|
||||||
*/
|
*/
|
||||||
@Prop({ default: null })
|
@Prop({ default: null })
|
||||||
displayEntitiesFunction?: (
|
displayEntitiesFunction?: (
|
||||||
entities: Contact[] | PlanData[],
|
entities: Contact[] | PlanData[],
|
||||||
entityType: "people" | "projects",
|
entityType: "people" | "projects",
|
||||||
maxItems: number,
|
|
||||||
) => Contact[] | PlanData[];
|
) => Contact[] | PlanData[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,33 +283,60 @@ export default class EntityGrid extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computed CSS classes for the grid layout
|
* Computed entities to display - uses function prop if provided, otherwise uses infinite scroll
|
||||||
|
* When searching, returns filtered results with infinite scroll applied
|
||||||
*/
|
*/
|
||||||
get gridClasses(): string {
|
get displayedEntities(): Contact[] | PlanData[] {
|
||||||
const baseClasses = "grid gap-x-2 gap-y-4 text-center mb-4";
|
// If searching, return filtered results with infinite scroll
|
||||||
|
if (this.searchTerm.trim()) {
|
||||||
if (this.entityType === "projects") {
|
return this.filteredEntities.slice(0, this.displayedCount);
|
||||||
return `${baseClasses} grid-cols-3 md:grid-cols-4`;
|
|
||||||
} else {
|
|
||||||
return `${baseClasses} grid-cols-4 sm:grid-cols-5 md:grid-cols-6`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If custom function provided, use it (disables infinite scroll)
|
||||||
|
if (this.displayEntitiesFunction) {
|
||||||
|
return this.displayEntitiesFunction(this.entities, this.entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default: projects use infinite scroll
|
||||||
|
if (this.entityType === "projects") {
|
||||||
|
return (this.entities as PlanData[]).slice(0, this.displayedCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// People: handled by recentContacts + alphabeticalContacts (both use displayedCount)
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computed entities to display - uses function prop if provided, otherwise defaults
|
* Get the 3 most recently added contacts (when showing contacts and not searching)
|
||||||
*/
|
*/
|
||||||
get displayedEntities(): Contact[] | PlanData[] {
|
get recentContacts(): Contact[] {
|
||||||
if (this.displayEntitiesFunction) {
|
if (this.entityType !== "people" || this.searchTerm.trim()) {
|
||||||
return this.displayEntitiesFunction(
|
return [];
|
||||||
this.entities,
|
|
||||||
this.entityType,
|
|
||||||
this.maxItems,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
// Entities are already sorted by date added (newest first)
|
||||||
|
return (this.entities as Contact[]).slice(0, 3);
|
||||||
|
}
|
||||||
|
|
||||||
// Default implementation for backward compatibility
|
/**
|
||||||
const maxDisplay = this.entityType === "projects" ? 7 : this.maxItems;
|
* Get the remaining contacts sorted alphabetically (when showing contacts and not searching)
|
||||||
return this.entities.slice(0, maxDisplay);
|
* Uses infinite scroll to control how many are displayed
|
||||||
|
*/
|
||||||
|
get alphabeticalContacts(): Contact[] {
|
||||||
|
if (this.entityType !== "people" || this.searchTerm.trim()) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
// Skip the first 3 (recent contacts) and sort the rest alphabetically
|
||||||
|
// Create a copy to avoid mutating the original array
|
||||||
|
const remaining = (this.entities as Contact[]).slice(RECENT_CONTACTS_COUNT);
|
||||||
|
const sorted = [...remaining].sort((a: Contact, b: Contact) => {
|
||||||
|
// Sort alphabetically by name, falling back to DID if name is missing
|
||||||
|
const nameA = (a.name || a.did).toLowerCase();
|
||||||
|
const nameB = (b.name || b.did).toLowerCase();
|
||||||
|
return nameA.localeCompare(nameB);
|
||||||
|
});
|
||||||
|
// Apply infinite scroll: show based on displayedCount (minus the 3 recent)
|
||||||
|
const toShow = Math.max(0, this.displayedCount - RECENT_CONTACTS_COUNT);
|
||||||
|
return sorted.slice(0, toShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -246,15 +350,6 @@ export default class EntityGrid extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to show the "Show All" navigation
|
|
||||||
*/
|
|
||||||
get shouldShowAll(): boolean {
|
|
||||||
return (
|
|
||||||
!this.hideShowAll && this.entities.length > 0 && this.showAllRoute !== ""
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the "You" entity is conflicted
|
* Whether the "You" entity is conflicted
|
||||||
*/
|
*/
|
||||||
@@ -328,6 +423,144 @@ export default class EntityGrid extends Vue {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle search input with debouncing
|
||||||
|
*/
|
||||||
|
handleSearchInput(): void {
|
||||||
|
// Show spinner immediately when user types
|
||||||
|
this.isSearching = true;
|
||||||
|
|
||||||
|
// Clear existing timeout
|
||||||
|
if (this.searchTimeout) {
|
||||||
|
clearTimeout(this.searchTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set new timeout for 500ms delay
|
||||||
|
this.searchTimeout = setTimeout(() => {
|
||||||
|
this.performSearch();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform the actual search
|
||||||
|
*/
|
||||||
|
async performSearch(): Promise<void> {
|
||||||
|
if (!this.searchTerm.trim()) {
|
||||||
|
this.filteredEntities = [];
|
||||||
|
this.displayedCount = INITIAL_BATCH_SIZE;
|
||||||
|
this.infiniteScrollReset?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isSearching = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Simulate async search (in case we need to add API calls later)
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
|
|
||||||
|
const searchLower = this.searchTerm.toLowerCase().trim();
|
||||||
|
|
||||||
|
if (this.entityType === "people") {
|
||||||
|
this.filteredEntities = (this.entities as Contact[])
|
||||||
|
.filter((contact: Contact) => {
|
||||||
|
const name = contact.name?.toLowerCase() || "";
|
||||||
|
const did = contact.did.toLowerCase();
|
||||||
|
return name.includes(searchLower) || did.includes(searchLower);
|
||||||
|
})
|
||||||
|
.sort((a: Contact, b: Contact) => {
|
||||||
|
// Sort alphabetically by name, falling back to DID if name is missing
|
||||||
|
const nameA = (a.name || a.did).toLowerCase();
|
||||||
|
const nameB = (b.name || b.did).toLowerCase();
|
||||||
|
return nameA.localeCompare(nameB);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.filteredEntities = (this.entities as PlanData[])
|
||||||
|
.filter((project: PlanData) => {
|
||||||
|
const name = project.name?.toLowerCase() || "";
|
||||||
|
const handleId = project.handleId.toLowerCase();
|
||||||
|
return name.includes(searchLower) || handleId.includes(searchLower);
|
||||||
|
})
|
||||||
|
.sort((a: PlanData, b: PlanData) => {
|
||||||
|
// Sort alphabetically by name
|
||||||
|
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset displayed count when search completes
|
||||||
|
this.displayedCount = INITIAL_BATCH_SIZE;
|
||||||
|
this.infiniteScrollReset?.();
|
||||||
|
} finally {
|
||||||
|
this.isSearching = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the search
|
||||||
|
*/
|
||||||
|
clearSearch(): void {
|
||||||
|
this.searchTerm = "";
|
||||||
|
this.filteredEntities = [];
|
||||||
|
this.isSearching = false;
|
||||||
|
this.displayedCount = INITIAL_BATCH_SIZE;
|
||||||
|
this.infiniteScrollReset?.();
|
||||||
|
|
||||||
|
// Clear any pending timeout
|
||||||
|
if (this.searchTimeout) {
|
||||||
|
clearTimeout(this.searchTimeout);
|
||||||
|
this.searchTimeout = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if more entities can be loaded
|
||||||
|
*/
|
||||||
|
canLoadMore(): boolean {
|
||||||
|
if (this.displayEntitiesFunction) {
|
||||||
|
// Custom function disables infinite scroll
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.searchTerm.trim()) {
|
||||||
|
// Search mode: check filtered entities
|
||||||
|
return this.displayedCount < this.filteredEntities.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.entityType === "projects") {
|
||||||
|
// Projects: check if more available
|
||||||
|
return this.displayedCount < this.entities.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// People: check if more alphabetical contacts available
|
||||||
|
// Total available = 3 recent + all alphabetical
|
||||||
|
const remaining = (this.entities as Contact[]).slice(RECENT_CONTACTS_COUNT);
|
||||||
|
const totalAvailable = RECENT_CONTACTS_COUNT + remaining.length;
|
||||||
|
return this.displayedCount < totalAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize infinite scroll on mount
|
||||||
|
*/
|
||||||
|
mounted(): void {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const container = this.$refs.scrollContainer as HTMLElement;
|
||||||
|
|
||||||
|
if (container) {
|
||||||
|
const { reset } = useInfiniteScroll(
|
||||||
|
container,
|
||||||
|
() => {
|
||||||
|
// Load more: increment displayedCount
|
||||||
|
this.displayedCount += INCREMENT_SIZE;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
distance: 50, // pixels from bottom
|
||||||
|
canLoadMore: () => this.canLoadMore(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
this.infiniteScrollReset = reset;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Emit methods using @Emit decorator
|
// Emit methods using @Emit decorator
|
||||||
|
|
||||||
@Emit("entity-selected")
|
@Emit("entity-selected")
|
||||||
@@ -340,6 +573,33 @@ export default class EntityGrid extends Vue {
|
|||||||
} {
|
} {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Watch for changes in search term to reset displayed count
|
||||||
|
*/
|
||||||
|
@Watch("searchTerm")
|
||||||
|
onSearchTermChange(): void {
|
||||||
|
this.displayedCount = INITIAL_BATCH_SIZE;
|
||||||
|
this.infiniteScrollReset?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Watch for changes in entities prop to reset displayed count
|
||||||
|
*/
|
||||||
|
@Watch("entities")
|
||||||
|
onEntitiesChange(): void {
|
||||||
|
this.displayedCount = INITIAL_BATCH_SIZE;
|
||||||
|
this.infiniteScrollReset?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup timeouts when component is destroyed
|
||||||
|
*/
|
||||||
|
beforeUnmount(): void {
|
||||||
|
if (this.searchTimeout) {
|
||||||
|
clearTimeout(this.searchTimeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ from GiftedDialog.vue to handle the complete step 1 * entity selection interface
|
|||||||
with dynamic labeling and grid display. * * Features: * - Dynamic step labeling
|
with dynamic labeling and grid display. * * Features: * - Dynamic step labeling
|
||||||
based on context * - EntityGrid integration for unified entity display * -
|
based on context * - EntityGrid integration for unified entity display * -
|
||||||
Conflict detection and prevention * - Special entity handling (You, Unnamed) * -
|
Conflict detection and prevention * - Special entity handling (You, Unnamed) * -
|
||||||
Show All navigation with context preservation * - Cancel functionality * - Event
|
Cancel functionality * - Event delegation for entity selection * - Warning
|
||||||
delegation for entity selection * - Warning notifications for conflicted
|
notifications for conflicted entities * - Template streamlined with computed CSS
|
||||||
entities * - Template streamlined with computed CSS properties * * @author
|
properties * * @author Matthew Raymer */
|
||||||
Matthew Raymer */
|
|
||||||
<template>
|
<template>
|
||||||
<div id="sectionGiftedGiver">
|
<div id="sectionGiftedGiver">
|
||||||
<label class="block font-bold mb-4">
|
<label class="block font-bold mb-4">
|
||||||
@@ -16,18 +15,14 @@ Matthew Raymer */
|
|||||||
<EntityGrid
|
<EntityGrid
|
||||||
:entity-type="shouldShowProjects ? 'projects' : 'people'"
|
:entity-type="shouldShowProjects ? 'projects' : 'people'"
|
||||||
:entities="shouldShowProjects ? projects : allContacts"
|
:entities="shouldShowProjects ? projects : allContacts"
|
||||||
:max-items="10"
|
|
||||||
:active-did="activeDid"
|
:active-did="activeDid"
|
||||||
:all-my-dids="allMyDids"
|
:all-my-dids="allMyDids"
|
||||||
:all-contacts="allContacts"
|
:all-contacts="allContacts"
|
||||||
:conflict-checker="conflictChecker"
|
:conflict-checker="conflictChecker"
|
||||||
:show-you-entity="shouldShowYouEntity"
|
:show-you-entity="shouldShowYouEntity"
|
||||||
:you-selectable="youSelectable"
|
:you-selectable="youSelectable"
|
||||||
:show-all-route="showAllRoute"
|
|
||||||
:show-all-query-params="showAllQueryParams"
|
|
||||||
:notify="notify"
|
:notify="notify"
|
||||||
:conflict-context="conflictContext"
|
:conflict-context="conflictContext"
|
||||||
:hide-show-all="hideShowAll"
|
|
||||||
@entity-selected="handleEntitySelected"
|
@entity-selected="handleEntitySelected"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -68,7 +63,6 @@ interface EntitySelectionEvent {
|
|||||||
* - EntityGrid integration for unified entity display
|
* - EntityGrid integration for unified entity display
|
||||||
* - Conflict detection and prevention
|
* - Conflict detection and prevention
|
||||||
* - Special entity handling (You, Unnamed)
|
* - Special entity handling (You, Unnamed)
|
||||||
* - Show All navigation with context preservation
|
|
||||||
* - Cancel functionality
|
* - Cancel functionality
|
||||||
* - Event delegation for entity selection
|
* - Event delegation for entity selection
|
||||||
* - Warning notifications for conflicted entities
|
* - Warning notifications for conflicted entities
|
||||||
@@ -154,10 +148,6 @@ export default class EntitySelectionStep extends Vue {
|
|||||||
@Prop()
|
@Prop()
|
||||||
notify?: (notification: NotificationIface, timeout?: number) => void;
|
notify?: (notification: NotificationIface, timeout?: number) => void;
|
||||||
|
|
||||||
/** Whether to hide the "Show All" navigation */
|
|
||||||
@Prop({ default: false })
|
|
||||||
hideShowAll!: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CSS classes for the cancel button
|
* CSS classes for the cancel button
|
||||||
*/
|
*/
|
||||||
@@ -222,59 +212,6 @@ export default class EntitySelectionStep extends Vue {
|
|||||||
return !this.conflictChecker(this.activeDid);
|
return !this.conflictChecker(this.activeDid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Route name for "Show All" navigation
|
|
||||||
*/
|
|
||||||
get showAllRoute(): string {
|
|
||||||
if (this.shouldShowProjects) {
|
|
||||||
return "discover";
|
|
||||||
} else if (this.allContacts.length > 0) {
|
|
||||||
return "contact-gift";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query parameters for "Show All" navigation
|
|
||||||
*/
|
|
||||||
get showAllQueryParams(): Record<string, string> {
|
|
||||||
const baseParams = {
|
|
||||||
stepType: this.stepType,
|
|
||||||
giverEntityType: this.giverEntityType,
|
|
||||||
recipientEntityType: this.recipientEntityType,
|
|
||||||
// Form field values to preserve
|
|
||||||
description: this.description,
|
|
||||||
amountInput: this.amountInput,
|
|
||||||
unitCode: this.unitCode,
|
|
||||||
offerId: this.offerId,
|
|
||||||
fromProjectId: this.fromProjectId,
|
|
||||||
toProjectId: this.toProjectId,
|
|
||||||
showProjects: this.showProjects.toString(),
|
|
||||||
isFromProjectView: this.isFromProjectView.toString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.shouldShowProjects) {
|
|
||||||
// For project contexts, still pass entity type information
|
|
||||||
return baseParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...baseParams,
|
|
||||||
// Always pass both giver and recipient info for context preservation
|
|
||||||
giverProjectId: this.fromProjectId || "",
|
|
||||||
giverProjectName: this.giver?.name || "",
|
|
||||||
giverProjectImage: this.giver?.image || "",
|
|
||||||
giverProjectHandleId: this.giver?.handleId || "",
|
|
||||||
giverDid: this.giverEntityType === "person" ? this.giver?.did || "" : "",
|
|
||||||
recipientProjectId: this.toProjectId || "",
|
|
||||||
recipientProjectName: this.receiver?.name || "",
|
|
||||||
recipientProjectImage: this.receiver?.image || "",
|
|
||||||
recipientProjectHandleId: this.receiver?.handleId || "",
|
|
||||||
recipientDid:
|
|
||||||
this.recipientEntityType === "person" ? this.receiver?.did || "" : "",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle entity selection from EntityGrid
|
* Handle entity selection from EntityGrid
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
:unit-code="unitCode"
|
:unit-code="unitCode"
|
||||||
:offer-id="offerId"
|
:offer-id="offerId"
|
||||||
:notify="$notify"
|
:notify="$notify"
|
||||||
:hide-show-all="hideShowAll"
|
|
||||||
@entity-selected="handleEntitySelected"
|
@entity-selected="handleEntitySelected"
|
||||||
@cancel="cancel"
|
@cancel="cancel"
|
||||||
/>
|
/>
|
||||||
@@ -117,7 +116,6 @@ export default class GiftedDialog extends Vue {
|
|||||||
@Prop() fromProjectId = "";
|
@Prop() fromProjectId = "";
|
||||||
@Prop() toProjectId = "";
|
@Prop() toProjectId = "";
|
||||||
@Prop() isFromProjectView = false;
|
@Prop() isFromProjectView = false;
|
||||||
@Prop() hideShowAll = false;
|
|
||||||
@Prop({ default: "person" }) giverEntityType = "person" as
|
@Prop({ default: "person" }) giverEntityType = "person" as
|
||||||
| "person"
|
| "person"
|
||||||
| "project";
|
| "project";
|
||||||
@@ -233,7 +231,7 @@ export default class GiftedDialog extends Vue {
|
|||||||
apiServer: this.apiServer,
|
apiServer: this.apiServer,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.allContacts = await this.$contacts();
|
this.allContacts = await this.$contactsByDateAdded();
|
||||||
|
|
||||||
this.allMyDids = await retrieveAccountDids();
|
this.allMyDids = await retrieveAccountDids();
|
||||||
|
|
||||||
|
|||||||
@@ -3,30 +3,25 @@ GiftedDialog.vue to handle person entity display * with selection states and
|
|||||||
conflict detection. * * @author Matthew Raymer */
|
conflict detection. * * @author Matthew Raymer */
|
||||||
<template>
|
<template>
|
||||||
<li :class="cardClasses" @click="handleClick">
|
<li :class="cardClasses" @click="handleClick">
|
||||||
<div class="relative w-fit mx-auto">
|
<div>
|
||||||
<EntityIcon
|
<EntityIcon
|
||||||
v-if="person.did"
|
v-if="person.did"
|
||||||
:contact="person"
|
:contact="person"
|
||||||
class="!size-[3rem] mx-auto border border-slate-300 bg-white overflow-hidden rounded-full mb-1"
|
class="!size-[2rem] shrink-0 border border-slate-300 bg-white overflow-hidden rounded-full"
|
||||||
/>
|
/>
|
||||||
<font-awesome
|
<font-awesome
|
||||||
v-else
|
v-else
|
||||||
icon="circle-question"
|
icon="circle-question"
|
||||||
class="text-slate-400 text-5xl mb-1"
|
class="text-slate-400 text-5xl mb-1 shrink-0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Time icon overlay for contacts -->
|
|
||||||
<div
|
|
||||||
v-if="person.did && showTimeIcon"
|
|
||||||
class="rounded-full bg-slate-400 absolute bottom-0 right-0 p-1 translate-x-1/3"
|
|
||||||
>
|
|
||||||
<font-awesome icon="clock" class="block text-white text-xs w-[1em]" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 :class="nameClasses">
|
<div class="overflow-hidden">
|
||||||
{{ displayName }}
|
<h3 :class="nameClasses">
|
||||||
</h3>
|
{{ displayName }}
|
||||||
|
</h3>
|
||||||
|
<p class="text-xs text-slate-500 truncate">{{ person.did }}</p>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -81,29 +76,32 @@ export default class PersonCard extends Vue {
|
|||||||
* Computed CSS classes for the card
|
* Computed CSS classes for the card
|
||||||
*/
|
*/
|
||||||
get cardClasses(): string {
|
get cardClasses(): string {
|
||||||
|
const baseCardClasses =
|
||||||
|
"flex items-center gap-2 px-2 py-1.5 border-b border-slate-300";
|
||||||
|
|
||||||
if (!this.selectable || this.conflicted) {
|
if (!this.selectable || this.conflicted) {
|
||||||
return "opacity-50 cursor-not-allowed";
|
return `${baseCardClasses} *:opacity-50 cursor-not-allowed`;
|
||||||
}
|
}
|
||||||
return "cursor-pointer hover:bg-slate-50";
|
|
||||||
|
return `${baseCardClasses} cursor-pointer hover:bg-slate-50`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computed CSS classes for the person name
|
* Computed CSS classes for the person name
|
||||||
*/
|
*/
|
||||||
get nameClasses(): string {
|
get nameClasses(): string {
|
||||||
const baseClasses =
|
const baseNameClasses = "text-sm font-semibold truncate";
|
||||||
"text-xs font-medium text-ellipsis whitespace-nowrap overflow-hidden";
|
|
||||||
|
|
||||||
if (this.conflicted) {
|
if (this.conflicted) {
|
||||||
return `${baseClasses} text-slate-400`;
|
return `${baseNameClasses} text-slate-500`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add italic styling for entities without set names
|
// Add italic styling for entities without set names
|
||||||
if (!this.person.name) {
|
if (!this.person.name) {
|
||||||
return `${baseClasses} italic text-slate-500`;
|
return `${baseNameClasses} italic text-slate-500`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseClasses;
|
return baseNameClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,25 +2,26 @@
|
|||||||
GiftedDialog.vue to handle project entity display * with selection states and
|
GiftedDialog.vue to handle project entity display * with selection states and
|
||||||
issuer information. * * @author Matthew Raymer */
|
issuer information. * * @author Matthew Raymer */
|
||||||
<template>
|
<template>
|
||||||
<li class="cursor-pointer" @click="handleClick">
|
<li
|
||||||
<div class="relative w-fit mx-auto">
|
class="flex items-center gap-2 px-2 py-1.5 border-b border-slate-300 hover:bg-slate-50 cursor-pointer"
|
||||||
<ProjectIcon
|
@click="handleClick"
|
||||||
:entity-id="project.handleId"
|
>
|
||||||
:icon-size="48"
|
<ProjectIcon
|
||||||
:image-url="project.image"
|
:entity-id="project.handleId"
|
||||||
class="!size-[3rem] mx-auto border border-slate-300 bg-white overflow-hidden rounded-full mb-1"
|
:icon-size="48"
|
||||||
/>
|
:image-url="project.image"
|
||||||
</div>
|
class="!size-[2rem] shrink-0 border border-slate-300 bg-white overflow-hidden rounded-full"
|
||||||
|
/>
|
||||||
|
|
||||||
<h3
|
<div class="overflow-hidden">
|
||||||
class="text-xs font-medium text-ellipsis whitespace-nowrap overflow-hidden"
|
<h3 class="text-sm font-semibold truncate">
|
||||||
>
|
{{ project.name || unnamedProject }}
|
||||||
{{ project.name || unnamedProject }}
|
</h3>
|
||||||
</h3>
|
|
||||||
|
|
||||||
<div class="text-xs text-slate-500 truncate">
|
<div class="text-xs text-slate-500 truncate">
|
||||||
<font-awesome icon="user" class="fa-fw text-slate-400" />
|
<font-awesome icon="user" class="text-slate-400" />
|
||||||
{{ issuerDisplayName }}
|
{{ issuerDisplayName }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
/** * ShowAllCard.vue - Show All navigation card component * * Extracted from
|
|
||||||
GiftedDialog.vue to handle "Show All" navigation * for both people and projects
|
|
||||||
entity types. * * @author Matthew Raymer */
|
|
||||||
<template>
|
|
||||||
<li class="cursor-pointer">
|
|
||||||
<router-link :to="navigationRoute" class="block text-center">
|
|
||||||
<font-awesome icon="circle-right" class="text-blue-500 text-5xl mb-1" />
|
|
||||||
<h3
|
|
||||||
class="text-xs text-slate-500 font-medium italic text-ellipsis whitespace-nowrap overflow-hidden"
|
|
||||||
>
|
|
||||||
Show All
|
|
||||||
</h3>
|
|
||||||
</router-link>
|
|
||||||
</li>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { Component, Prop, Vue } from "vue-facing-decorator";
|
|
||||||
import { RouteLocationRaw } from "vue-router";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ShowAllCard - Displays "Show All" navigation for entity grids
|
|
||||||
*
|
|
||||||
* Features:
|
|
||||||
* - Provides navigation to full entity listings
|
|
||||||
* - Supports different routes based on entity type
|
|
||||||
* - Maintains context through query parameters
|
|
||||||
* - Consistent visual styling with other cards
|
|
||||||
*/
|
|
||||||
@Component({ name: "ShowAllCard" })
|
|
||||||
export default class ShowAllCard extends Vue {
|
|
||||||
/** Type of entities being shown */
|
|
||||||
@Prop({ required: true })
|
|
||||||
entityType!: "people" | "projects";
|
|
||||||
|
|
||||||
/** Route name to navigate to */
|
|
||||||
@Prop({ required: true })
|
|
||||||
routeName!: string;
|
|
||||||
|
|
||||||
/** Query parameters to pass to the route */
|
|
||||||
@Prop({ default: () => ({}) })
|
|
||||||
queryParams!: Record<string, string>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Computed navigation route with query parameters
|
|
||||||
*/
|
|
||||||
get navigationRoute(): RouteLocationRaw {
|
|
||||||
return {
|
|
||||||
name: this.routeName,
|
|
||||||
query: this.queryParams,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
/* Ensure router-link styling is consistent */
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover .fa-circle-right {
|
|
||||||
transform: scale(1.1);
|
|
||||||
transition: transform 0.2s ease;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -63,23 +63,24 @@ export default class SpecialEntityCard extends Vue {
|
|||||||
conflictContext!: string;
|
conflictContext!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computed CSS classes for the card container
|
* Computed CSS classes for the card
|
||||||
*/
|
*/
|
||||||
get cardClasses(): string {
|
get cardClasses(): string {
|
||||||
const baseClasses = "block";
|
const baseCardClasses =
|
||||||
|
"flex items-center gap-2 px-2 py-1.5 border-b border-slate-300";
|
||||||
|
|
||||||
if (!this.selectable || this.conflicted) {
|
if (!this.selectable || this.conflicted) {
|
||||||
return `${baseClasses} cursor-not-allowed opacity-50`;
|
return `${baseCardClasses} *:opacity-50 cursor-not-allowed`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${baseClasses} cursor-pointer`;
|
return `${baseCardClasses} cursor-pointer hover:bg-slate-50`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computed CSS classes for the icon
|
* Computed CSS classes for the icon
|
||||||
*/
|
*/
|
||||||
get iconClasses(): string {
|
get iconClasses(): string {
|
||||||
const baseClasses = "text-5xl mb-1";
|
const baseClasses = "text-[2rem]";
|
||||||
|
|
||||||
if (this.conflicted) {
|
if (this.conflicted) {
|
||||||
return `${baseClasses} text-slate-400`;
|
return `${baseClasses} text-slate-400`;
|
||||||
@@ -101,7 +102,7 @@ export default class SpecialEntityCard extends Vue {
|
|||||||
*/
|
*/
|
||||||
get nameClasses(): string {
|
get nameClasses(): string {
|
||||||
const baseClasses =
|
const baseClasses =
|
||||||
"text-xs font-medium text-ellipsis whitespace-nowrap overflow-hidden";
|
"text-sm font-semibold text-ellipsis whitespace-nowrap overflow-hidden";
|
||||||
|
|
||||||
if (this.conflicted) {
|
if (this.conflicted) {
|
||||||
return `${baseClasses} text-slate-400`;
|
return `${baseClasses} text-slate-400`;
|
||||||
|
|||||||
@@ -234,32 +234,20 @@ export async function runMigrations<T>(
|
|||||||
sqlQuery: (sql: string, params?: unknown[]) => Promise<T>,
|
sqlQuery: (sql: string, params?: unknown[]) => Promise<T>,
|
||||||
extractMigrationNames: (result: T) => Set<string>,
|
extractMigrationNames: (result: T) => Set<string>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// Only log migration start in development
|
logger.debug("[Migration] Starting database migrations");
|
||||||
const isDevelopment = process.env.VITE_PLATFORM === "development";
|
|
||||||
if (isDevelopment) {
|
|
||||||
logger.debug("[Migration] Starting database migrations");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const migration of MIGRATIONS) {
|
for (const migration of MIGRATIONS) {
|
||||||
if (isDevelopment) {
|
logger.debug("[Migration] Registering migration:", migration.name);
|
||||||
logger.debug("[Migration] Registering migration:", migration.name);
|
|
||||||
}
|
|
||||||
registerMigration(migration);
|
registerMigration(migration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDevelopment) {
|
logger.debug("[Migration] Running migration service");
|
||||||
logger.debug("[Migration] Running migration service");
|
|
||||||
}
|
|
||||||
await runMigrationsService(sqlExec, sqlQuery, extractMigrationNames);
|
await runMigrationsService(sqlExec, sqlQuery, extractMigrationNames);
|
||||||
|
|
||||||
if (isDevelopment) {
|
logger.debug("[Migration] Database migrations completed");
|
||||||
logger.debug("[Migration] Database migrations completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bootstrapping: Ensure active account is selected after migrations
|
// Bootstrapping: Ensure active account is selected after migrations
|
||||||
if (isDevelopment) {
|
logger.debug("[Migration] Running bootstrapping hooks");
|
||||||
logger.debug("[Migration] Running bootstrapping hooks");
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// Check if we have accounts but no active selection
|
// Check if we have accounts but no active selection
|
||||||
const accountsResult = await sqlQuery("SELECT COUNT(*) FROM accounts");
|
const accountsResult = await sqlQuery("SELECT COUNT(*) FROM accounts");
|
||||||
@@ -274,18 +262,14 @@ export async function runMigrations<T>(
|
|||||||
activeDid = (extractSingleValue(activeResult) as string) || null;
|
activeDid = (extractSingleValue(activeResult) as string) || null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Table doesn't exist - migration 004 may not have run yet
|
// Table doesn't exist - migration 004 may not have run yet
|
||||||
if (isDevelopment) {
|
logger.debug(
|
||||||
logger.debug(
|
"[Migration] active_identity table not found - migration may not have run",
|
||||||
"[Migration] active_identity table not found - migration may not have run",
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
activeDid = null;
|
activeDid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accountsCount > 0 && (!activeDid || activeDid === "")) {
|
if (accountsCount > 0 && (!activeDid || activeDid === "")) {
|
||||||
if (isDevelopment) {
|
logger.debug("[Migration] Auto-selecting first account as active");
|
||||||
logger.debug("[Migration] Auto-selecting first account as active");
|
|
||||||
}
|
|
||||||
const firstAccountResult = await sqlQuery(
|
const firstAccountResult = await sqlQuery(
|
||||||
"SELECT did FROM accounts ORDER BY dateCreated, did LIMIT 1",
|
"SELECT did FROM accounts ORDER BY dateCreated, did LIMIT 1",
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ export interface AgreeActionClaim extends ClaimObject {
|
|||||||
object: Record<string, unknown>;
|
object: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface EmojiClaim extends ClaimObject {
|
||||||
|
// default context is "https://endorser.ch"
|
||||||
|
"@type": "Emoji";
|
||||||
|
text: string;
|
||||||
|
parentItem: { lastClaimId: string };
|
||||||
|
}
|
||||||
|
|
||||||
// Note that previous VCs may have additional fields.
|
// Note that previous VCs may have additional fields.
|
||||||
// https://endorser.ch/doc/html/transactions.html#id4
|
// https://endorser.ch/doc/html/transactions.html#id4
|
||||||
export interface GiveActionClaim extends ClaimObject {
|
export interface GiveActionClaim extends ClaimObject {
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ export interface UserInfo {
|
|||||||
|
|
||||||
export interface CreateAndSubmitClaimResult {
|
export interface CreateAndSubmitClaimResult {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
|
embeddedRecordError?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
claimId?: string;
|
||||||
handleId?: string;
|
handleId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,6 @@
|
|||||||
export type {
|
export * from "./claims";
|
||||||
// From common.ts
|
|
||||||
CreateAndSubmitClaimResult,
|
|
||||||
GenericCredWrapper,
|
|
||||||
GenericVerifiableCredential,
|
|
||||||
KeyMeta,
|
|
||||||
// Exclude types that are also exported from other files
|
|
||||||
// GiveVerifiableCredential,
|
|
||||||
// OfferVerifiableCredential,
|
|
||||||
// RegisterVerifiableCredential,
|
|
||||||
// PlanSummaryRecord,
|
|
||||||
// UserInfo,
|
|
||||||
} from "./common";
|
|
||||||
|
|
||||||
export type {
|
|
||||||
// From claims.ts
|
|
||||||
GiveActionClaim,
|
|
||||||
OfferClaim,
|
|
||||||
RegisterActionClaim,
|
|
||||||
} from "./claims";
|
|
||||||
|
|
||||||
export type {
|
|
||||||
// From records.ts
|
|
||||||
PlanSummaryRecord,
|
|
||||||
} from "./records";
|
|
||||||
|
|
||||||
export type {
|
|
||||||
// From user.ts
|
|
||||||
UserInfo,
|
|
||||||
} from "./user";
|
|
||||||
|
|
||||||
export * from "./limits";
|
|
||||||
export * from "./deepLinks";
|
|
||||||
export * from "./common";
|
|
||||||
export * from "./claims-result";
|
export * from "./claims-result";
|
||||||
|
export * from "./common";
|
||||||
|
export * from "./deepLinks";
|
||||||
|
export * from "./limits";
|
||||||
export * from "./records";
|
export * from "./records";
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
import { GiveActionClaim, OfferClaim, PlanActionClaim } from "./claims";
|
import { GiveActionClaim, OfferClaim, PlanActionClaim } from "./claims";
|
||||||
import { GenericCredWrapper } from "./common";
|
import { GenericCredWrapper } from "./common";
|
||||||
|
|
||||||
|
export interface EmojiSummaryRecord {
|
||||||
|
issuerDid: string;
|
||||||
|
jwtId: string;
|
||||||
|
text: string;
|
||||||
|
parentHandleId: string;
|
||||||
|
}
|
||||||
|
|
||||||
// a summary record; the VC is found the fullClaim field
|
// a summary record; the VC is found the fullClaim field
|
||||||
export interface GiveSummaryRecord {
|
export interface GiveSummaryRecord {
|
||||||
[x: string]: PropertyKey | undefined | GiveActionClaim;
|
[x: string]:
|
||||||
|
| PropertyKey
|
||||||
|
| undefined
|
||||||
|
| GiveActionClaim
|
||||||
|
| Record<string, number>;
|
||||||
type?: string;
|
type?: string;
|
||||||
agentDid: string;
|
agentDid: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
amountConfirmed: number;
|
amountConfirmed: number;
|
||||||
description: string;
|
description: string;
|
||||||
|
emojiCount: Record<string, number>; // Map of emoji character to count
|
||||||
fullClaim: GiveActionClaim;
|
fullClaim: GiveActionClaim;
|
||||||
fulfillsHandleId: string;
|
fulfillsHandleId: string;
|
||||||
fulfillsPlanHandleId?: string;
|
fulfillsPlanHandleId?: string;
|
||||||
|
|||||||
@@ -630,11 +630,7 @@ async function performPlanRequest(
|
|||||||
|
|
||||||
return cred;
|
return cred;
|
||||||
} else {
|
} else {
|
||||||
// Use debug level for development to reduce console noise
|
logger.debug(
|
||||||
const isDevelopment = process.env.VITE_PLATFORM === "development";
|
|
||||||
const log = isDevelopment ? logger.debug : logger.log;
|
|
||||||
|
|
||||||
log(
|
|
||||||
"[Plan Loading] ⚠️ Plan cache is empty for handle",
|
"[Plan Loading] ⚠️ Plan cache is empty for handle",
|
||||||
handleId,
|
handleId,
|
||||||
" Got data:",
|
" Got data:",
|
||||||
@@ -1226,7 +1222,12 @@ export async function createAndSubmitClaim(
|
|||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
return { success: true, handleId: response.data?.handleId };
|
return {
|
||||||
|
success: true,
|
||||||
|
claimId: response.data?.claimId,
|
||||||
|
handleId: response.data?.handleId,
|
||||||
|
embeddedRecordError: response.data?.embeddedRecordError,
|
||||||
|
};
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
// Enhanced error logging with comprehensive context
|
// Enhanced error logging with comprehensive context
|
||||||
const requestId = `claim_error_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
const requestId = `claim_error_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
||||||
|
|||||||
@@ -1147,3 +1147,29 @@ export async function checkForDuplicateAccount(
|
|||||||
|
|
||||||
return (existingAccount?.values?.length ?? 0) > 0;
|
return (existingAccount?.values?.length ?? 0) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class PromiseTracker<T> {
|
||||||
|
private _promise: Promise<T>;
|
||||||
|
private _resolved = false;
|
||||||
|
private _value: T | undefined;
|
||||||
|
|
||||||
|
constructor(promise: Promise<T>) {
|
||||||
|
this._promise = promise.then((value) => {
|
||||||
|
this._resolved = true;
|
||||||
|
this._value = value;
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get isResolved(): boolean {
|
||||||
|
return this._resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
get value(): T | undefined {
|
||||||
|
return this._value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get promise(): Promise<T> {
|
||||||
|
return this._promise;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,15 +48,13 @@ export class WebPlatformService implements PlatformService {
|
|||||||
constructor() {
|
constructor() {
|
||||||
WebPlatformService.instanceCount++;
|
WebPlatformService.instanceCount++;
|
||||||
|
|
||||||
// Use debug level logging for development mode to reduce console noise
|
logger.debug("[WebPlatformService] Initializing web platform service");
|
||||||
const isDevelopment = process.env.VITE_PLATFORM === "development";
|
|
||||||
const log = isDevelopment ? logger.debug : logger.log;
|
|
||||||
|
|
||||||
log("[WebPlatformService] Initializing web platform service");
|
|
||||||
|
|
||||||
// Only initialize SharedArrayBuffer setup for web platforms
|
// Only initialize SharedArrayBuffer setup for web platforms
|
||||||
if (this.isWorker()) {
|
if (this.isWorker()) {
|
||||||
log("[WebPlatformService] Skipping initBackend call in worker context");
|
logger.debug(
|
||||||
|
"[WebPlatformService] Skipping initBackend call in worker context",
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
<EntityGrid
|
<EntityGrid
|
||||||
entity-type="people"
|
entity-type="people"
|
||||||
:entities="people"
|
:entities="people"
|
||||||
:max-items="5"
|
|
||||||
:active-did="activeDid"
|
:active-did="activeDid"
|
||||||
:all-my-dids="allMyDids"
|
:all-my-dids="allMyDids"
|
||||||
:all-contacts="people"
|
:all-contacts="people"
|
||||||
@@ -39,7 +38,6 @@
|
|||||||
<EntityGrid
|
<EntityGrid
|
||||||
entity-type="projects"
|
entity-type="projects"
|
||||||
:entities="projects"
|
:entities="projects"
|
||||||
:max-items="3"
|
|
||||||
:active-did="activeDid"
|
:active-did="activeDid"
|
||||||
:all-my-dids="allMyDids"
|
:all-my-dids="allMyDids"
|
||||||
:all-contacts="people"
|
:all-contacts="people"
|
||||||
@@ -152,11 +150,8 @@ export default class EntityGridFunctionPropTest extends Vue {
|
|||||||
customPeopleFunction = (
|
customPeopleFunction = (
|
||||||
entities: Contact[],
|
entities: Contact[],
|
||||||
_entityType: string,
|
_entityType: string,
|
||||||
maxItems: number,
|
|
||||||
): Contact[] => {
|
): Contact[] => {
|
||||||
return entities
|
return entities.filter((person) => person.profileImageUrl);
|
||||||
.filter((person) => person.profileImageUrl)
|
|
||||||
.slice(0, maxItems);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,7 +160,6 @@ export default class EntityGridFunctionPropTest extends Vue {
|
|||||||
customProjectsFunction = (
|
customProjectsFunction = (
|
||||||
entities: PlanData[],
|
entities: PlanData[],
|
||||||
_entityType: string,
|
_entityType: string,
|
||||||
_maxItems: number,
|
|
||||||
): PlanData[] => {
|
): PlanData[] => {
|
||||||
return entities.sort((a, b) => a.name.localeCompare(b.name)).slice(0, 3);
|
return entities.sort((a, b) => a.name.localeCompare(b.name)).slice(0, 3);
|
||||||
};
|
};
|
||||||
@@ -200,16 +194,16 @@ export default class EntityGridFunctionPropTest extends Vue {
|
|||||||
*/
|
*/
|
||||||
get displayedPeopleCount(): number {
|
get displayedPeopleCount(): number {
|
||||||
if (this.useCustomFunction) {
|
if (this.useCustomFunction) {
|
||||||
return this.customPeopleFunction(this.people, "people", 5).length;
|
return this.customPeopleFunction(this.people, "people").length;
|
||||||
}
|
}
|
||||||
return Math.min(5, this.people.length);
|
return Math.min(10, this.people.length); // Initial batch size for infinite scroll
|
||||||
}
|
}
|
||||||
|
|
||||||
get displayedProjectsCount(): number {
|
get displayedProjectsCount(): number {
|
||||||
if (this.useCustomFunction) {
|
if (this.useCustomFunction) {
|
||||||
return this.customProjectsFunction(this.projects, "projects", 3).length;
|
return this.customProjectsFunction(this.projects, "projects").length;
|
||||||
}
|
}
|
||||||
return Math.min(7, this.projects.length);
|
return Math.min(10, this.projects.length); // Initial batch size for infinite scroll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -970,6 +970,20 @@ export const PlatformServiceMixin = {
|
|||||||
return this.$normalizeContacts(rawContacts);
|
return this.$normalizeContacts(rawContacts);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load all contacts sorted by when they were added (by ID)
|
||||||
|
* Always fetches fresh data from database for consistency
|
||||||
|
* Handles JSON string/object duality for contactMethods field
|
||||||
|
* @returns Promise<Contact[]> Array of normalized contact objects sorted by addition date (newest first)
|
||||||
|
*/
|
||||||
|
async $contactsByDateAdded(): Promise<Contact[]> {
|
||||||
|
const rawContacts = (await this.$query(
|
||||||
|
"SELECT * FROM contacts ORDER BY id DESC",
|
||||||
|
)) as ContactMaybeWithJsonStrings[];
|
||||||
|
|
||||||
|
return this.$normalizeContacts(rawContacts);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ultra-concise shortcut for getting number of contacts
|
* Ultra-concise shortcut for getting number of contacts
|
||||||
* @returns Promise<number> Total number of contacts
|
* @returns Promise<number> Total number of contacts
|
||||||
@@ -2057,6 +2071,7 @@ declare module "@vue/runtime-core" {
|
|||||||
|
|
||||||
// Specialized shortcuts - contacts cached, settings fresh
|
// Specialized shortcuts - contacts cached, settings fresh
|
||||||
$contacts(): Promise<Contact[]>;
|
$contacts(): Promise<Contact[]>;
|
||||||
|
$contactsByDateAdded(): Promise<Contact[]>;
|
||||||
$contactCount(): Promise<number>;
|
$contactCount(): Promise<number>;
|
||||||
$settings(defaults?: Settings): Promise<Settings>;
|
$settings(defaults?: Settings): Promise<Settings>;
|
||||||
$accountSettings(did?: string, defaults?: Settings): Promise<Settings>;
|
$accountSettings(did?: string, defaults?: Settings): Promise<Settings>;
|
||||||
|
|||||||
@@ -91,12 +91,15 @@
|
|||||||
<div class="text-sm overflow-hidden">
|
<div class="text-sm overflow-hidden">
|
||||||
<div
|
<div
|
||||||
data-testId="description"
|
data-testId="description"
|
||||||
class="overflow-hidden text-ellipsis"
|
class="flex items-start gap-2 overflow-hidden"
|
||||||
>
|
>
|
||||||
<font-awesome icon="message" class="fa-fw text-slate-400" />
|
<font-awesome
|
||||||
|
icon="message"
|
||||||
|
class="fa-fw text-slate-400 flex-shrink-0 mt-1"
|
||||||
|
/>
|
||||||
<vue-markdown
|
<vue-markdown
|
||||||
:source="claimDescription"
|
:source="claimDescription"
|
||||||
class="markdown-content"
|
class="markdown-content flex-1 min-w-0"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-hidden text-ellipsis">
|
<div class="overflow-hidden text-ellipsis">
|
||||||
@@ -551,7 +554,7 @@ import VueMarkdown from "vue-markdown-render";
|
|||||||
import { Router, RouteLocationNormalizedLoaded } from "vue-router";
|
import { Router, RouteLocationNormalizedLoaded } from "vue-router";
|
||||||
import { copyToClipboard } from "../services/ClipboardService";
|
import { copyToClipboard } from "../services/ClipboardService";
|
||||||
|
|
||||||
import { GenericVerifiableCredential } from "../interfaces";
|
import { EmojiClaim, GenericVerifiableCredential } from "../interfaces";
|
||||||
import GiftedDialog from "../components/GiftedDialog.vue";
|
import GiftedDialog from "../components/GiftedDialog.vue";
|
||||||
import QuickNav from "../components/QuickNav.vue";
|
import QuickNav from "../components/QuickNav.vue";
|
||||||
import { NotificationIface } from "../constants/app";
|
import { NotificationIface } from "../constants/app";
|
||||||
@@ -667,6 +670,10 @@ export default class ClaimView extends Vue {
|
|||||||
return giveClaim.description || "";
|
return giveClaim.description || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.veriClaim.claimType === "Emoji") {
|
||||||
|
return (claim as EmojiClaim).text || "";
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback for other claim types
|
// Fallback for other claim types
|
||||||
return (claim as { description?: string })?.description || "";
|
return (claim as { description?: string })?.description || "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ Raymer * @version 1.0.0 */
|
|||||||
:last-viewed-claim-id="feedLastViewedClaimId"
|
:last-viewed-claim-id="feedLastViewedClaimId"
|
||||||
:is-registered="isRegistered"
|
:is-registered="isRegistered"
|
||||||
:active-did="activeDid"
|
:active-did="activeDid"
|
||||||
|
:api-server="apiServer"
|
||||||
@load-claim="onClickLoadClaim"
|
@load-claim="onClickLoadClaim"
|
||||||
@view-image="openImageViewer"
|
@view-image="openImageViewer"
|
||||||
/>
|
/>
|
||||||
@@ -1264,6 +1265,7 @@ export default class HomeView extends Vue {
|
|||||||
provider,
|
provider,
|
||||||
fulfillsPlan,
|
fulfillsPlan,
|
||||||
providedByPlan,
|
providedByPlan,
|
||||||
|
record.emojiCount,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1487,12 +1489,14 @@ export default class HomeView extends Vue {
|
|||||||
provider: Provider | undefined,
|
provider: Provider | undefined,
|
||||||
fulfillsPlan?: FulfillsPlan,
|
fulfillsPlan?: FulfillsPlan,
|
||||||
providedByPlan?: ProvidedByPlan,
|
providedByPlan?: ProvidedByPlan,
|
||||||
|
emojiCount?: Record<string, number>,
|
||||||
): GiveRecordWithContactInfo {
|
): GiveRecordWithContactInfo {
|
||||||
return {
|
return {
|
||||||
...record,
|
...record,
|
||||||
jwtId: record.jwtId,
|
jwtId: record.jwtId,
|
||||||
fullClaim: record.fullClaim,
|
fullClaim: record.fullClaim,
|
||||||
description: record.description || "",
|
description: record.description || "",
|
||||||
|
emojiCount: emojiCount || {},
|
||||||
handleId: record.handleId,
|
handleId: record.handleId,
|
||||||
issuerDid: record.issuerDid,
|
issuerDid: record.issuerDid,
|
||||||
fulfillsPlanHandleId: record.fulfillsPlanHandleId,
|
fulfillsPlanHandleId: record.fulfillsPlanHandleId,
|
||||||
|
|||||||
Reference in New Issue
Block a user