Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 9 additions & 11 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
version: "3.4"
version: '3.4'

services:
mongo:
build: ./mongodb_replica
environment:
MONGO_INITDB_ROOT_USERNAME: user
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_REPLICA_HOST: localhost
MONGO_REPLICA_PORT: 27018
mongodb:
image: mongo:4.0.3
volumes:
- ./scripts/docker-mongo-init.sh:/docker-mongo-init.sh:ro
entrypoint: ['/bin/bash', '/docker-mongo-init.sh']
ports:
- "27018:27018"
- '27018:27018'

maildev:
image: maildev/maildev
ports:
- "1080:1080"
- "1025:1025"
- '1080:1080'
- '1025:1025'
11 changes: 0 additions & 11 deletions mongodb_replica/Dockerfile

This file was deleted.

10 changes: 10 additions & 0 deletions scripts/docker-mongo-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
mongod --port 27018 --replSet rs0 --bind_ip 0.0.0.0 &
MONGOD_PID=$!

until mongo admin --port 27018 --eval "rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27018' }] }) && db.createUser({ user: 'user', pwd: 'password', roles: ['root'] })"; do
sleep 1
done

echo "REPLICA SET ONLINE"
wait $MONGOD_PID
4 changes: 3 additions & 1 deletion src/app/(payload)/admin/importMap.js

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

30 changes: 18 additions & 12 deletions src/payload/collections/Indicators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ import {
lexicalEditor,
lexicalHTML
} from '@payloadcms/richtext-lexical';
import type { CollectionConfig } from 'payload';
import type { CollectionAfterReadHook, CollectionConfig } from 'payload';

const populateLevels: CollectionAfterReadHook = async ({ doc, req }) => {
const levels = await req.payload.find({
collection: 'payload-indicator-levels',
where: {
indicator: { equals: doc.id }
},
limit: 100,
depth: 0,
sort: 'position'
});
return { ...doc, levels };
};

enum IndicatorSlug {
online = 'online',
Expand All @@ -30,8 +43,10 @@ export const Indicators: CollectionConfig = {
description_html: true,
moreInfos: true,
moreInfosTitle: true,
threshold_max: true,
levels: true
threshold_max: true
},
hooks: {
afterRead: [populateLevels]
},
labels: {
singular: 'Indicateur',
Expand Down Expand Up @@ -130,15 +145,6 @@ export const Indicators: CollectionConfig = {
type: 'number',
label: 'Seuil (maximum)'
},
{
name: 'levels',
label: 'Légende',
type: 'join',
collection: 'payload-indicator-levels',
on: 'indicator',
hasMany: true,
maxDepth: 2
}
],
timestamps: true
};
Expand Down
25 changes: 14 additions & 11 deletions src/payload/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ export interface Config {
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
};
collectionsJoins: {
'payload-indicators': {
levels: 'payload-indicator-levels';
};
};
collectionsJoins: {};
collectionsSelect: {
'payload-admins': PayloadAdminsSelect<false> | PayloadAdminsSelect<true>;
'payload-media': PayloadMediaSelect<false> | PayloadMediaSelect<true>;
Expand Down Expand Up @@ -108,6 +104,9 @@ export interface Config {
footer: FooterSelect<false> | FooterSelect<true>;
};
locale: null;
widgets: {
collections: CollectionsWidget;
};
user: PayloadAdmin;
jobs: {
tasks: unknown;
Expand Down Expand Up @@ -236,11 +235,6 @@ export interface PayloadIndicator {
moreInfosTitle?: string | null;
moreInfos?: string | null;
threshold_max?: number | null;
levels?: {
docs?: (string | PayloadIndicatorLevel)[];
hasNextPage?: boolean;
totalDocs?: number;
};
updatedAt: string;
createdAt: string;
}
Expand Down Expand Up @@ -402,7 +396,6 @@ export interface PayloadIndicatorsSelect<T extends boolean = true> {
moreInfosTitle?: T;
moreInfos?: T;
threshold_max?: T;
levels?: T;
updatedAt?: T;
createdAt?: T;
}
Expand Down Expand Up @@ -843,6 +836,16 @@ export interface FooterSelect<T extends boolean = true> {
createdAt?: T;
globalType?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "collections_widget".
*/
export interface CollectionsWidget {
data?: {
[k: string]: unknown;
};
width: 'full';
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auth".
Expand Down
3 changes: 1 addition & 2 deletions src/scripts/goal-reached.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ async function updateGoalReachedProperty() {
collection: 'payload-indicators',
select: {
id: true,
slug: true,
levels: true
slug: true
},
limit: 100
});
Expand Down
Loading