Skip to content

Commit

Permalink
Close #8 Display overarching acts
Browse files Browse the repository at this point in the history
  • Loading branch information
driver-deploy-2 committed Nov 27, 2024
1 parent eed6c8c commit 2685eac
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 15 deletions.
5 changes: 3 additions & 2 deletions packages/gui/src/components/ui/crime-script-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,9 @@ export const CrimeScriptEditor: FactoryComponent<{
m('.cur-act', { key: curAct.id }, [
m(LayoutForm, {
form: [
{ id: 'label', type: 'text', className: 'col s6 m9', label: t('NAME'), show: ['!icon=1'] },
{ id: 'label', type: 'text', className: 'col s6 m6', label: t('NAME'), show: ['icon=1'] },
{ id: 'label', type: 'text', className: 'col s6 m6', label: t('NAME'), show: ['!icon=1'] },
{ id: 'label', type: 'text', className: 'col s6 m3', label: t('NAME'), show: ['icon=1'] },
{ id: 'isGeneric', type: 'switch', className: 'col s6 m3', label: t('IS_GENERIC') },
{ id: 'icon', type: 'select', className: 'col s6 m3', label: t('IMAGE'), options: IconOpts },
{ id: 'url', type: 'base64', className: 'col s12 m3', label: t('IMAGE'), show: ['icon=1'] },
{ id: 'description', type: 'textarea', className: 'col s12', label: t('SUMMARY') },
Expand Down
69 changes: 58 additions & 11 deletions packages/gui/src/components/ui/crime-script-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import {
Product,
ServiceProvider,
missingIcon,
scriptIcon,
} from '../../models';
import { State } from '../../services';
import { ITabItem, Tabs } from 'mithril-materialized';
import { FlatButton, ITabItem, Tabs } from 'mithril-materialized';
import { render, SlimdownView } from 'mithril-ui-form';
import { Patch } from 'meiosis-setup/types';
import { ReferenceListComponent } from '../ui/reference';
Expand Down Expand Up @@ -175,7 +176,15 @@ ${toMarkdownOl(attributes, attrIds)}`
if (lookupPartner.size < partners.length) {
partners.forEach((p) => lookupPartner.set(p.id, p));
}
const { label = '...', description, literature, stages = [], productIds = [], geoLocationIds = [] } = crimeScript;
const {
label = '...',
description,
literature,
stages = [],
productIds = [],
geoLocationIds = [],
url = scriptIcon,
} = crimeScript;
const [allCastIds, allSpIds, allAttrIds, allLocIds] = stages.reduce(
(acc, stage) => {
const act = acts.find((a) => a.id === stage.id);
Expand Down Expand Up @@ -207,7 +216,7 @@ ${toMarkdownOl(attributes, attrIds)}`
const selectedActContent = selectedAct
? visualizeAct(selectedAct, cast, serviceProviders, attributes, locations, curPhaseIdx)
: undefined;
console.log(selectedAct?.measures);
// console.log(selectedAct?.measures);
const measuresMd =
selectedAct && selectedAct.measures?.length > 0
? `##### ${t('MEASURES')}
Expand All @@ -222,7 +231,7 @@ ${measuresToMarkdown(selectedAct.measures, lookupPartner, findCrimeMeasure)}`
.map(({ id: actId, ids }) => {
const act = acts.find((a) => a.id === actId);
if (act) {
const { id, label = '...', icon, url, description = '' } = act;
const { id, label = '...', icon, url, description = '', isGeneric } = act;
const imgSrc = (icon === ICONS.OTHER ? url : IconOpts.find((i) => i.id === icon)?.img) || missingIcon;
const variants =
ids.length > 1
Expand Down Expand Up @@ -250,20 +259,32 @@ ${measuresToMarkdown(selectedAct.measures, lookupPartner, findCrimeMeasure)}`
icon: imgSrc,
description: m(SlimdownView, { md: description, removeParagraphs: true }),
variants,
} as ProcessStep;
isGeneric,
} as ProcessStep & { isGeneric?: boolean };
} else {
return undefined;
}
})
.filter(Boolean) as ProcessStep[];
.filter(Boolean) as Array<ProcessStep & { isGeneric?: boolean }>;

return m('.col.s12', [
m('h4', `${label}${productIds.length > 0 ? ` (${toCommaSeparatedList(products, productIds)})` : ''}`),
geoLocationIds.length > 0 &&
m(
'.row',
m(
'i.geo-location',
`${t('GEOLOCATIONS', geoLocationIds.length)}: ${toCommaSeparatedList(geoLocations, geoLocationIds)}`
'.col.s9',
m('h4', `${label}${productIds.length > 0 ? ` (${toCommaSeparatedList(products, productIds)})` : ''}`),
geoLocationIds.length > 0 &&
m(
'i.geo-location',
`${t('GEOLOCATIONS', geoLocationIds.length)}: ${toCommaSeparatedList(geoLocations, geoLocationIds)}`
)
),
m(
'.col.s3',
m('img.right', { src: url, alt: 'Icon', style: { border: '2px solid black', borderRadius: '10px' } })
)
),

description && m('p', description),
m('.row', [
m('.col.s6.m4.l3', [
Expand Down Expand Up @@ -309,8 +330,34 @@ ${measuresToMarkdown(selectedAct.measures, lookupPartner, findCrimeMeasure)}`
literature &&
literature.length > 0 && [m('h5', t('REFERENCES')), m(ReferenceListComponent, { references: literature })],
m('h5', t('ACTS')),
m(FlatButton, {
label: t('MAIN_ACTS'),
style: 'font-size: 16px;',
onclick: () => {
const stage = stages.length > 0 ? stages[0] : undefined;
if (stage) {
// stage.id = variantId;
update({ curActIdx: acts.findIndex((a) => a.id === stage.id) });
}
},
}),
steps
.filter((s) => s.isGeneric)
.map((s) =>
m(FlatButton, {
label: s.title,
style: 'font-size: 16px;',
onclick: () => {
const stage = stages.find((stage) => stage.id === s.id);
if (stage) {
// stage.id = variantId;
update({ curActIdx: acts.findIndex((a) => a.id === s.id) });
}
},
})
),
m(ProcessVisualization, {
steps,
steps: steps.filter((s) => !s.isGeneric),
selectedStep: selectedAct?.id,
onStepSelect: (stepId) => update({ curActIdx: acts.findIndex((a) => a.id === stepId) }),
onVariantSelect: (stepId, variantId) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/gui/src/models/data-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ export type Stage = {
};

export type Act = Labeled & {
/** Overarching act, such as for financial dealings or generic stuff */
isGeneric?: boolean;
/** Locations to perform the activity */
locationIds?: ID[];
/** Barriers or measures to prevent or stop crime */
Expand Down
2 changes: 2 additions & 0 deletions packages/gui/src/services/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const messages = {
STAGE: 'Stage',
SCENES: 'Scenes',
SCENE: 'Scene',
MAIN_ACTS: 'Main Acts',
ACTS: 'Acts',
ACT: 'Act',
SELECT_ACT_TO_EDIT: 'Select act to edit',
Expand Down Expand Up @@ -229,4 +230,5 @@ export const messages = {
SERVICE_PROVIDERS: 'Service Providers',
STEPS: 'Steps',
HEADER: 'Header',
IS_GENERIC: 'Generic act',
};
6 changes: 4 additions & 2 deletions packages/gui/src/services/lang/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const messagesNL: typeof messages = {
STAGE: 'Fase',
SCENES: 'Scenes',
SCENE: 'Scene',
MAIN_ACTS: 'Hoofdproces fases',
ACTS: 'Fases',
ACT: 'Fase',
SELECT_ACT_TO_EDIT: 'Selecteer handeling om te bewerken',
Expand All @@ -81,8 +82,8 @@ export const messagesNL: typeof messages = {
DOWNLOAD: 'Sla model op als JSON',
PERMALINK: 'Maak permanente link',
ROLE: 'Rol',
SELECT_ACT: 'Selecteer scene om te bewerken',
SELECT_ACT_N: 'Selecteer een of meerdere scenes',
SELECT_ACT: 'Selecteer fase om te bewerken',
SELECT_ACT_N: 'Selecteer een of meerdere fases',

/** Crime Prevention Techniques */
INCREASE_EFFORT: 'Verhoog de inspanning',
Expand Down Expand Up @@ -231,4 +232,5 @@ export const messagesNL: typeof messages = {
SERVICE_PROVIDERS: 'Dienstverleners',
STEPS: 'Stappen',
HEADER: 'Titel',
IS_GENERIC: 'Generieke fase',
};

0 comments on commit 2685eac

Please sign in to comment.