Skip to content

Commit 129cbba

Browse files
committed
using services from cds-plugin
This commit shows how to use the defined print services (console and print service) in the cds-plugin.js to use the queries coming from the services that is used depending on the profile
1 parent 1133666 commit 129cbba

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cds-plugin.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,19 @@ cds.once("served", async () => {
4444
// Track the action parameters holding print configurations
4545
await getAnnotatedParamsOfAction(boundAction);
4646
const sourceentity = getQueueValueHelpEntity(boundAction.params);
47+
const printer = await cds.connect.to("print");
4748
if(sourceentity && !queueValueHelpHandlerRegistered) {
48-
srv.after('READ', sourceentity, populateQueueValueHelp);
49+
srv.after('READ', sourceentity, async (_, req) => {
50+
// TODO: make sure the format of all services are the same
51+
const q = await printer.getQueues();
52+
53+
q.forEach((item, index) => {
54+
req.results[index] = { ID: item.ID };
55+
});
56+
req.results.$count = q.length;
57+
return;
58+
59+
});
4960
}
5061
const actionName = boundAction.name.split('.').pop();
5162

@@ -56,4 +67,4 @@ cds.once("served", async () => {
5667
}
5768
}
5869
}
59-
});
70+
});

0 commit comments

Comments
 (0)