googleapis / googleapis/google-api-nodejs-client

Add strong typing for Google Sheet API conditionnal formatting - Type of BooleanRules

Open
#2,605 2 comments 0 reactions 0 assignees View on GitHub
type: feature request
Dominant language
TypeScript
Stars
12.2k
Forks
2k
Avg merge
1d 9h
Merged PRs (30d)
24

Description

Please add strongly type for the condition's types in boolean rules for conditionnal formatting.
Today, it is `string or undefined`:
![image](https://user-images.githubusercontent.com/51024915/115994825-e812d780-a5d8-11eb-8d12-3bd7cb3f8388.png)

below the enum I have created, that may helps

```
enum EGoogleSheetBooleanConditionsTypes {
CONDITION_TYPE_UNSPECIFIED = "CONDITION_TYPE_UNSPECIFIED",
NUMBER_GREATER = "NUMBER_GREATER",
NUMBER_GREATER_THAN_EQ = "NUMBER_GREATER_THAN_EQ",
NUMBER_LESS = "NUMBER_LESS",
NUMBER_LESS_THAN_EQ = "NUMBER_LESS_THAN_EQ",
NUMBER_EQ = "NUMBER_EQ",
NUMBER_NOT_EQ = "NUMBER_NOT_EQ",
NUMBER_BETWEEN = "NUMBER_BETWEEN",
NUMBER_NOT_BETWEEN = "NUMBER_NOT_BETWEEN",
TEXT_CONTAINS = "TEXT_CONTAINS",
TEXT_NOT_CONTAINS = "TEXT_NOT_CONTAINS",
TEXT_STARTS_WITH = "TEXT_STARTS_WITH",
TEXT_ENDS_WITH = "TEXT_ENDS_WITH",
TEXT_EQ = "TEXT_EQ",
TEXT_IS_EMAIL = "TEXT_IS_EMAIL",
TEXT_IS_URL = "TEXT_IS_URL",
DATE_EQ = "DATE_EQ",
DATE_BEFORE = "DATE_BEFORE",
DATE_AFTER = "DATE_AFTER",
DATE_ON_OR_BEFORE = "DATE_ON_OR_BEFORE",
DATE_ON_OR_AFTER = "DATE_ON_OR_AFTER",
DATE_BETWEEN = "DATE_BETWEEN",
DATE_NOT_BETWEEN = "DATE_NOT_BETWEEN",
DATE_IS_VALID = "DATE_IS_VALID",
ONE_OF_RANGE = "ONE_OF_RANGE",
ONE_OF_LIST = "ONE_OF_LIST",
BLANK = "BLANK",
NOT_BLANK = "NOT_BLANK",
CUSTOM_FORMULA = "CUSTOM_FORMULA",
BOOLEAN = "BOOLEAN",
TEXT_NOT_EQ = "TEXT_NOT_EQ",
DATE_NOT_EQ = "DATE_NOT_EQ",
}
```

example to color in red negative cells

```
const conditionnalFormatting: sheets_v4.Schema$Request = {
addConditionalFormatRule: {
rule: {
ranges: [
{
sheetId,
startColumnIndex: 1,
endColumnIndex: 10,
},
],
booleanRule: {
condition: {
type: EGoogleSheetBooleanConditionsTypes.NUMBER_LESS,
values: [
{
userEnteredValue: "0",
},
],
},
format: {
textFormat: {
foregroundColor: {
red: 1,
},
},
},
},
},
index: 0,
},
};

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.