Skip to content

Commit fa7060e

Browse files
committed
Item nav order APIs
1 parent e87478b commit fa7060e

23 files changed

Lines changed: 245 additions & 863 deletions

src/main/api/studio-api.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5451,6 +5451,142 @@ paths:
54515451
'500':
54525452
$ref: '#/components/responses/InternalServerError'
54535453

5454+
/api/2/content/{siteId}/item/next-order:
5455+
get:
5456+
tags:
5457+
- content
5458+
summary: Get the next order value for a new item under a given parent path
5459+
description: 'Required permission "content_read"'
5460+
operationId: getNextItemOrder
5461+
parameters:
5462+
- name: siteId
5463+
in: path
5464+
required: true
5465+
schema:
5466+
type: string
5467+
description: Site ID
5468+
- name: parentPath
5469+
in: query
5470+
required: true
5471+
schema:
5472+
type: string
5473+
description: Parent path
5474+
responses:
5475+
'200':
5476+
description: OK
5477+
content:
5478+
application/json:
5479+
schema:
5480+
type: object
5481+
properties:
5482+
nextOrder:
5483+
type: integer
5484+
'400':
5485+
$ref: '#/components/responses/BadRequest'
5486+
'401':
5487+
$ref: '#/components/responses/Unauthorized'
5488+
'404':
5489+
$ref: '#/components/responses/NotFound'
5490+
'500':
5491+
$ref: '#/components/responses/InternalServerError'
5492+
5493+
/api/2/content/{siteId}/item/orders:
5494+
get:
5495+
tags:
5496+
- content
5497+
summary: Get the existing items order for a given parent path
5498+
description: 'Required permission "content_read"'
5499+
operationId: getItemsOrder
5500+
parameters:
5501+
- name: siteId
5502+
in: path
5503+
required: true
5504+
schema:
5505+
type: string
5506+
description: Site ID
5507+
- name: parentPath
5508+
in: query
5509+
required: true
5510+
schema:
5511+
type: string
5512+
description: Parent path
5513+
responses:
5514+
'200':
5515+
description: OK
5516+
content:
5517+
application/json:
5518+
schema:
5519+
type: array
5520+
items:
5521+
type: object
5522+
properties:
5523+
path:
5524+
type: string
5525+
order:
5526+
type: integer
5527+
label:
5528+
type: string
5529+
'400':
5530+
$ref: '#/components/responses/BadRequest'
5531+
'401':
5532+
$ref: '#/components/responses/Unauthorized'
5533+
'404':
5534+
$ref: '#/components/responses/NotFound'
5535+
'500':
5536+
$ref: '#/components/responses/InternalServerError'
5537+
5538+
/api/2/content/{siteId}/item/reorder:
5539+
post:
5540+
tags:
5541+
- content
5542+
summary: Calculates the order value so the item is placed at the selected location.
5543+
description: 'Required permission "content_read"'
5544+
operationId: reorderItem
5545+
parameters:
5546+
- name: siteId
5547+
in: path
5548+
required: true
5549+
schema:
5550+
type: string
5551+
description: Site ID
5552+
requestBody:
5553+
required: true
5554+
content:
5555+
application/json:
5556+
schema:
5557+
type: object
5558+
properties:
5559+
parentPath:
5560+
type: string
5561+
description: Path of the parent item
5562+
pathBefore:
5563+
type: string
5564+
description: Path of the item before the target location
5565+
pathAfter:
5566+
type: string
5567+
description: Path of the item after the target location
5568+
required:
5569+
- parentPath
5570+
responses:
5571+
'200':
5572+
description: OK
5573+
content:
5574+
application/json:
5575+
schema:
5576+
type: object
5577+
properties:
5578+
order:
5579+
type: integer
5580+
'400':
5581+
$ref: '#/components/responses/BadRequest'
5582+
'401':
5583+
$ref: '#/components/responses/Unauthorized'
5584+
'404':
5585+
$ref: '#/components/responses/NotFound'
5586+
'500':
5587+
$ref: '#/components/responses/InternalServerError'
5588+
5589+
54545590
/api/2/dependency/{siteId}/publish_dependencies:
54555591
post:
54565592
tags:

src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,4 @@ public interface ContentService {
170170

171171
List<DmOrderTO> getItemOrders(String site, String path) throws ContentNotFoundException;
172172

173-
double reorderItems(String site, String relativePath, String before, String after, String orderName)
174-
throws ServiceLayerException;
175-
176173
}

src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ public ResultList<ItemVersion> getHistory(@ValidSiteId @RequestParam(value = REQ
338338

339339
@GetMapping(SITE_HISTORY)
340340
public ResultList<RepositoryVersion> history(@ValidSiteId @PathVariable String siteId,
341-
@NotEmpty @RequestParam(defaultValue = Constants.HEAD) String start,
342-
@Positive @RequestParam(defaultValue = "10") int limit) throws ServiceLayerException {
341+
@NotEmpty @RequestParam(defaultValue = Constants.HEAD) String start,
342+
@Positive @RequestParam(defaultValue = "10") int limit) throws ServiceLayerException {
343343
ResultList<RepositoryVersion> result = new ResultList<>();
344344
result.setEntities(RESULT_KEY_ITEMS, contentService.getHistory(siteId, start, limit));
345345
result.setResponse(OK);
@@ -369,4 +369,31 @@ public Result createFolder(@ValidSiteId @PathVariable String siteId, @Valid @Req
369369
result.setResponse(CREATED);
370370
return result;
371371
}
372+
373+
// Get the order value for a new item under a given parent path
374+
// This will get max existing value for the items under the parent path and add the increment to it
375+
// return a numeric value
376+
@GetMapping(GET_ITEM_NEXT_ORDER)
377+
public Result getNextItemOrder(@ValidSiteId @PathVariable String siteId, @NotEmpty @ValidExistingContentPath @RequestParam String parentPath) {
378+
// TODO
379+
return null;
380+
}
381+
382+
// Get the existing items order for a given parent path
383+
// Return an array of objects with:
384+
// - item path
385+
// - item order value
386+
// - item label
387+
@GetMapping(GET_ITEMS_ORDER)
388+
public Result getItemsOrder(@ValidSiteId @PathVariable String siteId, @NotEmpty @ValidExistingContentPath @RequestParam String parentPath) {
389+
// TODO
390+
return null;
391+
}
392+
393+
// Calculate the order value so the item is placed at the selected location( e.g.: after x and before y)
394+
@PostMapping(REORDER_ITEM)
395+
public Result reorderItem(@ValidSiteId @PathVariable String siteId, @Valid @RequestBody ReorderItemRequest request) {
396+
// TODO
397+
return null;
398+
}
372399
}

src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public final class RequestMappingConstants {
6767
public static final String FOLDER = SITE_ID + "/folder";
6868
public static final String ITEM_HISTORY = "/item_history";
6969
public static final String SITE_HISTORY = SITE_ID + "/history";
70+
public static final String GET_ITEM_NEXT_ORDER = SITE_ID + "/order/next";
71+
public static final String GET_ITEMS_ORDER = SITE_ID + "/order";
72+
public static final String REORDER_ITEM = SITE_ID + "/order/reorder";
7073

7174
/**
7275
* Groups controller

0 commit comments

Comments
 (0)