Browse Source

Merge pull request 'allow edit of a contact's name' (#73) from contact-edit into master

Reviewed-on: https://gitea.anomalistdesign.com/trent_larson/crowd-funder-for-time-pwa/pulls/73
pull/77/head
trentlarson 1 year ago
parent
commit
679d1a70e8
  1. 1
      project.task.yaml
  2. 2
      src/main.ts
  3. 70
      src/views/ContactsView.vue

1
project.task.yaml

@ -31,7 +31,6 @@ tasks:
- .1 Remove notification alert visuals on home page - .1 Remove notification alert visuals on home page
- .5 Add infinite scroll to gifts on the home page - .5 Add infinite scroll to gifts on the home page
- .5 Allow edit of a contact name (but not the DID)
- .5 bug - search for "Safari" does not find the project, but if already on the "Anywhere" tab it shows all - .5 bug - search for "Safari" does not find the project, but if already on the "Anywhere" tab it shows all
- .2 figure out why endorser-mobile search doesn't find recently created PlanAction - .2 figure out why endorser-mobile search doesn't find recently created PlanAction
- .1 when creating a plan, select location and then make sure you can deselect on Android - .1 when creating a plan, select location and then make sure you can deselect on Android

2
src/main.ts

@ -13,6 +13,7 @@ import { library } from "@fortawesome/fontawesome-svg-core";
import { import {
faArrowLeft, faArrowLeft,
faArrowRight, faArrowRight,
faBan,
faBurst, faBurst,
faCalendar, faCalendar,
faChevronLeft, faChevronLeft,
@ -59,6 +60,7 @@ import {
library.add( library.add(
faArrowLeft, faArrowLeft,
faArrowRight, faArrowRight,
faBan,
faBurst, faBurst,
faCalendar, faCalendar,
faChevronLeft, faChevronLeft,

70
src/views/ContactsView.vue

@ -93,6 +93,16 @@
class="inline-block align-text-bottom border border-slate-300 rounded" class="inline-block align-text-bottom border border-slate-300 rounded"
></EntityIcon> ></EntityIcon>
{{ contact.name || "(no name)" }} {{ contact.name || "(no name)" }}
<button
class="text-sm uppercase bg-slate-500 text-white px-1 rounded-md"
@click="
contactEdit = contact;
contactNewName = contact.name;
"
title="Edit"
>
<fa icon="pen" class="fa-fw" />
</button>
</h2> </h2>
<div class="text-sm truncate">{{ contact.did }}</div> <div class="text-sm truncate">{{ contact.did }}</div>
<div class="text-sm truncate" v-if="contact.publicKeyBase64"> <div class="text-sm truncate" v-if="contact.publicKeyBase64">
@ -209,6 +219,31 @@
</li> </li>
</ul> </ul>
<p v-else>This identity has no contacts.</p> <p v-else>This identity has no contacts.</p>
<div v-if="contactEdit !== null" class="dialog-overlay">
<div class="dialog">
<h1 class="text-xl font-bold text-center mb-4">Edit Name</h1>
<input
type="text"
class="block w-full rounded border border-slate-400 mb-2 px-3 py-2"
placeholder="Name"
v-model="contactNewName"
/>
<button
class="text-sm bg-blue-600 text-white px-2 py-1.5 rounded -ml-1.5 border-l border-blue-400"
@click="onClickSaveName(contactEdit, contactNewName)"
>
<fa icon="save" />
</button>
<span class="inline-block w-2" />
<button
class="text-sm bg-blue-600 text-white px-2 py-1.5 rounded -ml-1.5 border-l border-blue-400"
@click="onClickCancelName()"
>
<fa icon="ban" />
</button>
</div>
</div>
</section> </section>
</template> </template>
@ -251,6 +286,8 @@ export default class ContactsView extends Vue {
contacts: Array<Contact> = []; contacts: Array<Contact> = [];
contactEndorserUrl = localStorage.getItem("contactEndorserUrl") || ""; contactEndorserUrl = localStorage.getItem("contactEndorserUrl") || "";
contactInput = ""; contactInput = "";
contactEdit: Contact | null = null;
contactNewName = "";
// { "did:...": concatenated-descriptions } entry for each contact // { "did:...": concatenated-descriptions } entry for each contact
givenByMeDescriptions: Record<string, string> = {}; givenByMeDescriptions: Record<string, string> = {};
// { "did:...": amount } entry for each contact // { "did:...": amount } entry for each contact
@ -961,6 +998,18 @@ export default class ContactsView extends Vue {
} }
} }
private async onClickCancelName() {
this.contactEdit = null;
this.contactNewName = "";
}
private async onClickSaveName(contact: Contact, newName: string) {
contact.name = newName;
return db.contacts
.update(contact.did, { name: newName })
.then(() => (this.contactEdit = null));
}
public toggleShowGiveTotals() { public toggleShowGiveTotals() {
if (this.showGiveTotals) { if (this.showGiveTotals) {
this.showGiveTotals = false; this.showGiveTotals = false;
@ -985,6 +1034,26 @@ export default class ContactsView extends Vue {
</script> </script>
<style> <style>
.dialog-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
padding: 1.5rem;
}
.dialog {
background-color: white;
padding: 1rem;
border-radius: 0.5rem;
width: 100%;
max-width: 500px;
}
/* Tooltip from https://www.w3schools.com/css/css_tooltip.asp */ /* Tooltip from https://www.w3schools.com/css/css_tooltip.asp */
/* Tooltip container */ /* Tooltip container */
.tooltip { .tooltip {
@ -992,7 +1061,6 @@ export default class ContactsView extends Vue {
display: inline-block; display: inline-block;
border-bottom: 1px dotted black; /* If you want dots under the hoverable text */ border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
} }
/* Tooltip text */ /* Tooltip text */
.tooltip .tooltiptext { .tooltip .tooltiptext {
visibility: hidden; visibility: hidden;

Loading…
Cancel
Save