From 5c34266b73fc83cab754603899b1821b547c4c52 Mon Sep 17 00:00:00 2001 From: Fabien Taillon Date: Mon, 18 Jan 2021 10:55:03 +0100 Subject: [PATCH] Added StatusCategory flag for ContractStatus --- README.md | 43 ++++++++++--------- messages/contractstatus-value-add.json | 3 +- package.json | 2 +- .../texei/contractstatus/value/add.ts | 5 ++- src/shared/standardValueSetHelper.ts | 13 +++--- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 09ad5cf..543716f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Install npm modules: npm install Link the plugin: sfdx plugins:link . -* [`sfdx texei:contractstatus:value:add -l -a [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeicontractstatusvalueadd--l-string--a-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal) +* [`sfdx texei:contractstatus:value:add -l -a [-s ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeicontractstatusvalueadd--l-string--a-string--s-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal) * [`sfdx texei:data:export -d [-o ] [-p ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeidataexport--d-string--o-string--p-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal) * [`sfdx texei:data:import -d [-a] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeidataimport--d-string--a--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal) * [`sfdx texei:data:plan:generate -d -o [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeidataplangenerate--d-string--o-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal) @@ -37,14 +37,14 @@ Link the plugin: sfdx plugins:link . * [`sfdx texei:source:layouts:cleanorg [-p ] [-v ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeisourcelayoutscleanorg--p-string--v-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal) * [`sfdx texei:user:update [-v ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`](#sfdx-texeiuserupdate--v-string--u-string---apiversion-string---json---loglevel-tracedebuginfowarnerrorfataltracedebuginfowarnerrorfatal) -## `sfdx texei:contractstatus:value:add -l -a [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` +## `sfdx texei:contractstatus:value:add -l -a [-s ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` add a value to Contract Status picklist ``` USAGE - $ sfdx texei:contractstatus:value:add -l -a [-u ] [--apiversion ] [--json] - [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] + $ sfdx texei:contractstatus:value:add -l -a [-s ] [-u ] [--apiversion ] + [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] OPTIONS -a, --apiname=apiname (required) API Name of the Contract @@ -53,6 +53,9 @@ OPTIONS -l, --label=label (required) label of the Contract Status value to add + -s, --statuscategory=Draft|Activated|InApprovalProcess [default: Draft] Status Category of + the Contract Status value to add + -u, --targetusername=targetusername username or alias for the target org; overrides default target org @@ -69,7 +72,7 @@ EXAMPLE --targetusername texei ``` -_See code: [src/commands/texei/contractstatus/value/add.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/contractstatus/value/add.ts)_ +_See code: [src/commands/texei/contractstatus/value/add.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/contractstatus/value/add.ts)_ ## `sfdx texei:data:export -d [-o ] [-p ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -105,7 +108,7 @@ EXAMPLES sfdx texei:data:export --dataplan ./data/data-plan.json --outputdir ./data --targetusername texei ``` -_See code: [src/commands/texei/data/export.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/data/export.ts)_ +_See code: [src/commands/texei/data/export.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/data/export.ts)_ ## `sfdx texei:data:import -d [-a] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -140,7 +143,7 @@ EXAMPLE Data imported! ``` -_See code: [src/commands/texei/data/import.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/data/import.ts)_ +_See code: [src/commands/texei/data/import.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/data/import.ts)_ ## `sfdx texei:data:plan:generate -d -o [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -167,7 +170,7 @@ EXAMPLE $ sfdx texei:data:plan:generate --objects Account,Contact,MyCustomObject__c --outputdir ./data ``` -_See code: [src/commands/texei/data/plan/generate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/data/plan/generate.ts)_ +_See code: [src/commands/texei/data/plan/generate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/data/plan/generate.ts)_ ## `sfdx texei:org:contractfieldhistory:fix [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -195,7 +198,7 @@ EXAMPLE History tracking fixed. ``` -_See code: [src/commands/texei/org/contractfieldhistory/fix.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/org/contractfieldhistory/fix.ts)_ +_See code: [src/commands/texei/org/contractfieldhistory/fix.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/org/contractfieldhistory/fix.ts)_ ## `sfdx texei:org:shape:extract [-d ] [-s ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -230,7 +233,7 @@ EXAMPLE $ sfdx texei:org:shape:extract -u bulma@capsulecorp.com" ``` -_See code: [src/commands/texei/org/shape/extract.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/org/shape/extract.ts)_ +_See code: [src/commands/texei/org/shape/extract.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/org/shape/extract.ts)_ ## `sfdx texei:package:dependencies:install [-k ] [-b ] [-p ] [-s ] [-n ] [-w ] [-r] [-a ] [-v ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -293,7 +296,7 @@ EXAMPLE $ texei:package:dependencies:install -u MyScratchOrg -v MyDevHub -k "1:MyPackage1Key 2: 3:MyPackage3Key" -b "DEV" ``` -_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/package/dependencies/install.ts)_ +_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/package/dependencies/install.ts)_ ## `sfdx texei:profile:clean [-k ] [-p ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -327,7 +330,7 @@ EXAMPLES custom-sfdx-source-folder/main/profiles,source-folder-2/main/profiles/myAdmin.profile-meta.xml ``` -_See code: [src/commands/texei/profile/clean.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/profile/clean.ts)_ +_See code: [src/commands/texei/profile/clean.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/profile/clean.ts)_ ## `sfdx texei:sharedactivities:enable [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -354,7 +357,7 @@ EXAMPLE $ sfdx texei:sharedactivities:enable ``` -_See code: [src/commands/texei/sharedactivities/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharedactivities/enable.ts)_ +_See code: [src/commands/texei/sharedactivities/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharedactivities/enable.ts)_ ## `sfdx texei:sharingcalc:recalculate [-s ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -385,7 +388,7 @@ EXAMPLE Recalculated Sharing Rules ``` -_See code: [src/commands/texei/sharingcalc/recalculate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharingcalc/recalculate.ts)_ +_See code: [src/commands/texei/sharingcalc/recalculate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharingcalc/recalculate.ts)_ ## `sfdx texei:sharingcalc:resume [-s ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -416,7 +419,7 @@ EXAMPLE Sharing calculations resumed ``` -_See code: [src/commands/texei/sharingcalc/resume.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharingcalc/resume.ts)_ +_See code: [src/commands/texei/sharingcalc/resume.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharingcalc/resume.ts)_ ## `sfdx texei:sharingcalc:suspend [-s ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -447,7 +450,7 @@ EXAMPLE Sharing calculations suspended ``` -_See code: [src/commands/texei/sharingcalc/suspend.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/sharingcalc/suspend.ts)_ +_See code: [src/commands/texei/sharingcalc/suspend.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/sharingcalc/suspend.ts)_ ## `sfdx texei:skinnyprofile:retrieve [-t ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -477,7 +480,7 @@ EXAMPLE $ texei:skinnyprofile:retrieve -u MyScratchOrg ``` -_See code: [src/commands/texei/skinnyprofile/retrieve.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/skinnyprofile/retrieve.ts)_ +_See code: [src/commands/texei/skinnyprofile/retrieve.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/skinnyprofile/retrieve.ts)_ ## `sfdx texei:source:customlabel:replace -l -v [-p ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -501,7 +504,7 @@ EXAMPLE $ texei:source:customlabel:replace --label GreatSalesforceBlog --value https://blog.texei.com ``` -_See code: [src/commands/texei/source/customlabel/replace.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/source/customlabel/replace.ts)_ +_See code: [src/commands/texei/source/customlabel/replace.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/source/customlabel/replace.ts)_ ## `sfdx texei:source:layouts:cleanorg [-p ] [-v ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -534,7 +537,7 @@ EXAMPLES $ texei:source:layouts:cleanorg --targetusername myScratchOrg --targetdevhubusername myDevHub ``` -_See code: [src/commands/texei/source/layouts/cleanorg.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/source/layouts/cleanorg.ts)_ +_See code: [src/commands/texei/source/layouts/cleanorg.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/source/layouts/cleanorg.ts)_ ## `sfdx texei:user:update [-v ] [-u ] [--apiversion ] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]` @@ -567,5 +570,5 @@ EXAMPLES sfdx texei:user:update --values "LanguageLocaleKey=en_US UserPermissionsMarketingUser=true" --json ``` -_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.2/src/commands/texei/user/update.ts)_ +_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.9.3/src/commands/texei/user/update.ts)_ diff --git a/messages/contractstatus-value-add.json b/messages/contractstatus-value-add.json index 319fafa..d4b56a2 100644 --- a/messages/contractstatus-value-add.json +++ b/messages/contractstatus-value-add.json @@ -1,5 +1,6 @@ { "commandDescription": "add a value to Contract Status picklist", "labelFlagDescription": "label of the Contract Status value to add", - "apiNameFlagDescription": "API Name of the Contract Status value to add" + "apiNameFlagDescription": "API Name of the Contract Status value to add", + "statusCategoryFlagDescription": "Status Category of the Contract Status value to add" } \ No newline at end of file diff --git a/package.json b/package.json index 9b2f810..28de26f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "texei-sfdx-plugin", "description": "Texeï's plugin for sfdx", - "version": "1.9.2", + "version": "1.9.3", "author": "Texeï", "bugs": "https://github.com/https://github.com/texei/texei-sfdx-plugin/issues", "dependencies": { diff --git a/src/commands/texei/contractstatus/value/add.ts b/src/commands/texei/contractstatus/value/add.ts index 431bff9..8588b9b 100644 --- a/src/commands/texei/contractstatus/value/add.ts +++ b/src/commands/texei/contractstatus/value/add.ts @@ -20,7 +20,8 @@ export default class Add extends SfdxCommand { protected static flagsConfig = { label: flags.string({char: 'l', description: messages.getMessage('labelFlagDescription'), required: true}), - apiname: flags.string({char: 'a', description: messages.getMessage('apiNameFlagDescription'), required: true}) + apiname: flags.string({char: 'a', description: messages.getMessage('apiNameFlagDescription'), required: true}), + statuscategory: flags.string({char: 's', description: messages.getMessage('statusCategoryFlagDescription'), options: ['Draft','Activated','InApprovalProcess'], default: 'Draft', required: false}) }; // Comment this out if your command does not require an org username @@ -37,7 +38,7 @@ export default class Add extends SfdxCommand { this.ux.startSpinner(`Adding ContractStatus value (${this.flags.label}/${this.flags.apiname})`, null, { stdout: true }); const svsh = new StandardValueSetHelper(this.org.getConnection(), 'ContractStatus'); - await svsh.addValue(this.flags.label, this.flags.apiname); + await svsh.addValue(this.flags.label, this.flags.apiname, this.flags.statuscategory); await svsh.close(); this.ux.stopSpinner('Done.'); diff --git a/src/shared/standardValueSetHelper.ts b/src/shared/standardValueSetHelper.ts index 38f9d6e..1bc16a3 100644 --- a/src/shared/standardValueSetHelper.ts +++ b/src/shared/standardValueSetHelper.ts @@ -5,14 +5,11 @@ const standardValueSetPaths = new Map([ ['ContractStatus', '/_ui/common/config/field/StandardFieldAttributes/d?id=Status&type=Contract'] ]); -// TODO: look how to handle languages -/* const contractStatusCategory = new Map([ - ['D', 'Draft'], - ['A', 'Activated'], - ['P', 'In Approval Process'] + ['Draft', 'D'], + ['Activated', 'A'], + ['InApprovalProcess', 'P'] ]); -*/ export class StandardValueSetHelper { @@ -53,7 +50,7 @@ export class StandardValueSetHelper { } } - public async addValue(label: string, apiName: string): Promise { + public async addValue(label: string, apiName: string, statusCategory: string): Promise { if (!this.browser) { await this.init(); @@ -93,7 +90,7 @@ export class StandardValueSetHelper { // TODO: Handle other Category than Draft await this.page.waitForSelector('tbody #p5'); await this.page.click('tbody #p5'); - await this.page.select('tbody #p5', 'D'); + await this.page.select('tbody #p5', contractStatusCategory.get(statusCategory)); } // Click Save