Skip to content

Commit 8e01abb

Browse files
committed
some adjusts
1 parent 31d7221 commit 8e01abb

File tree

6 files changed

+76
-7
lines changed

6 files changed

+76
-7
lines changed

components/google_appsheet/actions/add-row/add-row.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ export default {
44
...common,
55
key: "google_appsheet-add-row",
66
name: "Add Row",
7-
description: "Adds a new row to a specific table in an AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10104797?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA#)",
7+
description: "Adds a new row to a specific table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10104797?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA#)",
88
version: "0.0.1",
99
type: "action",
1010
methods: {
11+
...common.methods,
1112
getAction() {
1213
return "Add";
1314
},

components/google_appsheet/actions/common/base.mjs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,30 @@ export default {
1717
],
1818
},
1919
},
20+
methods: {
21+
getData() {
22+
return {};
23+
},
24+
},
2025
async run({ $ }) {
26+
const dataRow = parseObject(this.row);
27+
const rows = dataRow
28+
? [
29+
dataRow,
30+
]
31+
: [];
32+
2133
const response = await this.appsheet.post({
2234
$,
2335
tableName: this.tableName,
2436
data: {
2537
Action: this.getAction(),
26-
Rows: [
27-
parseObject(this.row),
28-
],
38+
Rows: rows,
39+
...this.getData(),
2940
},
3041
});
42+
console.log("response: ", response);
43+
3144
$.export("$summary", this.getSummary(response));
3245
return response;
3346
},

components/google_appsheet/actions/delete-row/delete-row.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
...common,
55
key: "google_appsheet-delete-row",
66
name: "Delete Row",
7-
description: "Deletes a specific row from a table in an AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10105399?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA)",
7+
description: "Deletes a specific row from a table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10105399?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA)",
88
version: "0.0.1",
99
type: "action",
1010
props: {
@@ -14,8 +14,17 @@ export default {
1414
alertType: "info",
1515
content: "The `Row` value may contain field values of the key field values of the record to be deleted.",
1616
},
17+
row: {
18+
propDefinition: [
19+
common.props.appsheet,
20+
"row",
21+
],
22+
description: "The `Row` value may contain field values of the key field values of the record to be deleted.",
23+
optional: true,
24+
},
1725
},
1826
methods: {
27+
...common.methods,
1928
getAction() {
2029
return "Delete";
2130
},
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import common from "../common/base.mjs";
2+
3+
export default {
4+
...common,
5+
key: "google_appsheet-get-rows",
6+
name: "Get Rows",
7+
description: "Read existing records in a table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10104797?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA#)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
...common.props,
12+
selector: {
13+
type: "string",
14+
label: "Selector",
15+
description: "You can specify an expression to select and format the rows returned. **Example: Filter(TableName, [Column] = \"Value\")** [See the documentation](https://support.google.com/appsheet/answer/10105770?hl=en&ref_topic=10105767&sjid=3242006823758562345-NC)",
16+
optional: true,
17+
},
18+
row: {
19+
propDefinition: [
20+
common.props.appsheet,
21+
"row",
22+
],
23+
description: "You can also filter the results using the `Row` value. The `Row` value may contain field values of the key field values of the record to be retrieved. **Example:** `{ \"First Name\": \"John\" }`",
24+
optional: true,
25+
},
26+
},
27+
methods: {
28+
...common.methods,
29+
getAction() {
30+
return "Find";
31+
},
32+
getData() {
33+
return this.selector
34+
? {
35+
Properties: {
36+
Selector: this.selector,
37+
},
38+
}
39+
: {};
40+
},
41+
getSummary(response) {
42+
return `Successfully retrieved ${ response.length || 0} rows`;
43+
},
44+
},
45+
};

components/google_appsheet/actions/update-row/update-row.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
...common,
55
key: "google_appsheet-update-row",
66
name: "Update Row",
7-
description: "Updates an existing row in a specific table in an AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10105002?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA)",
7+
description: "Updates an existing row in a specific table in the AppSheet app. [See the documentation](https://support.google.com/appsheet/answer/10105002?hl=en&ref_topic=10105767&sjid=1665780.0.1444403316-SA)",
88
version: "0.0.1",
99
type: "action",
1010
props: {
@@ -18,6 +18,7 @@ export default {
1818
},
1919
},
2020
methods: {
21+
...common.methods,
2122
getAction() {
2223
return "Edit";
2324
},

components/google_appsheet/google_appsheet.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
row: {
1313
type: "object",
1414
label: "Row",
15-
description: "JSON object representing the new row data",
15+
description: "JSON object representing the row data",
1616
},
1717
},
1818
methods: {

0 commit comments

Comments
 (0)