Skip to content

Commit 4e32570

Browse files
authored
Merge pull request #243 from os2display/feature/4573-resource-name-in-selector
Changed resource name in calendar api feed type resource selector
2 parents d7426e8 + f736c48 commit 4e32570

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
- [#243](https://github.com/os2display/display-api-service/pull/243)
8+
- Changed resource name in calendar api feed type resource selector.
79
- [#242](https://github.com/os2display/display-api-service/pull/242)
810
- Changed calendar api feed type to use display name from resources feed instead of events feed.
911

docs/feed/calender-api-feed.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ By default, the three endpoints should return data as follows:
3838
{
3939
"id": "Resource Id 1",
4040
"locationId": "Location Id 1",
41+
"name": "Resource-1",
4142
"displayName": "Resource 1",
4243
"includedInEvents": true
4344
},
4445
{
4546
"id": "Resource Id 2",
4647
"locationId": "Location Id 1",
48+
"name": "Resource-2",
4749
"displayName": "Resource 2",
4850
"includedInEvents": false
4951
}
@@ -52,7 +54,8 @@ By default, the three endpoints should return data as follows:
5254

5355
* The `id` (Mapping key: RESOURCE_ID) should be unique for the resource.
5456
* The `locationId` (Mapping key: RESOURCE_LOCATION_ID) is the id of the location the resource belongs to.
55-
* The `displayName` (Mapping key: RESOURCE_DISPLAY_NAME) is the name the resource is presented by in templates and admin.
57+
* The `name` (Mapping key: RESOURCE_NAME) is the name the resource is presented by in the admin selector.
58+
* The `displayName` (Mapping key: RESOURCE_DISPLAY_NAME) is the name the resource is presented by in templates.
5659
* The `includedInEvents` (Mapping key: RESOURCE_INCLUDED_IN_EVENTS) determines if the resource is included in the events
5760
endpoint.
5861
This property can be excluded in the data. If this is the case, it defaults to `true`.
@@ -102,6 +105,7 @@ CALENDAR_API_FEED_SOURCE_CUSTOM_MAPPINGS='{
102105
"LOCATION_DISPLAY_NAME": "Example2",
103106
"RESOURCE_ID": "Example3",
104107
"RESOURCE_LOCATION_ID": "Example4",
108+
"RESOURCE_NAME": "Example12",
105109
"RESOURCE_DISPLAY_NAME": "Example5",
106110
"RESOURCE_INCLUDED_IN_EVENTS": "Example6",
107111
"EVENT_TITLE": "Example7",

src/Feed/CalendarApiFeedType.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin
228228

229229
$resourceOptions = array_map(fn (Resource $resource) => [
230230
'id' => Ulid::generate(),
231-
'title' => $resource->displayName,
231+
'title' => $resource->name.' ('.$resource->displayName.')',
232232
'value' => $resource->id,
233233
], $resources);
234234

@@ -372,6 +372,7 @@ private function loadResources(): array
372372

373373
$resource = new Resource(
374374
$id,
375+
$resourceEntry[$this->getMapping('resourceName')],
375376
$resourceEntry[$this->getMapping('resourceLocationId')],
376377
$resourceEntry[$this->getMapping('resourceDisplayName')],
377378
);
@@ -485,6 +486,7 @@ private function createMappings(array $customMappings): array
485486
'locationDisplayName' => $customMappings['LOCATION_DISPLAY_NAME'] ?? 'displayName',
486487
'resourceId' => $customMappings['RESOURCE_ID'] ?? 'id',
487488
'resourceLocationId' => $customMappings['RESOURCE_LOCATION_ID'] ?? 'locationId',
489+
'resourceName' => $customMappings['RESOURCE_NAME'] ?? 'name',
488490
'resourceDisplayName' => $customMappings['RESOURCE_DISPLAY_NAME'] ?? 'displayName',
489491
'resourceIncludedInEvents' => $customMappings['RESOURCE_INCLUDED_IN_EVENTS'] ?? 'includedInEvents',
490492
'eventTitle' => $customMappings['EVENT_TITLE'] ?? 'title',

src/Feed/OutputModel/Calendar/Resource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Resource
88
{
99
public function __construct(
1010
public string $id,
11+
public string $name,
1112
public string $locationId,
1213
public string $displayName,
1314
) {}

0 commit comments

Comments
 (0)