🌐 AI搜索 & 代理 主页
Skip to content

Commit a11fc13

Browse files
committed
Refactor pagination and update data handling in remote components
- Added a dataKey parameter to the paginate function for flexible data extraction. - Updated references in list-employments and other components to utilize the new dataKey. - Corrected employment ID references in new contract amendment and onboarding sources. - Improved descriptions in custom field value updated source for clarity.
1 parent dabd201 commit a11fc13

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

components/remote/actions/list-employments/list-employments.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
11-
readOnlyHint: false,
11+
readOnlyHint: true,
1212
},
1313
type: "action",
1414
props: {
@@ -51,6 +51,7 @@ export default {
5151
async run({ $ }) {
5252
const response = this.remote.paginate({
5353
$,
54+
dataKey: "employments",
5455
fn: this.remote.listEmployments,
5556
params: {
5657
email: this.email,

components/remote/actions/show-timeoff-balance/show-timeoff-balance.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
11-
readOnlyHint: false,
11+
readOnlyHint: true,
1212
},
1313
type: "action",
1414
props: {

components/remote/remote.app.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default {
104104
});
105105
},
106106
async *paginate({
107-
fn, params = {}, maxResults = null, ...args
107+
fn, params = {}, dataKey = "data", maxResults = null, ...args
108108
}) {
109109
let hasMore = false;
110110
let count = 0;
@@ -114,7 +114,7 @@ export default {
114114
params.page = ++page;
115115
const {
116116
data: {
117-
employments,
117+
[dataKey]: data,
118118
current_page,
119119
total_pages,
120120
},
@@ -123,7 +123,7 @@ export default {
123123
...args,
124124
});
125125

126-
for (const d of employments) {
126+
for (const d of data) {
127127
yield d;
128128

129129
if (maxResults && ++count === maxResults) {

components/remote/sources/new-contract-amendment-done-instant/new-contract-amendment-done-instant.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default {
2121
ts,
2222
}) {
2323
return {
24-
id: body.employment_id,
25-
summary: `Contract amendment for employment with ID ${body.employment_id} has been done`,
24+
id: body.employment_request_id,
25+
summary: `Contract amendment for employment with ID ${body.employment_request_id} has been done`,
2626
ts,
2727
};
2828
},

components/remote/sources/new-custom-field-value-updated-instant/new-custom-field-value-updated-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
...common,
66
key: "remote-new-custom-field-value-updated-instant",
77
name: "New Custom Field Value Updated (Instant)",
8-
description: "Emit new event when a custom field is updated. [See the documentation](https://developer.remote.com/reference/customfieldupdated)",
8+
description: "Emit new event when a custom field is updated. [See the documentation](https://developer.remote.com/reference/custom_fieldvalue_updated)",
99
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",

components/remote/sources/new-employment-onboarding-started-instant/new-employment-onboarding-started-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
...common,
66
key: "remote-new-employment-onboarding-started-instant",
77
name: "New Employment Onboarding Started (Instant)",
8-
description: "Emit new event when a employment onboarding is started. [See the documentation](https://developer.remote.com/reference/employmentonboardingstarted)",
8+
description: "Emit new event when an employment onboarding is started. [See the documentation](https://developer.remote.com/reference/employmentonboardingstarted)",
99
version: "0.0.1",
1010
type: "source",
1111
dedupe: "unique",

0 commit comments

Comments
 (0)