Migrated visualID's tag related routes
MODIFY
src/server/rest/v1/router/api/TagRouter.ts
src/server/rest/v1/router/api/TagRouter.ts
@@ -19,14 +19,22 @@ export default class TagRouter {
this.buildRouteDeleteTag();
this.buildRouteDeleteTags();
this.buildRouteUpdateTag();
+ this.buildRouteUpdateTagByVisualID();
this.buildRouteImportTag();
this.buildRouteExportTag();
+ this.buildRouteAssignTag();
+ this.buildRouteUnassignTag();
+ this.buildRouteUnassignTags();
return this.router;
}
private buildRouteTags(): void {
this.router.get(`/${ServerRoute.REST_TAGS}`, async (req: Request, res: Response, next: NextFunction) => {
+ if (req.query.VisualID) {
+ await RouterUtils.handleServerAction(TagService.handleGetTagByVisualID.bind(this), ServerAction.TAG_BY_VISUAL_ID, req, res, next);
+ } else {
await RouterUtils.handleServerAction(TagService.handleGetTags.bind(this), ServerAction.TAGS, req, res, next);
+ }
});
}
@@ -63,6 +71,12 @@ export default class TagRouter {
});
}
+ private buildRouteUpdateTagByVisualID(): void {
+ this.router.put(`/${ServerRoute.REST_TAGS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TagService.handleUpdateTagByVisualID.bind(this), ServerAction.TAG_UPDATE_BY_VISUAL_ID, req, res, next);
+ });
+ }
+
private buildRouteImportTag(): void {
this.router.post(`/${ServerRoute.REST_TAGS_IMPORT}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(TagService.handleImportTags.bind(this), ServerAction.TAGS_IMPORT, req, res, next);
@@ -74,4 +88,22 @@ export default class TagRouter {
await RouterUtils.handleServerAction(TagService.handleExportTags.bind(this), ServerAction.TAGS_EXPORT, req, res, next);
});
}
+
+ private buildRouteAssignTag(): void {
+ this.router.put(`/${ServerRoute.REST_TAG_ASSIGN}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TagService.handleAssignTag.bind(this), ServerAction.TAG_ASSIGN, req, res, next);
+ });
+ }
+
+ private buildRouteUnassignTag(): void {
+ this.router.put(`/${ServerRoute.REST_TAG_UNASSIGN}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TagService.handleUnassignTag.bind(this), ServerAction.TAG_UNASSIGN, req, res, next);
+ });
+ }
+
+ private buildRouteUnassignTags(): void {
+ this.router.put(`/${ServerRoute.REST_TAGS_UNASSIGN}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TagService.handleUnassignTags.bind(this), ServerAction.TAGS_UNASSIGN, req, res, next);
+ });
+ }
}

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -275,7 +275,7 @@ export default class TagService {
public static async handleUpdateTagByVisualID(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = TagValidator.getInstance().validateTagVisualIDUpdateReq({ ...req.params, ...req.body });
+ const filteredRequest = TagValidator.getInstance().validateTagVisualIDUpdateReq(req.body);
// Check and Get Tag
const tag = await UtilsService.checkAndGetTagByVisualIDAuthorization(req.tenant, req.user, filteredRequest.visualID, Action.UPDATE_BY_VISUAL_ID, action,
filteredRequest, { withNbrTransactions: true, withUser: true });

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -538,6 +538,9 @@ export enum ServerRoute {
REST_TAGS = 'tags',
REST_TAG = 'tags/:id',
+ REST_TAG_ASSIGN = 'tags/:id/assign',
+ REST_TAG_UNASSIGN = 'tags/:id/unassign',
+ REST_TAGS_UNASSIGN = 'tags/unassign',
REST_TAGS_IMPORT = 'tags/action/import',
REST_TAGS_EXPORT = 'tags/action/export',

MODIFY
test/api/client/TagApi.ts
test/api/client/TagApi.ts
@@ -33,7 +33,7 @@ export default class TagApi extends CrudApi {
}
public async readTagByVisualID(visualID) {
- return super.read({ VisualID: visualID }, '/client/api/TagByVisualID');
+ return super.read({ VisualID: visualID }, this.buildRestEndpointUrl(ServerRoute.REST_TAGS));
}
public async createTag(data) {

Migrated visualID's tag related routes