-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Dealcloud components initial merge #19233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5fdb40c
Adding DealCloud app and package
GTFalcao 9485f56
Adding listEntryTypes
GTFalcao a464c81
Adding initial field-to-prop conversion
GTFalcao 7ddafaf
pnpm
GTFalcao dfbe0af
Fetching entries and parsing option-based props
GTFalcao 195aede
adding mocked data for testing
GTFalcao 8db8dee
Adding 'get records' and 'delete records' actions
GTFalcao cdebe41
Fixing mocked versions of get and delete record
GTFalcao 33b6e61
'Create Record' action and basic stuff
GTFalcao 2abbb3c
Removing dynamic options (for now)
GTFalcao 32c3e57
Adding 'update record' + patches
GTFalcao 60384b9
Minor patches
GTFalcao 27c8c4c
Merge branch 'master' into dealcloud-new-components
GTFalcao 8f405bb
Removing mock data
GTFalcao fbbf4d3
Adjusting component versions
GTFalcao 60e267c
minor fixes
GTFalcao e083ab6
Merge branch 'dealcloud-new-components' into dealcloud-components-ini…
GTFalcao 6f7c73f
Minor adjustments
GTFalcao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
components/dealcloud/actions/common/common-create-update.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { convertFieldsToProps } from "../../common/utils.mjs"; | ||
| import dealcloud from "../../dealcloud.app.mjs"; | ||
|
|
||
| export default { | ||
| methods: { | ||
| convertFieldsToProps, | ||
| isUpdate() { | ||
| return false; | ||
| }, | ||
| getEntryId() { | ||
| return -1; | ||
| }, | ||
| getRequestData(props) { | ||
| return { | ||
| storeRequests: Object.entries(props).map(([ | ||
| key, | ||
| value, | ||
| ]) => { | ||
| const fieldId = Number(key.split("_")[1]); | ||
| return { | ||
| entryId: this.getEntryId(), | ||
| fieldId, | ||
| ignoreNearDups: this.ignoreNearDups, | ||
| value, | ||
| }; | ||
| }), | ||
| }; | ||
| }, | ||
| }, | ||
| props: { | ||
| dealcloud, | ||
| entryTypeId: { | ||
| propDefinition: [ | ||
| dealcloud, | ||
| "entryTypeId", | ||
| ], | ||
| reloadProps: true, | ||
| }, | ||
| ignoreNearDups: { | ||
| propDefinition: [ | ||
| dealcloud, | ||
| "ignoreNearDups", | ||
| ], | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| if (!this.entryTypeId) { | ||
| return props; | ||
| } | ||
| const fields = await this.dealcloud.getEntryTypeFields({ | ||
| entryTypeId: this.entryTypeId, | ||
| }); | ||
| return this.convertFieldsToProps(fields); | ||
| }, | ||
| }; | ||
|
|
||
40 changes: 40 additions & 0 deletions
40
components/dealcloud/actions/create-record/create-record.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import commonCreateUpdate from "../common/common-create-update.mjs"; | ||
|
|
||
| export default { | ||
| ...commonCreateUpdate, | ||
| key: "dealcloud-create-record", | ||
| name: "Create Record", | ||
| description: "Creates a new record (entry) in DealCloud. [See the documentation](https://api.docs.dealcloud.com/docs/data/cells/postput)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async run({ $ }) { | ||
| /* eslint-disable no-unused-vars */ | ||
| const { | ||
| dealcloud, | ||
| entryTypeId, | ||
| ignoreNearDups, | ||
| convertFieldsToProps, | ||
| isUpdate, | ||
| getEntryId, | ||
| getRequestData, | ||
| ...props | ||
| } = this; | ||
| /* eslint-enable no-unused-vars */ | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const response = await dealcloud.createEntry({ | ||
| $, | ||
| entryTypeId, | ||
| data: this.getRequestData(props), | ||
| }); | ||
|
|
||
| $.export("$summary", "Successfully created record"); | ||
| // add id to summary when we know the response schema | ||
| return response; | ||
| }, | ||
| }; | ||
|
|
||
51 changes: 51 additions & 0 deletions
51
components/dealcloud/actions/delete-records/delete-records.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { checkIdArray } from "../../common/utils.mjs"; | ||
| import app from "../../dealcloud.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "dealcloud-delete-records", | ||
| name: "Delete Record(s)", | ||
| description: "Deletes one or more records (entries) from DealCloud. [See the documentation](https://api.docs.dealcloud.com/docs/data/delete)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: true, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| app, | ||
| entryTypeId: { | ||
| propDefinition: [ | ||
| app, | ||
| "entryTypeId", | ||
| ], | ||
| }, | ||
| entryIds: { | ||
| propDefinition: [ | ||
| app, | ||
| "entryId", | ||
| ({ entryTypeId }) => ({ | ||
| entryTypeId, | ||
| }), | ||
| ], | ||
| type: "integer[]", | ||
| label: "Record ID(s)", | ||
| description: "The ID(s) of one or more records (entries) to delete.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const entryIds = checkIdArray(this.entryIds).map(Number); | ||
| const response = await this.app.deleteEntry({ | ||
| $, | ||
| entryTypeId: this.entryTypeId, | ||
| data: entryIds, | ||
| }); | ||
|
|
||
| const count = response.length; | ||
| $.export("$summary", `Successfully deleted ${count} record${count === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return response; | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { checkIdArray } from "../../common/utils.mjs"; | ||
| import dealcloud from "../../dealcloud.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "dealcloud-get-records", | ||
| name: "Get Record(s)", | ||
| description: "Retrieves one or more records (entries) from DealCloud. [See the documentation](https://api.docs.dealcloud.com/docs/data/rows/get)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: true, | ||
| }, | ||
| props: { | ||
| dealcloud, | ||
| entryTypeId: { | ||
| propDefinition: [ | ||
| dealcloud, | ||
| "entryTypeId", | ||
| ], | ||
| }, | ||
| entryIds: { | ||
| propDefinition: [ | ||
| dealcloud, | ||
| "entryId", | ||
| ({ entryTypeId }) => ({ | ||
| entryTypeId, | ||
| }), | ||
| ], | ||
| type: "integer[]", | ||
| label: "Record ID(s)", | ||
| description: "The ID(s) of one or more records (entries) to retrieve.", | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const entryIds = checkIdArray(this.entryIds); | ||
| const response = await this.dealcloud.queryEntries({ | ||
| $, | ||
| entryTypeId: this.entryTypeId, | ||
| params: { | ||
| query: `{entryid: {$in:[${entryIds.join()}]}}`, | ||
| resolveReferenceUrls: true, | ||
| wrapIntoArrays: true, | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| const count = response.length; | ||
| $.export("$summary", `Successfully retrieved ${count} record${count === 1 | ||
| ? "" | ||
| : "s"}`); | ||
| return response; | ||
| }, | ||
| }; | ||
|
|
||
69 changes: 69 additions & 0 deletions
69
components/dealcloud/actions/update-record/update-record.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import commonCreateUpdate from "../common/common-create-update.mjs"; | ||
|
|
||
| const { | ||
| props: { | ||
| dealcloud, entryTypeId, ignoreNearDups, | ||
| }, | ||
| } = commonCreateUpdate; | ||
|
|
||
| export default { | ||
| ...commonCreateUpdate, | ||
| key: "dealcloud-update-record", | ||
| name: "Update Record", | ||
| description: "Updates a record (entry) in DealCloud. [See the documentation](https://api.docs.dealcloud.com/docs/data/cells/postput)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| props: { | ||
| dealcloud, | ||
| entryTypeId, | ||
| entryId: { | ||
| propDefinition: [ | ||
| dealcloud, | ||
| "entryId", | ||
| ({ entryTypeId }) => ({ | ||
| entryTypeId, | ||
| }), | ||
| ], | ||
| }, | ||
| ignoreNearDups, | ||
| }, | ||
GTFalcao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| methods: { | ||
| ...commonCreateUpdate.methods, | ||
| isUpdate() { | ||
| return true; | ||
| }, | ||
| getEntryId() { | ||
| return this.entryId; | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| /* eslint-disable no-unused-vars */ | ||
| const { | ||
| dealcloud, | ||
| entryTypeId, | ||
| entryId, | ||
| ignoreNearDups, | ||
| convertFieldsToProps, | ||
| isUpdate, | ||
| getEntryId, | ||
| getRequestData, | ||
| ...props | ||
| } = this; | ||
| /* eslint-enable no-unused-vars */ | ||
|
|
||
| const response = await dealcloud.updateEntry({ | ||
| $, | ||
| entryTypeId, | ||
| data: this.getRequestData(props), | ||
| }); | ||
|
|
||
| $.export("$summary", "Successfully updated record"); | ||
| return response; | ||
| }, | ||
| }; | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.