Added figure size conversions to actor revisions.
This commit is contained in:
parent
192aeeaafd
commit
39a7cf2ec0
|
@ -176,12 +176,12 @@
|
||||||
>{{ rev.base.title }}</span>
|
>{{ rev.base.title }}</span>
|
||||||
|
|
||||||
<span class="rev-summary">
|
<span class="rev-summary">
|
||||||
|
<span class="summary-deltas ellipsis">{{ rev.deltas.map((delta) => delta.key).join(', ') }}</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="rev.comment"
|
v-if="rev.comment"
|
||||||
class="summary-comment ellipsis"
|
class="summary-comment ellipsis"
|
||||||
>{{ rev.comment }}</span>
|
>{{ rev.comment }}</span>
|
||||||
|
|
||||||
<span class="summary-deltas ellipsis">{{ rev.deltas.map((delta) => delta.key).join(', ') }}</span>
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="rev-details noshrink">
|
<div class="rev-details noshrink">
|
||||||
|
@ -615,9 +615,9 @@ async function banEditor(revision) {
|
||||||
}
|
}
|
||||||
|
|
||||||
.summary-comment {
|
.summary-comment {
|
||||||
padding-right: .5rem;
|
padding-left: .5rem;
|
||||||
border-right: solid 1px var(--glass-weak-20);
|
border-left: solid 1px var(--glass-weak-20);
|
||||||
margin-right: .5rem;
|
margin-left: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.summary-deltas {
|
.summary-deltas {
|
||||||
|
|
|
@ -138,7 +138,7 @@
|
||||||
v-for="option in item.options"
|
v-for="option in item.options"
|
||||||
:key="`${item.key}-option-${option}`"
|
:key="`${item.key}-option-${option}`"
|
||||||
:value="typeof option?.value === 'undefined' ? option : option.value"
|
:value="typeof option?.value === 'undefined' ? option : option.value"
|
||||||
>{{ option?.label || option || 'unknown' }}</option>
|
>{{ option?.label || option }}</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
@ -196,14 +196,17 @@
|
||||||
<span class="value-label">Units</span>
|
<span class="value-label">Units</span>
|
||||||
|
|
||||||
<select
|
<select
|
||||||
v-model="figureSystem"
|
v-model="figureUnits"
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option value="us">USA</option>
|
<option value="us">USA</option>
|
||||||
|
<option value="uk">UK</option>
|
||||||
<option value="eu">Europe/Asia</option>
|
<option value="eu">Europe/Asia</option>
|
||||||
<option value="jp">Japan</option>
|
<option value="jp">Japan</option>
|
||||||
<option value="aus">Australia</option>
|
<option value="au">Australia</option>
|
||||||
|
<option value="it">Italy</option>
|
||||||
|
<option value="fr">France</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -211,13 +214,23 @@
|
||||||
<div class="value-section">
|
<div class="value-section">
|
||||||
<span class="value-label">Bust</span>
|
<span class="value-label">Bust</span>
|
||||||
|
|
||||||
<input
|
<select
|
||||||
v-model="edits[item.key].bust"
|
v-model="edits[item.key].bust"
|
||||||
type="number"
|
class="select input"
|
||||||
class="input"
|
|
||||||
placeholder="Bust"
|
placeholder="Bust"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
|
<option
|
||||||
|
:key="`${item.key}-bust-unknown`"
|
||||||
|
:value="null"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<option
|
||||||
|
v-for="bust in bustSizes[figureUnits]"
|
||||||
|
:key="`${item.key}-bust-${bust}`"
|
||||||
|
:value="Array.isArray(bust) ? bust[0] : bust"
|
||||||
|
>{{ Array.isArray(bust) ? bust.join('/') : bust }}</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="value-section">
|
<div class="value-section">
|
||||||
|
@ -232,13 +245,13 @@
|
||||||
<option
|
<option
|
||||||
:key="`${item.key}-cup-unknown`"
|
:key="`${item.key}-cup-unknown`"
|
||||||
:value="null"
|
:value="null"
|
||||||
>Unknown</option>
|
/>
|
||||||
|
|
||||||
<option
|
<option
|
||||||
v-for="cup in cupSizes"
|
v-for="cup in cupSizes[figureUnits]"
|
||||||
:key="`${item.key}-cup-${cup}`"
|
:key="`${item.key}-cup-${cup}`"
|
||||||
:value="cup"
|
:value="Array.isArray(cup) ? cup[0] : cup"
|
||||||
>{{ cup }}</option>
|
>{{ Array.isArray(cup) ? cup.join('/') : cup }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
@ -246,25 +259,33 @@
|
||||||
<div class="value-section">
|
<div class="value-section">
|
||||||
<span class="value-label">Waist</span>
|
<span class="value-label">Waist</span>
|
||||||
|
|
||||||
|
<span>
|
||||||
<input
|
<input
|
||||||
v-model="edits[item.key].waist"
|
v-model="edits[item.key].waist"
|
||||||
type="number"
|
type="number"
|
||||||
class="input"
|
class="input"
|
||||||
placeholder="Waist"
|
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<template v-if="['us', 'uk'].includes(figureUnits)"> inch</template>
|
||||||
|
<template v-else> cm</template>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="value-section">
|
<div class="value-section">
|
||||||
<span class="value-label">Hip</span>
|
<span class="value-label">Hip</span>
|
||||||
|
|
||||||
|
<span>
|
||||||
<input
|
<input
|
||||||
v-model="edits[item.key].hip"
|
v-model="edits[item.key].hip"
|
||||||
type="number"
|
type="number"
|
||||||
class="input"
|
class="input"
|
||||||
placeholder="Hip"
|
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<template v-if="['us', 'uk'].includes(figureUnits)"> inch</template>
|
||||||
|
<template v-else> cm</template>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -280,7 +301,7 @@
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option :value="null">Unknown</option>
|
<option :value="null" />
|
||||||
<option :value="true">Yes</option>
|
<option :value="true">Yes</option>
|
||||||
<option :value="false">No</option>
|
<option :value="false">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -314,7 +335,7 @@
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option :value="null">Unknown</option>
|
<option :value="null" />
|
||||||
<option value="saline">Saline</option>
|
<option value="saline">Saline</option>
|
||||||
<option value="silicone">Silicone</option>
|
<option value="silicone">Silicone</option>
|
||||||
<option value="gummy">Gummy</option>
|
<option value="gummy">Gummy</option>
|
||||||
|
@ -333,7 +354,7 @@
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option :value="null">Unknown</option>
|
<option :value="null" />
|
||||||
<option value="over">Over muscle</option>
|
<option value="over">Over muscle</option>
|
||||||
<option value="under">Under muscle</option>
|
<option value="under">Under muscle</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -367,7 +388,7 @@
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option :value="null">Unknown</option>
|
<option :value="null" />
|
||||||
<option :value="true">Yes</option>
|
<option :value="true">Yes</option>
|
||||||
<option :value="false">No</option>
|
<option :value="false">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -401,7 +422,7 @@
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option :value="null">Unknown</option>
|
<option :value="null" />
|
||||||
<option value="bbl">BBL (fat transfer)</option>
|
<option value="bbl">BBL (fat transfer)</option>
|
||||||
<option value="lift">Direct lift</option>
|
<option value="lift">Direct lift</option>
|
||||||
<option value="filler">Filler (Sculptra)</option>
|
<option value="filler">Filler (Sculptra)</option>
|
||||||
|
@ -419,7 +440,7 @@
|
||||||
<span class="value-label">Units</span>
|
<span class="value-label">Units</span>
|
||||||
|
|
||||||
<select
|
<select
|
||||||
v-model="penisSystem"
|
v-model="penisUnits"
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
|
@ -462,7 +483,7 @@
|
||||||
class="input"
|
class="input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option :value="null">Unknown</option>
|
<option :value="null" />
|
||||||
<option :value="true">Yes</option>
|
<option :value="true">Yes</option>
|
||||||
<option :value="false">No</option>
|
<option :value="false">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -478,7 +499,7 @@
|
||||||
class="select input"
|
class="select input"
|
||||||
:disabled="!editing.has(item.key)"
|
:disabled="!editing.has(item.key)"
|
||||||
>
|
>
|
||||||
<option :value="null">Unknown</option>
|
<option :value="null" />
|
||||||
<option :value="true">Yes</option>
|
<option :value="true">Yes</option>
|
||||||
<option :value="false">No</option>
|
<option :value="false">No</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -574,6 +595,7 @@ const topCountries = [
|
||||||
|
|
||||||
const sortedCountries = countries.toSorted((countryA, countryB) => topCountries.indexOf(countryB.alpha2) - topCountries.indexOf(countryA.alpha2));
|
const sortedCountries = countries.toSorted((countryA, countryB) => topCountries.indexOf(countryB.alpha2) - topCountries.indexOf(countryA.alpha2));
|
||||||
|
|
||||||
|
/*
|
||||||
const cupSizes = [
|
const cupSizes = [
|
||||||
'A', 'AA',
|
'A', 'AA',
|
||||||
'B',
|
'B',
|
||||||
|
@ -591,6 +613,30 @@ const cupSizes = [
|
||||||
'O',
|
'O',
|
||||||
'P',
|
'P',
|
||||||
];
|
];
|
||||||
|
*/
|
||||||
|
|
||||||
|
const cupSizes = {
|
||||||
|
us: ['AA', 'A', 'B', 'C', 'D', ['DD', 'E'], ['DDD', 'F'], 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'], // United States
|
||||||
|
uk: ['AA', 'A', 'B', 'C', 'D', 'DD', 'E', 'F', 'FF', 'G', 'GG', 'H', 'HH', 'J', 'JJ', 'K', 'KK'], // United Kingdom
|
||||||
|
eu: ['AA', 'A', 'B', 'C', 'D', 'E', 'F', 'G', ' H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'], // Europe
|
||||||
|
jp: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q'], // Japan
|
||||||
|
};
|
||||||
|
|
||||||
|
cupSizes.fr = cupSizes.eu; // France
|
||||||
|
cupSizes.it = cupSizes.uk; // Italy
|
||||||
|
cupSizes.au = cupSizes.uk; // Australia
|
||||||
|
|
||||||
|
// bra band sizes
|
||||||
|
const bustSizes = {
|
||||||
|
us: [28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56],
|
||||||
|
eu: [60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130],
|
||||||
|
fr: [75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145],
|
||||||
|
it: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||||
|
au: [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34],
|
||||||
|
};
|
||||||
|
|
||||||
|
bustSizes.uk = bustSizes.us;
|
||||||
|
bustSizes.jp = bustSizes.eu;
|
||||||
|
|
||||||
const fields = computed(() => [
|
const fields = computed(() => [
|
||||||
{
|
{
|
||||||
|
@ -767,8 +813,8 @@ const comment = ref(null);
|
||||||
const apply = ref(user.role !== 'user');
|
const apply = ref(user.role !== 'user');
|
||||||
const submitted = ref(false);
|
const submitted = ref(false);
|
||||||
|
|
||||||
const figureSystem = ref('us');
|
const figureUnits = ref('us');
|
||||||
const penisSystem = ref('imperial');
|
const penisUnits = ref('imperial');
|
||||||
|
|
||||||
function toggleField(item) {
|
function toggleField(item) {
|
||||||
if (editing.value.has(item.key)) {
|
if (editing.value.has(item.key)) {
|
||||||
|
@ -809,6 +855,8 @@ async function submit() {
|
||||||
|
|
||||||
return [[key, edits.value[key]]];
|
return [[key, edits.value[key]]];
|
||||||
})),
|
})),
|
||||||
|
figureUnits: figureUnits.value,
|
||||||
|
penisUnits: penisUnits.value,
|
||||||
comment: comment.value,
|
comment: comment.value,
|
||||||
apply: apply.value,
|
apply: apply.value,
|
||||||
}, {
|
}, {
|
||||||
|
@ -873,6 +921,8 @@ async function submit() {
|
||||||
|
|
||||||
.row .input {
|
.row .input {
|
||||||
height: 2.5rem;
|
height: 2.5rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
min-width: 7rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select {
|
.select {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { unit } from 'mathjs';
|
||||||
import { MerkleJson } from 'merkle-json';
|
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 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';
|
||||||
|
@ -662,7 +663,77 @@ export async function reviewActorRevision(revisionId, isApproved, { feedback },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createActorRevision(actorId, { edits, comment, apply }, reqUser) {
|
const cupConversions = {
|
||||||
|
us: ['AA', 'A', 'B', 'C', 'D', ['DD', 'E'], ['DDD', 'F'], 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'], // United States
|
||||||
|
uk: ['AA', 'A', 'B', 'C', 'D', 'DD', 'E', 'F', 'FF', 'G', 'GG', 'H', 'HH', 'J', 'JJ', 'K', 'KK'], // United Kingdom
|
||||||
|
eu: ['AA', 'A', 'B', 'C', 'D', 'E', 'F', 'G', ' H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'], // Europe
|
||||||
|
jp: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q'], // Japan
|
||||||
|
};
|
||||||
|
|
||||||
|
cupConversions.fr = cupConversions.eu; // France
|
||||||
|
cupConversions.it = cupConversions.uk; // Italy
|
||||||
|
cupConversions.au = cupConversions.uk; // Australia
|
||||||
|
|
||||||
|
// bra band sizes
|
||||||
|
const bustConversions = {
|
||||||
|
us: [28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56],
|
||||||
|
eu: [60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130],
|
||||||
|
fr: [75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145],
|
||||||
|
it: [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||||
|
au: [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34],
|
||||||
|
};
|
||||||
|
|
||||||
|
bustConversions.uk = bustConversions.us;
|
||||||
|
bustConversions.jp = bustConversions.eu;
|
||||||
|
|
||||||
|
const conversions = {
|
||||||
|
cup: cupConversions,
|
||||||
|
bust: bustConversions,
|
||||||
|
};
|
||||||
|
|
||||||
|
// to US
|
||||||
|
function convertFigure(domain = 'cup', rawValue, units) {
|
||||||
|
if (!rawValue) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = typeof rawValue === 'string'
|
||||||
|
? rawValue.toUpperCase()
|
||||||
|
: Number(rawValue);
|
||||||
|
|
||||||
|
if (!units || !cupConversions[units] || units === 'us') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!conversions[domain]) {
|
||||||
|
if (['us', 'uk'].includes(units)) {
|
||||||
|
return value; // should already be in inches
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round(convert(value, 'cm').to('inches'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Number.isNaN(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const valueIndex = conversions[domain][units].findIndex((chartValue) => (Array.isArray(chartValue) // US uses both DD and E, and DDD and F
|
||||||
|
? chartValue.includes(value)
|
||||||
|
: value === chartValue));
|
||||||
|
|
||||||
|
const usValue = Array.isArray(conversions[domain].us[valueIndex])
|
||||||
|
? conversions[domain].us[valueIndex][0]
|
||||||
|
: conversions[domain].us[valueIndex];
|
||||||
|
|
||||||
|
return usValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createActorRevision(actorId, {
|
||||||
|
edits,
|
||||||
|
comment,
|
||||||
|
apply,
|
||||||
|
...options
|
||||||
|
}, reqUser) {
|
||||||
const [
|
const [
|
||||||
[actor],
|
[actor],
|
||||||
openRevisions,
|
openRevisions,
|
||||||
|
@ -732,9 +803,29 @@ export async function createActorRevision(actorId, { edits, comment, apply }, re
|
||||||
return { key, value: Array.from(valueSet) };
|
return { key, value: Array.from(valueSet) };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { key, value: value || null };
|
if (['cup', 'bust', 'waist', 'hip'].includes(key)) {
|
||||||
|
const convertedValue = convertFigure(key, value, options.figureUnits);
|
||||||
|
|
||||||
|
const conversionComment = convertedValue === value
|
||||||
|
? null
|
||||||
|
: `${key} converted from ${value} ${options.figureUnits?.toUpperCase() || 'US'} to ${convertedValue} US`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
key,
|
||||||
|
value: convertedValue,
|
||||||
|
comment: conversionComment,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
key,
|
||||||
|
value: value || null,
|
||||||
|
};
|
||||||
}).filter(Boolean);
|
}).filter(Boolean);
|
||||||
|
|
||||||
|
const deltaComments = deltas.map((delta) => delta.comment);
|
||||||
|
const curatedComment = [comment, ...deltaComments].filter(Boolean).join(' | ');
|
||||||
|
|
||||||
if (deltas.length === 0) {
|
if (deltas.length === 0) {
|
||||||
throw new HttpError('No effective changes provided', 400);
|
throw new HttpError('No effective changes provided', 400);
|
||||||
}
|
}
|
||||||
|
@ -749,7 +840,7 @@ export async function createActorRevision(actorId, { edits, comment, apply }, re
|
||||||
base: baseActor,
|
base: baseActor,
|
||||||
deltas,
|
deltas,
|
||||||
}),
|
}),
|
||||||
comment,
|
comment: curatedComment,
|
||||||
})
|
})
|
||||||
.returning('id');
|
.returning('id');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue