mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
Added an API to get the cards for a specific custom field value
This commit is contained in:
parent
1cfb6eee4b
commit
c9a28db3ab
2 changed files with 51 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ const JSZip = require('jszip');
|
||||||
|
|
||||||
window.ExportHtml = Popup => {
|
window.ExportHtml = Popup => {
|
||||||
const saveAs = function(blob, filename) {
|
const saveAs = function(blob, filename) {
|
||||||
let dl = document.createElement('a');
|
const dl = document.createElement('a');
|
||||||
dl.href = window.URL.createObjectURL(blob);
|
dl.href = window.URL.createObjectURL(blob);
|
||||||
dl.onclick = event => document.body.removeChild(event.target);
|
dl.onclick = event => document.body.removeChild(event.target);
|
||||||
dl.style.display = 'none';
|
dl.style.display = 'none';
|
||||||
|
|
|
||||||
|
|
@ -1276,9 +1276,9 @@ Cards.mutations({
|
||||||
if (lastCardDom) sortIndex = Utils.calculateIndex(lastCardDom, null).base;
|
if (lastCardDom) sortIndex = Utils.calculateIndex(lastCardDom, null).base;
|
||||||
|
|
||||||
return this.moveOptionalArgs({
|
return this.moveOptionalArgs({
|
||||||
boardId: boardId,
|
boardId,
|
||||||
swimlaneId: swimlaneId,
|
swimlaneId,
|
||||||
listId: listId,
|
listId,
|
||||||
sort: sortIndex,
|
sort: sortIndex,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -1293,8 +1293,7 @@ Cards.mutations({
|
||||||
swimlaneId = board.getDefaultSwimline()._id;
|
swimlaneId = board.getDefaultSwimline()._id;
|
||||||
}
|
}
|
||||||
listId = listId || this.listId;
|
listId = listId || this.listId;
|
||||||
if (sort === undefined || sort === null)
|
if (sort === undefined || sort === null) sort = this.sort;
|
||||||
sort = this.sort;
|
|
||||||
return this.move(boardId, swimlaneId, listId, sort);
|
return this.move(boardId, swimlaneId, listId, sort);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -2683,6 +2682,52 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @operation get_cards_by_custom_field
|
||||||
|
* @summary Get all Cards that matchs a value of a specific custom field
|
||||||
|
*
|
||||||
|
* @param {string} boardId the board ID
|
||||||
|
* @param {string} customFieldId the list ID
|
||||||
|
* @param {string} customFieldValue the value to look for
|
||||||
|
* @return_type [{_id: string,
|
||||||
|
* title: string,
|
||||||
|
* description: string,
|
||||||
|
* listId: string
|
||||||
|
* swinlaneId: string}]
|
||||||
|
*/
|
||||||
|
JsonRoutes.add(
|
||||||
|
'GET',
|
||||||
|
'/api/boards/:boardId/cardsByCustomField/:customFieldId/:customFieldValue',
|
||||||
|
function(req, res) {
|
||||||
|
const paramBoardId = req.params.boardId;
|
||||||
|
const paramCustomFieldId = req.params.customFieldId;
|
||||||
|
const paramCustomFieldValue = req.params.customFieldValue;
|
||||||
|
|
||||||
|
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: Cards.find({
|
||||||
|
boardId: paramBoardId,
|
||||||
|
customFields: {
|
||||||
|
$elemMatch: {
|
||||||
|
_id: paramCustomFieldId,
|
||||||
|
value: paramCustomFieldValue,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
archived: false,
|
||||||
|
}).map(function(doc) {
|
||||||
|
return {
|
||||||
|
_id: doc._id,
|
||||||
|
title: doc.title,
|
||||||
|
description: doc.description,
|
||||||
|
listId: doc.listId,
|
||||||
|
swinlaneId: doc.swinlaneId,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Cards;
|
export default Cards;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue