Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced shattering #129

Merged
merged 108 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 102 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
96c9a3a
add turf bbox
nofurtherinformation Oct 17, 2024
b565a88
state shatter enhancements
nofurtherinformation Oct 17, 2024
77db599
exist shatter button
nofurtherinformation Oct 17, 2024
6534ae8
map rendering updates
nofurtherinformation Oct 17, 2024
3031963
Update mapStore.ts
nofurtherinformation Oct 17, 2024
a734a25
filter only children
nofurtherinformation Oct 17, 2024
b4e6766
Only filter child layers
nofurtherinformation Oct 17, 2024
0788cb2
update opacity on color
nofurtherinformation Oct 17, 2024
7e9f95f
select both layers if captive
nofurtherinformation Oct 17, 2024
0c40ed0
cleanup
nofurtherinformation Oct 17, 2024
4c47d8e
Hover and set color / zones with shattered child
nofurtherinformation Oct 17, 2024
9329180
lock features
nofurtherinformation Oct 17, 2024
105cbd2
remove pattern
nofurtherinformation Oct 17, 2024
97eba13
lock indicator
nofurtherinformation Oct 17, 2024
661cda9
optionally allow locked geoms in paint function
nofurtherinformation Oct 17, 2024
6e155bb
fix upcert locked feature state
nofurtherinformation Oct 17, 2024
7a99210
prevent re-zone or color of locked feature
nofurtherinformation Oct 17, 2024
a72759e
merge main
raphaellaude Oct 21, 2024
f5bfa54
quick test
raphaellaude Oct 21, 2024
c7c7aa9
mergearoni
raphaellaude Oct 22, 2024
125525f
Merge branch 'main' of github.com:districtr/districtr-v2 into enhance…
raphaellaude Oct 24, 2024
c77a161
unshatter UDF
nofurtherinformation Oct 28, 2024
07156c4
unshatter patch endpoint
nofurtherinformation Oct 28, 2024
0a37d76
unshatter api handler and mutation
nofurtherinformation Oct 28, 2024
ea867d0
state updates: remove shatter data, sub unshatter
nofurtherinformation Oct 28, 2024
7eabc62
clean up
nofurtherinformation Oct 28, 2024
a0894a9
Merge branch 'main' into enhanced-shattering-rebase
nofurtherinformation Oct 28, 2024
849f6ac
fix alembic
nofurtherinformation Oct 28, 2024
7bee6a8
rename to shatter mode
nofurtherinformation Oct 29, 2024
346ffae
decrease non-paintable transparency
nofurtherinformation Oct 29, 2024
1a184ab
refactor layer manager
nofurtherinformation Oct 29, 2024
c00fa2c
Add temporary outline on shatter
nofurtherinformation Oct 29, 2024
c0cb8e7
rename
nofurtherinformation Oct 30, 2024
344affb
remove print
nofurtherinformation Oct 30, 2024
e5a9df3
add lock tool
nofurtherinformation Oct 30, 2024
092c39f
decrease locked opacity
nofurtherinformation Oct 30, 2024
96219f1
ruff
nofurtherinformation Oct 30, 2024
4e7ef74
add "focused" state with heavy outline
nofurtherinformation Oct 30, 2024
65a2fe7
add focused features to state
nofurtherinformation Oct 30, 2024
97445a3
subscribe to focused features
nofurtherinformation Oct 30, 2024
0afd4af
move remove shatters to mouse up event
nofurtherinformation Oct 30, 2024
13022ea
helper to find mode of zone
nofurtherinformation Oct 30, 2024
91a6209
Swap to two actions, unshatter and remove shatter data
nofurtherinformation Oct 30, 2024
a335088
unshatter on reset shatter view
nofurtherinformation Oct 30, 2024
a31551d
add focus feature on re-shatter
nofurtherinformation Oct 30, 2024
f0e9879
lint
nofurtherinformation Oct 30, 2024
be367c3
Merge branch 'main' into enhanced-shattering-rebase
nofurtherinformation Oct 31, 2024
f29cbea
revision history cleanup
nofurtherinformation Oct 31, 2024
5b2aad0
cleanup async events
nofurtherinformation Oct 31, 2024
9badf19
ruff
nofurtherinformation Oct 31, 2024
8766672
Fix context menu double item
nofurtherinformation Oct 31, 2024
fc9e7c8
only auto-unshatter if all same zone
nofurtherinformation Oct 30, 2024
04ae6b7
Merge branch 'main' into enhanced-shattering-rebase
nofurtherinformation Nov 1, 2024
1d7c033
start renaming to break and heal
nofurtherinformation Nov 1, 2024
6a43114
prettier
nofurtherinformation Nov 1, 2024
1985754
swap to copy of airbnb prettier config
nofurtherinformation Nov 1, 2024
4751e87
refactor cleanup, naming things better
nofurtherinformation Nov 1, 2024
9ec4839
exit block view and lock
nofurtherinformation Nov 1, 2024
8c64621
fix prettier command
nofurtherinformation Nov 1, 2024
a37a1df
Add option to highlight broken districts
nofurtherinformation Nov 4, 2024
bb19199
Update MapLayerManager.ts
nofurtherinformation Nov 4, 2024
c49ba97
Clean up unshatter events to sub
nofurtherinformation Nov 4, 2024
78d31e2
block shatter child block
nofurtherinformation Nov 4, 2024
108f302
clean up feature filtering on brush
nofurtherinformation Nov 4, 2024
7e4da88
Update mapStore.ts
nofurtherinformation Nov 4, 2024
9078bfc
Handle shatter on children
nofurtherinformation Nov 4, 2024
1deaad7
Option to lock all painted areas
nofurtherinformation Nov 4, 2024
b98feaa
Swap map bbox state to map options
nofurtherinformation Nov 4, 2024
16ad2cb
prettier
nofurtherinformation Nov 4, 2024
4e2a8e5
clean up bbox in subs
nofurtherinformation Nov 4, 2024
f58b50d
mutation safety on heal
nofurtherinformation Nov 5, 2024
316358c
Simplify zone update logic + centralize in state
nofurtherinformation Nov 5, 2024
c124435
Clean up and more mutation overlap protection
nofurtherinformation Nov 5, 2024
02b9f2c
remove map layer manager - wait for next PR
nofurtherinformation Nov 5, 2024
20f4938
Clean up layer locking
nofurtherinformation Nov 5, 2024
3a7152c
Better docs of fussy logic
nofurtherinformation Nov 5, 2024
bbfd1d3
Clean up map rendering bug
nofurtherinformation Nov 5, 2024
80121d0
Fix locking on exit break view and highlight
nofurtherinformation Nov 5, 2024
64760a9
notes
nofurtherinformation Nov 5, 2024
9a04c23
Merge branch 'main' into enhanced-shattering-rebase
nofurtherinformation Nov 5, 2024
4ec8122
Highlight on close
nofurtherinformation Nov 5, 2024
e6d6aee
fix lock on exit block view
nofurtherinformation Nov 7, 2024
15bb5f5
Unlock children on heal
nofurtherinformation Nov 7, 2024
29b5f70
Allow locked features to be painted
nofurtherinformation Nov 7, 2024
945bac0
Lint
nofurtherinformation Nov 7, 2024
6bef50a
Lock by zone and color component refactor
nofurtherinformation Nov 7, 2024
f1557ca
Lint
nofurtherinformation Nov 7, 2024
be3a89f
Return GEOIDS from SQL function and simplify return
nofurtherinformation Nov 8, 2024
5b7b421
remove unused model
nofurtherinformation Nov 8, 2024
defeb6a
Rename ZoneAndGEOIDS to AssignedGEOIDS
nofurtherinformation Nov 8, 2024
0831392
Update comment on alembic revision
nofurtherinformation Nov 8, 2024
dc40e47
Update frontend to return type from unshatter
nofurtherinformation Nov 8, 2024
52ad7e2
Increase color opacity on lock state
nofurtherinformation Nov 8, 2024
bd7cbf2
Clean up return function
nofurtherinformation Nov 8, 2024
9328f4b
Clean up old zone assignments on unshatter
nofurtherinformation Nov 8, 2024
9091aa3
Set app loading state on document blur
nofurtherinformation Nov 8, 2024
37e833a
Reduce extra zone assignment events
nofurtherinformation Nov 8, 2024
eb3f843
Merge branch 'main' into enhanced-shattering-rebase
nofurtherinformation Nov 8, 2024
7bfe4a5
Prettier
nofurtherinformation Nov 8, 2024
abcfe25
Lint
nofurtherinformation Nov 8, 2024
c1319ae
Fix mobile color picker DOM
nofurtherinformation Nov 8, 2024
773d9e9
Lint
nofurtherinformation Nov 8, 2024
a5ffca9
restyle line layer
nofurtherinformation Nov 11, 2024
2662ddd
unshatter test
nofurtherinformation Nov 11, 2024
030b9c6
Merge branch 'main' into enhanced-shattering-rebase
nofurtherinformation Nov 11, 2024
7074edc
Prettier
nofurtherinformation Nov 11, 2024
b5e9551
Prettier
nofurtherinformation Nov 11, 2024
dacb89d
ruff
nofurtherinformation Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
module.exports = {
...require('prettier-airbnb-config'),
// https://github.com/Parker-Ledoux/prettier-airbnb-config
"$schema": "http://json.schemastore.org/prettierrc",
"arrowParens": "avoid",
"bracketSpacing": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 100,
"proseWrap": "always",
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
};
19 changes: 13 additions & 6 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
This is a [Next.js](https://nextjs.org/) project bootstrapped with
[`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

Expand All @@ -22,9 +23,11 @@ bun dev

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the
file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to
automatically optimize and load Inter, a custom Google Font.

## Learn More

Expand All @@ -33,10 +36,14 @@ To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your
feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
The easiest way to deploy your Next.js app is to use the
[Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme)
from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more
details.
24 changes: 12 additions & 12 deletions app/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { withSentryConfig } from "@sentry/nextjs";
import {withSentryConfig} from '@sentry/nextjs';
/** @type {import('next').NextConfig} */
const nextConfig = {
async redirects() {
return [
// Basic redirect
{
source: "/",
destination: "/map",
source: '/',
destination: '/map',
permanent: true,
},
];
Expand All @@ -16,12 +16,12 @@ const nextConfig = {
},
resolve: {
alias: {
"@src": "app/src",
"@components": "app/src/components",
"@utils": "app/src/utils",
"@api": "app/src/api",
"@store": "app/src/store",
"@constants": "app/src/constants",
'@src': 'app/src',
'@components': 'app/src/components',
'@utils': 'app/src/utils',
'@api': 'app/src/api',
'@store': 'app/src/store',
'@constants': 'app/src/constants',
},
},
};
Expand All @@ -30,8 +30,8 @@ export default withSentryConfig(nextConfig, {
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

org: "mggg-districtr",
project: "districtr-v2-app",
org: 'mggg-districtr',
project: 'districtr-v2-app',

// Only print logs for uploading source maps in CI
silent: !process.env.CI,
Expand All @@ -51,7 +51,7 @@ export default withSentryConfig(nextConfig, {
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",
tunnelRoute: '/monitoring',

// Hides source maps from generated client bundles
hideSourceMaps: true,
Expand Down
26 changes: 10 additions & 16 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"prettier": "prettier --write src/**/*.{tsx,ts} --config .prettierrc.js"
},
"dependencies": {
"@emotion/react": "^11.13.0",
Expand All @@ -17,6 +18,7 @@
"@sentry/nextjs": "^8.26.0",
"@stitches/react": "^1.2.8",
"@tanstack/react-query": "^5.51.11",
"@turf/bbox": "^7.1.0",
"@turf/boolean-within": "^7.1.0",
"@turf/helpers": "^7.1.0",
"@turf/point-on-feature": "^7.1.0",
Expand Down Expand Up @@ -46,7 +48,7 @@
"jest": "^29.7.0",
"nock": "^13.5.4",
"postcss": "^8",
"prettier-airbnb-config": "^1.0.0",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
Expand Down
4 changes: 2 additions & 2 deletions app/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: "https://e42d7ccd60a760cd2885b3f394b3a73b@o4507623009091584.ingest.us.sentry.io/4507794033082368",
dsn: 'https://e42d7ccd60a760cd2885b3f394b3a73b@o4507623009091584.ingest.us.sentry.io/4507794033082368',

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
Expand Down
4 changes: 2 additions & 2 deletions app/sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: "https://e42d7ccd60a760cd2885b3f394b3a73b@o4507623009091584.ingest.us.sentry.io/4507794033082368",
dsn: 'https://e42d7ccd60a760cd2885b3f394b3a73b@o4507623009091584.ingest.us.sentry.io/4507794033082368',

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
Expand Down
5 changes: 2 additions & 3 deletions app/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// The config you add here will be used whenever the server handles a request.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: "https://e42d7ccd60a760cd2885b3f394b3a73b@o4507623009091584.ingest.us.sentry.io/4507794033082368",
dsn: 'https://e42d7ccd60a760cd2885b3f394b3a73b@o4507623009091584.ingest.us.sentry.io/4507794033082368',

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,
Expand All @@ -15,5 +15,4 @@ Sentry.init({

// Uncomment the line below to enable Spotlight (https://spotlightjs.com)
// spotlight: process.env.NODE_ENV === 'development',

});
62 changes: 52 additions & 10 deletions app/src/app/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
import React from 'react';
import {ContextMenu, Text} from '@radix-ui/themes';
import {useMapStore} from '@/app/store/mapStore';
import {CHILD_LAYERS, PARENT_LAYERS} from '../constants/layers';

export const MapContextMenu: React.FC = () => {
const mapDocument = useMapStore(state => state.mapDocument);
const contextMenu = useMapStore(state => state.contextMenu);
const handleShatter = useMapStore(state => state.handleShatter);
const lockedFeatures = useMapStore(state => state.lockedFeatures);
const lockFeature = useMapStore(state => state.lockFeature);
const shatterMappings = useMapStore(state => state.shatterMappings);

const canShatter = Boolean(
mapDocument?.parent_layer &&
mapDocument.child_layer &&
mapDocument.child_layer !== contextMenu?.data.sourceLayer
);

if (!contextMenu) return null;
const isChild = CHILD_LAYERS.includes(contextMenu.data.layer.id);
const id = contextMenu.data.id?.toString() || '';
const parent =
(isChild &&
Object.entries(shatterMappings).find(([key, value]) => {
return value.has(id);
})?.[0]) ||
false;
const shatterableId = isChild && parent ? parent : contextMenu?.data?.id;
const featureIsLocked = lockedFeatures.has(id);

const handleSelect = () => {
if (!mapDocument || contextMenu?.data?.id === undefined) return;
handleShatter(mapDocument.document_id, [contextMenu.data.id.toString()]);
if (!mapDocument || !shatterableId) return;
const shatterData = isChild ? {id: shatterableId} : contextMenu.data;
handleShatter(mapDocument.document_id, [shatterData]);
contextMenu.close();
};

const handleLock = () => {
lockFeature(id, !featureIsLocked);
};

return (
<ContextMenu.Root onOpenChange={contextMenu.close}>
<ContextMenu.Content
Expand All @@ -32,16 +58,32 @@ export const MapContextMenu: React.FC = () => {
left: contextMenu.x,
}}
>
{contextMenu.data.id && (
<ContextMenu.Label>
<Text size="1" color="gray">
{contextMenu.data.id}
</Text>
</ContextMenu.Label>
<ContextMenu.Label>
<Text size="1" color="gray">
{id}
</Text>
</ContextMenu.Label>
{!isChild && (
<ContextMenu.Item disabled={!mapDocument?.child_layer} onSelect={handleSelect}>
Break to Blocks
</ContextMenu.Item>
)}
<ContextMenu.Item disabled={!mapDocument?.child_layer} onSelect={handleSelect}>
Shatter
<ContextMenu.Item onSelect={handleLock}>
{featureIsLocked ? 'Unlock' : 'Lock'}
</ContextMenu.Item>

{!!parent && (
<>
<ContextMenu.Label>
<Text size="1" color="gray">
Parent: {parent}
</Text>
</ContextMenu.Label>
<ContextMenu.Item disabled={!mapDocument?.child_layer} onSelect={handleSelect}>
Break Parent to Blocks
</ContextMenu.Item>
</>
)}
</ContextMenu.Content>
</ContextMenu.Root>
);
Expand Down
Loading
Loading