Added quick alert buttons to entity and tag headers.
This commit is contained in:
@@ -26,6 +26,10 @@ export function curateEntity(entity, context) {
|
||||
parameters: entity.affiliate.parameters,
|
||||
} : null,
|
||||
...context?.append?.[entity.id],
|
||||
alerts: {
|
||||
only: context?.alerts?.filter((alert) => alert.is_only).flatMap((alert) => alert.alert_ids) || [],
|
||||
multi: context?.alerts?.filter((alert) => !alert.is_only).flatMap((alert) => alert.alert_ids) || [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,8 +78,8 @@ export async function fetchEntities(options = {}) {
|
||||
return entities.map((entityEntry) => curateEntity(entityEntry));
|
||||
}
|
||||
|
||||
export async function fetchEntitiesById(entityIds, options = {}) {
|
||||
const [entities, children] = await Promise.all([
|
||||
export async function fetchEntitiesById(entityIds, options = {}, reqUser) {
|
||||
const [entities, children, alerts] = await Promise.all([
|
||||
knex('entities')
|
||||
.select(
|
||||
'entities.*',
|
||||
@@ -95,12 +99,18 @@ export async function fetchEntitiesById(entityIds, options = {}) {
|
||||
.whereIn('entities.parent_id', entityIds)
|
||||
.whereNot('type', 'info')
|
||||
.orderBy('slug') : [],
|
||||
reqUser
|
||||
? knex('alerts_users_entities')
|
||||
.where('user_id', reqUser.id)
|
||||
.whereIn('entity_id', entityIds)
|
||||
: [],
|
||||
]);
|
||||
|
||||
if (options.order) {
|
||||
return entities.map((entityEntry) => curateEntity(entityEntry, {
|
||||
append: options.append,
|
||||
children,
|
||||
children: children.filter((channel) => channel.parent_id === entityEntry.id),
|
||||
alerts: alerts.filter((alert) => alert.entity_id === entityEntry.id),
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -114,7 +124,8 @@ export async function fetchEntitiesById(entityIds, options = {}) {
|
||||
|
||||
return curateEntity(entity, {
|
||||
append: options.append,
|
||||
children,
|
||||
children: children.filter((channel) => channel.parent_id === entity.id),
|
||||
alerts: alerts.filter((alert) => alert.entity_id === entity.id),
|
||||
});
|
||||
}).filter(Boolean);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user