mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Removed hardcoded code (as it is likely to change and formatting/coloring is bad here) and added examples according to the Cards page.
parent
7c5798e334
commit
95efc814ee
1 changed files with 43 additions and 85 deletions
|
|
@ -1,96 +1,54 @@
|
|||
## Retrieve cards by swimlane id
|
||||
# Disclaimer
|
||||
|
||||
This page tries to be as up to date as possible. If you see something wrong here, feel free to update the page and help other people like you, that greatly depends on our APIs. If you don't feel comfortable doing this kind of changes, please contact us by creating an [issue](https://github.com/wekan/wekan/issues/new).
|
||||
|
||||
# Retrieve cards by swimlane id
|
||||
|
||||
Please somebody add example by looking this:
|
||||
|
||||
[Issue](https://github.com/wekan/wekan/issues/1934) and [code](https://github.com/wekan/wekan/pull/1944/commits/be42b8d4cbdfa547ca019ab2dc9a590a115cc0e2). Also add to [Cards page](https://github.com/wekan/wekan/wiki/REST-API-Cards).
|
||||
[Issue](https://github.com/wekan/wekan/issues/1934) and [code](https://github.com/wekan/wekan/pull/1944/commits/be42b8d4cbdfa547ca019ab2dc9a590a115cc0e2). Also add to [Cards page](https://github.com/wekan/wekan/wiki/REST-API-Cards)
|
||||
|
||||
## In Wekan code
|
||||
# Add Swimlane to Board
|
||||
|
||||
wekan/models/swimlanes.js at bottom:
|
||||
| API URL / Code Link | Requires Admin Auth | HTTP Method |
|
||||
| :--- | :--- | :--- |
|
||||
| [/api/boards/:boardId/swimlanes](https://github.com/wekan/wekan/blob/master/models/swimlanes.js#L223) | `yes` | `POST` |
|
||||
|
||||
```shell
|
||||
curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \
|
||||
-H "Content-type:application/json" \
|
||||
-X POST \
|
||||
http://localhost:3000/api/boards/YRgy7Ku6uLFv2pYwZ/swimlanes \
|
||||
-d '{ "title": "Swimlane title text" }'
|
||||
```
|
||||
JsonRoutes.add('GET', '/api/boards/:boardId/swimlanes', function (req, res) {
|
||||
try {
|
||||
const paramBoardId = req.params.boardId;
|
||||
Authentication.checkBoardAccess( req.userId, paramBoardId);
|
||||
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: Swimlanes.find({ boardId: paramBoardId, archived: false }).map(function (doc) {
|
||||
return {
|
||||
_id: doc._id,
|
||||
title: doc.title,
|
||||
};
|
||||
}),
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
JsonRoutes.add('GET', '/api/boards/:boardId/swimlanes/:swimlaneId', function (req, res) {
|
||||
try {
|
||||
const paramBoardId = req.params.boardId;
|
||||
const paramSwimlaneId = req.params.swimlaneId;
|
||||
Authentication.checkBoardAccess( req.userId, paramBoardId);
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: Swimlanes.findOne({ _id: paramSwimlaneId, boardId: paramBoardId, archived: false }),
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
JsonRoutes.add('POST', '/api/boards/:boardId/swimlanes', function (req, res) {
|
||||
try {
|
||||
Authentication.checkUserId( req.userId);
|
||||
const paramBoardId = req.params.boardId;
|
||||
const id = Swimlanes.insert({
|
||||
title: req.body.title,
|
||||
boardId: paramBoardId,
|
||||
});
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: {
|
||||
_id: id,
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
JsonRoutes.add('DELETE', '/api/boards/:boardId/swimlanes/:swimlaneId', function (req, res) {
|
||||
try {
|
||||
Authentication.checkUserId( req.userId);
|
||||
const paramBoardId = req.params.boardId;
|
||||
const paramSwimlaneId = req.params.swimlaneId;
|
||||
Swimlanes.remove({ _id: paramSwimlaneId, boardId: paramBoardId });
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: {
|
||||
_id: paramSwimlaneId,
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
JsonRoutes.sendResult(res, {
|
||||
code: 200,
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
});
|
||||
## Result example
|
||||
The new swimlane's ID is returned in the format:
|
||||
```json
|
||||
{
|
||||
"_id": "W9m9YxQKT6zZrKzRW"
|
||||
}
|
||||
```
|
||||
|
||||
# Delete a swimlane
|
||||
|
||||
| API URL / Code Link | Requires Admin Auth | HTTP Method |
|
||||
| :--- | :--- | :--- |
|
||||
| [/api/boards/:boardId/swimlanes/:swimlaneId](https://github.com/wekan/wekan/blob/master/models/swimlanes.js#L257) | `yes` | `DELETE` |
|
||||
|
||||
```shell
|
||||
curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \
|
||||
-H "Content-type:application/json" \
|
||||
-X DELETE \
|
||||
http://localhost:3000/api/boards/YRgy7Ku6uLFv2pYwZ/lists/PgTuf6sFJsaxto5dC/cards/ssrNX9CvXvPxuC5DE
|
||||
```
|
||||
## Result example
|
||||
The swimlane's ID is returned in the format:
|
||||
```json
|
||||
{
|
||||
"_id": "W9m9YxQKT6zZrKzRW"
|
||||
}
|
||||
```
|
||||
|
||||
# In Wekan code
|
||||
|
||||
If you believe that code is the best documentation, be our guest: [models/cards.js](https://github.com/wekan/wekan/blob/devel/models/swimlanes.js "Swimlane API code")
|
||||
Loading…
Add table
Add a link
Reference in a new issue