Resolving place in edit form.
This commit is contained in:
parent
f8aa903817
commit
2c49e0f9fe
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit 3bf8ce6e23a1c6c4c909b1a56b201903bad5b26e
|
Subproject commit 1122b4198f2c5bc27f9f4e3f3aedea6c81f09ba1
|
|
@ -230,6 +230,10 @@ const timeline = computed(() => {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
content: '';
|
content: '';
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -54,6 +54,7 @@
|
||||||
"redis": "^4.6.12",
|
"redis": "^4.6.12",
|
||||||
"sharp": "^0.32.6",
|
"sharp": "^0.32.6",
|
||||||
"sirv": "^2.0.3",
|
"sirv": "^2.0.3",
|
||||||
|
"unprint": "^0.14.1",
|
||||||
"video.js": "^8.10.0",
|
"video.js": "^8.10.0",
|
||||||
"vike": "^0.4.150",
|
"vike": "^0.4.150",
|
||||||
"vite": "^4.5.1",
|
"vite": "^4.5.1",
|
||||||
|
|
|
@ -706,8 +706,11 @@
|
||||||
@change="(checked) => apply = checked"
|
@change="(checked) => apply = checked"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Ellipsis v-if="submitting" />
|
||||||
|
|
||||||
<!-- we don't want the return key to submit the form -->
|
<!-- we don't want the return key to submit the form -->
|
||||||
<button
|
<button
|
||||||
|
v-else
|
||||||
class="button button-primary"
|
class="button button-primary"
|
||||||
type="button"
|
type="button"
|
||||||
:disabled="editing.size === 0"
|
:disabled="editing.size === 0"
|
||||||
|
@ -728,6 +731,7 @@ import { format } from 'date-fns';
|
||||||
|
|
||||||
import Avatar from '#/components/edit/avatar.vue';
|
import Avatar from '#/components/edit/avatar.vue';
|
||||||
import Checkbox from '#/components/form/checkbox.vue';
|
import Checkbox from '#/components/form/checkbox.vue';
|
||||||
|
import Ellipsis from '#/components/loading/ellipsis.vue';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
// get,
|
// get,
|
||||||
|
@ -965,6 +969,7 @@ const editing = ref(new Set());
|
||||||
const edits = ref(Object.fromEntries(fields.value.map((field) => [field.key, field.value])));
|
const edits = ref(Object.fromEntries(fields.value.map((field) => [field.key, field.value])));
|
||||||
const comment = ref(null);
|
const comment = ref(null);
|
||||||
const apply = ref(user.role !== 'user');
|
const apply = ref(user.role !== 'user');
|
||||||
|
const submitting = ref(false);
|
||||||
const submitted = ref(false);
|
const submitted = ref(false);
|
||||||
|
|
||||||
const sizeUnits = ref('metric');
|
const sizeUnits = ref('metric');
|
||||||
|
@ -1006,6 +1011,8 @@ const groupMap = {
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
try {
|
try {
|
||||||
|
submitting.value = true;
|
||||||
|
|
||||||
await post('/revisions/actors', {
|
await post('/revisions/actors', {
|
||||||
actorId: actor.value.id,
|
actorId: actor.value.id,
|
||||||
edits: {
|
edits: {
|
||||||
|
@ -1041,6 +1048,7 @@ async function submit() {
|
||||||
appendErrorMessage: true,
|
appendErrorMessage: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
submitting.value = false;
|
||||||
editing.value = new Set();
|
editing.value = new Set();
|
||||||
edits.value = {};
|
edits.value = {};
|
||||||
comment.value = null;
|
comment.value = null;
|
||||||
|
|
|
@ -5,9 +5,11 @@ import { MerkleJson } from 'merkle-json';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import omit from 'object.omit';
|
import omit from 'object.omit';
|
||||||
import convert from 'convert';
|
import convert from 'convert';
|
||||||
|
import unprint from 'unprint';
|
||||||
|
|
||||||
import initLogger from './logger.js';
|
import initLogger from './logger.js';
|
||||||
import { knexOwner as knex, knexManticore } from './knex.js';
|
import { knexOwner as knex, knexManticore } from './knex.js';
|
||||||
|
import redis from './redis.js';
|
||||||
import { utilsApi } from './manticore.js';
|
import { utilsApi } from './manticore.js';
|
||||||
import { HttpError } from './errors.js';
|
import { HttpError } from './errors.js';
|
||||||
import { fetchCountriesByAlpha2 } from './countries.js';
|
import { fetchCountriesByAlpha2 } from './countries.js';
|
||||||
|
@ -18,6 +20,7 @@ import escape from '../utils/escape-manticore.js';
|
||||||
import slugify from '../utils/slugify.js';
|
import slugify from '../utils/slugify.js';
|
||||||
import { curateRevision } from './revisions.js';
|
import { curateRevision } from './revisions.js';
|
||||||
import { interpolateProfiles } from '../common/actors.mjs'; // eslint-disable-line import/namespace
|
import { interpolateProfiles } from '../common/actors.mjs'; // eslint-disable-line import/namespace
|
||||||
|
import { resolvePlace } from '../common/geo.mjs'; // eslint-disable-line import/namespace
|
||||||
|
|
||||||
const logger = initLogger();
|
const logger = initLogger();
|
||||||
const mj = new MerkleJson();
|
const mj = new MerkleJson();
|
||||||
|
@ -816,14 +819,48 @@ export async function createActorRevision(actorId, {
|
||||||
return [key, values];
|
return [key, values];
|
||||||
}).filter(Boolean));
|
}).filter(Boolean));
|
||||||
|
|
||||||
const deltas = Object.entries(edits).map(([key, value]) => {
|
const deltas = await Promise.all(Object.entries(edits).map(async ([key, value]) => {
|
||||||
if (baseActor[key] === value || typeof value === 'undefined') {
|
if (baseActor[key] === value || typeof value === 'undefined') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['originPlace', 'residencePlay'].includes(key)) {
|
if (['originPlace', 'residencePlace'].includes(key)) {
|
||||||
console.log(key, value);
|
if (!value) {
|
||||||
throw new Error('must be converted first!');
|
return [
|
||||||
|
// { key: key.includes('origin') ? 'originCountry' : 'residenceCountry', value: null },
|
||||||
|
{ key: key.includes('origin') ? 'originState' : 'residenceState', value: null },
|
||||||
|
{ key: key.includes('origin') ? 'originCity' : 'residenceCity', value: null },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolvedLocation = await resolvePlace(value, {
|
||||||
|
knex,
|
||||||
|
redis,
|
||||||
|
logger,
|
||||||
|
slugify,
|
||||||
|
unprint,
|
||||||
|
}, {
|
||||||
|
userAgent: 'contact via https://traxxx.me/',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!resolvedLocation) {
|
||||||
|
throw new Error(`Failed to resolve ${key} ${value}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
key: key.includes('origin') ? 'originCountry' : 'residenceCountry',
|
||||||
|
value: resolvedLocation.country,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: key.includes('origin') ? 'originState' : 'residenceState',
|
||||||
|
value: resolvedLocation.state,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: key.includes('origin') ? 'originCity' : 'residenceCity',
|
||||||
|
value: resolvedLocation.city,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['cup', 'bust', 'waist', 'hip'].includes(key)) {
|
if (['cup', 'bust', 'waist', 'hip'].includes(key)) {
|
||||||
|
@ -902,7 +939,7 @@ export async function createActorRevision(actorId, {
|
||||||
}
|
}
|
||||||
|
|
||||||
return { key, value };
|
return { key, value };
|
||||||
}).filter(Boolean);
|
})).then((rawDeltas) => rawDeltas.flat().filter(Boolean));
|
||||||
|
|
||||||
const deltaComments = deltas.map((delta) => delta.comment);
|
const deltaComments = deltas.map((delta) => delta.comment);
|
||||||
const curatedComment = [comment, ...deltaComments].filter(Boolean).join(' | ');
|
const curatedComment = [comment, ...deltaComments].filter(Boolean).join(' | ');
|
||||||
|
|
Loading…
Reference in New Issue