From edfeb78578c478eac10aacc6f296c0ef2bd36ce6 Mon Sep 17 00:00:00 2001 From: Niels Vegter Date: Mon, 22 Jan 2024 14:54:55 +0100 Subject: [PATCH 1/3] Typo --- .../src/pages/projects/[project]/settings/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/admin-server/src/pages/projects/[project]/settings/index.tsx b/apps/admin-server/src/pages/projects/[project]/settings/index.tsx index e128c716c..57df9dc02 100644 --- a/apps/admin-server/src/pages/projects/[project]/settings/index.tsx +++ b/apps/admin-server/src/pages/projects/[project]/settings/index.tsx @@ -112,7 +112,7 @@ export default function ProjectSettings() { Projectinformatie - Geadvanceerde instellingen + Geavanceerde instellingen From 78a4edc9ce18e41288cacaa952747aa01276d4e1 Mon Sep 17 00:00:00 2001 From: Niels Vegter Date: Mon, 22 Jan 2024 14:55:42 +0100 Subject: [PATCH 2/3] Add extra tag info to API --- apps/api-server/seeds/development.js | 15 +++++++++++++ apps/api-server/src/models/Tag.js | 33 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/apps/api-server/seeds/development.js b/apps/api-server/seeds/development.js index 1ac999b04..96d7ff7dc 100755 --- a/apps/api-server/seeds/development.js +++ b/apps/api-server/seeds/development.js @@ -306,6 +306,11 @@ module.exports = async function seed(config, db) { name: 'Theme 1', type: 'theme', seqnr: 10, + label: 'Thema 1', + mapIcon: '{"html":"melding-map-icon","width":34,"height":45,"anchor":[17,45]}', + listIcon: '{"html":"melding-lijst-icon","width":34,"height":34}', + color: 'black', + backgroundColor: '#FF9100' }); let theme2 = await db.Tag.create({ @@ -313,6 +318,11 @@ module.exports = async function seed(config, db) { name: 'Theme 2', type: 'theme', seqnr: 20, + label: 'Thema 2', + mapIcon: '{"html":"bewonersvraag-map-icon","width":34,"height":45,"anchor":[17,45]}', + listIcon: '{"html":"bewonersvraag-lijst-icon","width":34,"height":34}', + color: 'white', + backgroundColor: '#E50082' }); let theme3 = await db.Tag.create({ @@ -320,6 +330,11 @@ module.exports = async function seed(config, db) { name: 'Theme 3', type: 'theme', seqnr: 30, + label: 'Thema 3', + mapIcon: '{"html":"Path","width":34,"height":45,"anchor":[17,45]}', + listIcon: '{"html":"plan-lijst-icon","width":34,"height":34}', + color: 'white', + backgroundColor: '#00A03C' }); let area1 = await db.Tag.create({ diff --git a/apps/api-server/src/models/Tag.js b/apps/api-server/src/models/Tag.js index f40f826ef..4b2ad537e 100755 --- a/apps/api-server/src/models/Tag.js +++ b/apps/api-server/src/models/Tag.js @@ -35,6 +35,39 @@ module.exports = function( db, sequelize, DataTypes ) { default: 10, }, + type: { + type : DataTypes.STRING, + allowNull : true, + set : function( text ) { + this.setDataValue('type', text?sanitize.safeTags(text.trim()):null); + } + }, + + label: { + type : DataTypes.STRING, + allowNull : true, + }, + + color: { + type : DataTypes.STRING, + allowNull : true, + }, + + backgroundColor: { + type : DataTypes.STRING, + allowNull : true, + }, + + mapIcon: { + type : DataTypes.TEXT, + allowNull : true, + }, + + listIcon: { + type : DataTypes.TEXT, + allowNull : true, + }, + extraData: getExtraDataConfig(DataTypes.JSON, 'tags') }, { From 877024b2fc38840a5d9d38871b0dc89e5dedfdb3 Mon Sep 17 00:00:00 2001 From: Niels Vegter Date: Mon, 22 Jan 2024 14:56:13 +0100 Subject: [PATCH 3/3] Add extra tag info to Admin --- apps/admin-server/src/hooks/use-tag.tsx | 6 +- .../projects/[project]/tags/[tag]/index.tsx | 208 +++++++++++++----- apps/api-server/src/models/Resource.js | 2 +- 3 files changed, 159 insertions(+), 57 deletions(-) diff --git a/apps/admin-server/src/hooks/use-tag.tsx b/apps/admin-server/src/hooks/use-tag.tsx index 607e3d894..1958675b7 100644 --- a/apps/admin-server/src/hooks/use-tag.tsx +++ b/apps/admin-server/src/hooks/use-tag.tsx @@ -5,17 +5,17 @@ export default function useTags(projectId?: string, id?: string) { const tagSwr = useSWR(projectId && id ? url : null); - async function updateTag(name: string, type: string, seqnr: number) { + async function updateTag(name: string, type: string, seqnr: number, backgroundColor: string | undefined, color: string | undefined, label: string | undefined, mapIcon: string | undefined, listIcon: string | undefined) { const res = await fetch(url, { method: 'PUT', headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify({ projectId, id, name, type, seqnr }), + body: JSON.stringify({ projectId, id, name, type, seqnr, backgroundColor, color, label, mapIcon, listIcon }), }); return await res.json(); } return { ...tagSwr, updateTag } -} \ No newline at end of file +} diff --git a/apps/admin-server/src/pages/projects/[project]/tags/[tag]/index.tsx b/apps/admin-server/src/pages/projects/[project]/tags/[tag]/index.tsx index a5b53786f..68c6b93ab 100644 --- a/apps/admin-server/src/pages/projects/[project]/tags/[tag]/index.tsx +++ b/apps/admin-server/src/pages/projects/[project]/tags/[tag]/index.tsx @@ -12,6 +12,7 @@ import { FormLabel, FormMessage, } from '@/components/ui/form'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Input } from '@/components/ui/input'; import { PageLayout } from '@/components/ui/page-layout'; import { Heading } from '@/components/ui/typography'; @@ -25,11 +26,15 @@ const formSchema = z.object({ name: z.string(), type: z.string(), seqnr: z.coerce.number(), + backgroundColor: z.string().optional(), + color: z.string().optional(), + label: z.string().optional(), + mapIcon: z.string().max(5000).optional(), + listIcon: z.string().optional(), }); export default function ProjectTagEdit() { const router = useRouter(); - console.log(router); const { project, tag } = router.query; const { data, isLoading, updateTag } = useTag( project as string, @@ -41,6 +46,11 @@ export default function ProjectTagEdit() { name: data?.name || null, type: data?.type || null, seqnr: data?.seqnr || null, + backgroundColor: data?.backgroundColor || undefined, + color: data?.color || undefined, + label: data?.label || undefined, + mapIcon: data?.mapIcon || undefined, + listIcon: data?.listIcon || undefined, }), [data] ); @@ -51,7 +61,7 @@ export default function ProjectTagEdit() { }); async function onSubmit(values: z.infer) { - const tag = await updateTag(values.name, values.type, values.seqnr); + const tag = await updateTag(values.name, values.type, values.seqnr, values.backgroundColor, values.color, values.label, values.mapIcon, values.listIcon); if (tag) { toast.success('Tag aangepast!'); } else { @@ -81,57 +91,149 @@ export default function ProjectTagEdit() { url: `/projects/${project}/tags/${tag}`, }, ]}> -
-
- Aanpassen - - - ( - - Naam - - - - - - )} - /> - ( - - Type - - - - - - )} - /> - ( - - Sequence nummer - - - - - - )} - /> - - - +
+ + + Tag + + Geavanceerde instellingen + + + +
+
+ Tag Aanpassen + + + ( + + Naam + + + + + + )} + /> + ( + + Type + + + + + + )} + /> + ( + + Sequence nummer + + + + + + )} + /> + + + +
+
+ +
+
+ Tag weergave + + + ( + + Achtergrond kleur + + + + + + )} + /> + ( + + Tekst kleur + + + + + + )} + /> + ( + + Label + + + + + + )} + /> + ( + + Kaart icon + + + + + + )} + /> + ( + + Resource overview icon + + + + + + )} + /> + + + +
+
+
diff --git a/apps/api-server/src/models/Resource.js b/apps/api-server/src/models/Resource.js index 68458de69..16a46ea88 100644 --- a/apps/api-server/src/models/Resource.js +++ b/apps/api-server/src/models/Resource.js @@ -641,7 +641,7 @@ module.exports = function (db, sequelize, DataTypes) { includeTags: { include: [{model: db.Tag, - attributes: ['id', 'name'], + attributes: ['id', 'type', 'name'], through: {attributes: []}, }] },