Skip to content

Commit

Permalink
adding news custom views
Browse files Browse the repository at this point in the history
  • Loading branch information
RudiThoeni committed Oct 8, 2024
1 parent 979067d commit d41f169
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 0 deletions.
2 changes: 2 additions & 0 deletions databrowser/src/config/tourism/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { weatherInfoConfig } from './weatherInfo/weatherInfo.config';
import { weatherRealTimeConfig } from './weatherRealTime/weatherRealTime.config';
import { webcamInfoConfig } from './webcamInfo/webcamInfo.config';
import { wineAwardConfig } from './wineAward/wineAward.config';
import { noinewsConfig } from './noinews/noinews.config';

export const tourismEmbeddedDatasetConfigs = [
accommodationConfig,
Expand Down Expand Up @@ -79,6 +80,7 @@ export const tourismEmbeddedDatasetConfigs = [
pushResponseConfig,
odhTagConfig,
tagConfig,
noinewsConfig,
].map<DatasetConfig>((config) => ({
...config,
views: {
Expand Down
19 changes: 19 additions & 0 deletions databrowser/src/config/tourism/noinews/noinews.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import { domainWithOpenApiDocument } from '../../../domain/openApi';
import { DatasetConfig } from '../../../domain/datasets/config/types';
import { noinewsDescription } from './noinews.description';
import { noinewsOperations } from './noinews.operations';
import { noinewsRoute } from './noinews.route';
import { noinewsViews } from './noinews.views';

export const noinewsConfig: DatasetConfig = {
source: 'embedded',
baseUrl: domainWithOpenApiDocument.tourism.baseUrl,
route: noinewsRoute,
description: noinewsDescription,
views: noinewsViews,
operations: noinewsOperations,
};
11 changes: 11 additions & 0 deletions databrowser/src/config/tourism/noinews/noinews.description.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import { DatasetDescription } from '../../../domain/datasets/config/types';

export const noinewsDescription: DatasetDescription = {
title: 'Articles Noi News',
subtitle: 'This dataset contains Noi news articles',
description: 'This dataset contains Noi news articles.',
};
46 changes: 46 additions & 0 deletions databrowser/src/config/tourism/noinews/noinews.listView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import { CellComponent } from '../../../domain/cellComponents/types';
import { ListViewConfig } from '../../../domain/datasets/config/types';
import {
imageTableCell,
languageTableCell,
lastChangesTableCell,
sourceTableCell,
titleTableCell,
publishedOnTableCell,
pushDataTableCell,
} from '../../builder/tourism';

export const noinewsListView: ListViewConfig = {
elements: [
titleTableCell(),
imageTableCell(),
{
title: 'Type',
component: CellComponent.StringCell,
class: 'w-48',
objectMapping: {
text: 'Type',
},
},
{
title: 'Tags',
component: CellComponent.ArrayCell,
class: 'w-40',
objectMapping: {
items: 'SmgTags',
},
params: {
separator: ', ',
},
},
languageTableCell(),
lastChangesTableCell(),
sourceTableCell(),
publishedOnTableCell(),
pushDataTableCell(),
],
};
29 changes: 29 additions & 0 deletions databrowser/src/config/tourism/noinews/noinews.operations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import { Operations } from '../../../domain/datasets/config/types';
import {
extendCreateRoles,
extendDeleteRoles,
extendUpdateRoles,
ROLE_READ,
} from '../roles';

export const noinewsOperations: Operations = {
readAll: {
rolesAllowed: ROLE_READ,
},
read: {
rolesAllowed: ROLE_READ,
},
create: {
rolesAllowed: extendCreateRoles(['ArticleManager', 'ArticleCreate']),
},
update: {
rolesAllowed: extendUpdateRoles(['ArticleManager', 'ArticleUpdate']),
},
delete: {
rolesAllowed: extendDeleteRoles(['ArticleManager', 'ArticleDelete']),
},
};
10 changes: 10 additions & 0 deletions databrowser/src/config/tourism/noinews/noinews.route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import { DatasetRoute } from '../../../domain/datasets/config/types';

export const noinewsRoute: DatasetRoute = {
domain: 'tourism',
pathSegments: ['v1', 'Article?articletype=newsfeednoi'],
};
130 changes: 130 additions & 0 deletions databrowser/src/config/tourism/noinews/noinews.sharedView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import { CellComponent } from '../../../domain/cellComponents/types';
import {
DetailViewConfig,
EditViewConfig,
} from '../../../domain/datasets/config/types';
import {
contactCategory,
dataStatesSubCategory,
idReadOnlyCell,
imageGalleryCategory,
odhTagCategory,

Check warning on line 15 in databrowser/src/config/tourism/noinews/noinews.sharedView.ts

View workflow job for this annotation

GitHub Actions / test

'odhTagCategory' is defined but never used

Check warning on line 15 in databrowser/src/config/tourism/noinews/noinews.sharedView.ts

View workflow job for this annotation

GitHub Actions / test

'odhTagCategory' is defined but never used
seasonCategory,

Check warning on line 16 in databrowser/src/config/tourism/noinews/noinews.sharedView.ts

View workflow job for this annotation

GitHub Actions / test

'seasonCategory' is defined but never used

Check warning on line 16 in databrowser/src/config/tourism/noinews/noinews.sharedView.ts

View workflow job for this annotation

GitHub Actions / test

'seasonCategory' is defined but never used
shortnameCell,
sourceSubCategoryWithDistinct,
textInfoCategory,
licenseInfoCategory,
mappingCategory,
tagCategory,
} from '../../builder/tourism';
import { videoItemsCategory } from '../../builder/tourism/video';
import { DEFAULT_DATE_FORMAT, withOdhBaseUrl } from '../../utils';

export const noinewsSharedView = (): DetailViewConfig | EditViewConfig => ({
elements: [
{
name: 'Main data',
slug: 'main-data',
subcategories: [
{
name: 'General data',
properties: [shortnameCell()],
},
{
name: 'IDs',
properties: [idReadOnlyCell()],
},
dataStatesSubCategory(),
sourceSubCategoryWithDistinct('article'),
],
},
textInfoCategory(),
contactCategory(),
imageGalleryCategory(),
videoItemsCategory(),
{
name: 'Additional Information',
slug: 'additional-information',
subcategories: [
{
name: '',
properties: [
{
title: '',
component: CellComponent.ArticleAdditionalInfoCell,
objectMapping: {
infos: 'AdditionalArticleInfos.{language}.Elements',
},
},
],
},
],
},
{
name: 'Links',
slug: 'links',
subcategories: [
{
name: '',
properties: [
{
title: '',
component: CellComponent.ArticleLinkInfoCell,
objectMapping: {
links: 'ArticleLinkInfo.{language}.Elements',
},
},
],
},
],
},
tagCategory('article'),
{
name: 'Article Details',
slug: 'article-details',
subcategories: [
{
name: '',
properties: [
{
title: 'Highlight',
component: CellComponent.ToggleTriStateCell,
objectMapping: { enabled: 'Highlight' },
},
{
title: '',
component: CellComponent.ArticleTypeCell,
objectMapping: {
type: 'Type',
subType: 'SubType',
},
params: {
lookupUrl: withOdhBaseUrl('/v1/ArticleTypes'),
required: 'true',
},
required: true,
},
{
title: 'Article Date',
component: CellComponent.DateCell,
objectMapping: { date: 'ArticleDate' },
params: { format: DEFAULT_DATE_FORMAT },
},
{
title: 'Article Date To',
component: CellComponent.DateCell,
objectMapping: { date: 'ArticleDateTo' },
params: { format: DEFAULT_DATE_FORMAT },
},
],
},
],
},
licenseInfoCategory(),
mappingCategory(),
],
});
13 changes: 13 additions & 0 deletions databrowser/src/config/tourism/noinews/noinews.views.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

import { noinewsListView } from './noinews.listView';
import { noinewsSharedView } from './noinews.sharedView';

export const noinewsViews = {
table: noinewsListView,
detail: noinewsSharedView(),
edit: noinewsSharedView(),
new: noinewsSharedView(),
};

0 comments on commit d41f169

Please sign in to comment.