add choice of a start date for a project
This commit is contained in:
@@ -82,12 +82,7 @@ import { useClipboard } from "@vueuse/core";
|
||||
import { NotificationIface } from "@/constants/app";
|
||||
import { accountsDB, db } from "@/db/index";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
import {
|
||||
deriveAddress,
|
||||
getContactPayloadFromJwtUrl,
|
||||
nextDerivationPath,
|
||||
SimpleSigner,
|
||||
} from "@/libs/crypto";
|
||||
import { deriveAddress, nextDerivationPath, SimpleSigner } from "@/libs/crypto";
|
||||
import QuickNav from "@/components/QuickNav.vue";
|
||||
import { Account } from "@/db/tables/accounts";
|
||||
import {
|
||||
@@ -187,7 +182,6 @@ export default class ContactQRScanShow extends Vue {
|
||||
const url = content[0]?.rawValue;
|
||||
if (url) {
|
||||
try {
|
||||
const fullData = getContactPayloadFromJwtUrl(url);
|
||||
localStorage.setItem("contactEndorserUrl", url);
|
||||
this.$router.push({ name: "contacts" });
|
||||
} catch (e) {
|
||||
|
||||
@@ -64,6 +64,23 @@
|
||||
class="block w-full rounded border border-slate-400 mb-4 px-3 py-2"
|
||||
/>
|
||||
|
||||
<div class="flex mb-4 columns-3 w-full">
|
||||
<input
|
||||
v-model="startDateInput"
|
||||
placeholder="Start Date"
|
||||
type="date"
|
||||
class="col-span-1 w-full rounded border border-slate-400 px-3 py-2"
|
||||
/>
|
||||
<input
|
||||
:disabled="!startDateInput"
|
||||
v-model="startTimeInput"
|
||||
placeholder="Start Time"
|
||||
type="time"
|
||||
class="col-span-1 w-full rounded border border-slate-400 ml-2 px-3 py-2"
|
||||
/>
|
||||
<span class="col-span-1 w-full flex justify-center">{{ zoneName }}</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center mb-4">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -137,6 +154,7 @@
|
||||
import "leaflet/dist/leaflet.css";
|
||||
import { AxiosError } from "axios";
|
||||
import * as didJwt from "did-jwt";
|
||||
import { DateTime } from "luxon";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet";
|
||||
|
||||
@@ -174,6 +192,9 @@ export default class NewEditProjectView extends Vue {
|
||||
numAccounts = 0;
|
||||
projectId = localStorage.getItem("projectId") || "";
|
||||
projectIssuerDid = "";
|
||||
startDateInput?: string;
|
||||
startTimeInput?: string;
|
||||
zoneName = DateTime.local().zoneName;
|
||||
zoom = 2;
|
||||
|
||||
async beforeCreate() {
|
||||
@@ -252,6 +273,13 @@ export default class NewEditProjectView extends Vue {
|
||||
if (this.fullClaim?.agent?.identifier) {
|
||||
this.agentDid = this.fullClaim.agent.identifier;
|
||||
}
|
||||
if (this.fullClaim.startTime) {
|
||||
const localDateTime = DateTime.fromISO(
|
||||
this.fullClaim.startTime as string,
|
||||
).toLocal();
|
||||
this.startDateInput = localDateTime.toFormat("yyyy-MM-dd");
|
||||
this.startTimeInput = localDateTime.toFormat("HH:mm");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Got error retrieving that project", error);
|
||||
@@ -282,6 +310,28 @@ export default class NewEditProjectView extends Vue {
|
||||
} else {
|
||||
delete vcClaim.location;
|
||||
}
|
||||
if (this.startDateInput) {
|
||||
try {
|
||||
const startTimeFull = this.startTimeInput || "00:00:00";
|
||||
const fullTimeString = this.startDateInput + " " + startTimeFull;
|
||||
// throw an error on an invalid date or time string
|
||||
vcClaim.startTime = new Date(fullTimeString).toISOString(); // ensure timezone is part of it
|
||||
} catch {
|
||||
// it's not a valid date so erase it and tell the user
|
||||
delete vcClaim.startTime;
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "The date was invalid so it was not set.",
|
||||
},
|
||||
5000,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
delete vcClaim.startTime;
|
||||
}
|
||||
// Make a payload for the claim
|
||||
const vcPayload = {
|
||||
vc: {
|
||||
|
||||
@@ -53,9 +53,9 @@
|
||||
<span v-show="showDidCopy">Copied DID</span>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="timeSince">
|
||||
<div v-if="startTime">
|
||||
<fa icon="calendar" class="fa-fw text-slate-400"></fa>
|
||||
{{ timeSince }}
|
||||
{{ startTime }}
|
||||
</div>
|
||||
<div v-if="latitude || longitude">
|
||||
<fa icon="location-dot" class="fa-fw text-slate-400"></fa>
|
||||
@@ -339,7 +339,6 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { AxiosError, RawAxiosRequestHeaders } from "axios";
|
||||
import * as moment from "moment";
|
||||
import { IIdentifier } from "@veramo/core";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
|
||||
@@ -396,7 +395,7 @@ export default class ProjectViewView extends Vue {
|
||||
offersToThis: Array<OfferSummaryRecord> = [];
|
||||
projectId = localStorage.getItem("projectId") || ""; // handle ID
|
||||
showDidCopy = false;
|
||||
timeSince = "";
|
||||
startTime = "";
|
||||
truncatedDesc = "";
|
||||
truncateLength = 40;
|
||||
url = "";
|
||||
@@ -468,11 +467,13 @@ export default class ProjectViewView extends Vue {
|
||||
try {
|
||||
const resp = await this.axios.get(url, { headers });
|
||||
if (resp.status === 200) {
|
||||
const startTime = resp.data.startTime;
|
||||
const startTime = resp.data.claim?.startTime;
|
||||
if (startTime != null) {
|
||||
const eventDate = new Date(startTime);
|
||||
const now = moment.now();
|
||||
this.timeSince = moment.utc(now).to(eventDate);
|
||||
const startDateTime = new Date(startTime);
|
||||
this.startTime =
|
||||
startDateTime.toLocaleDateString() +
|
||||
" " +
|
||||
startDateTime.toLocaleTimeString();
|
||||
}
|
||||
this.agentDid = resp.data.claim?.agent?.identifier;
|
||||
this.issuer = resp.data.issuer;
|
||||
|
||||
Reference in New Issue
Block a user