From 813c475a9c2cf78f87963cc6359be815088927c0 Mon Sep 17 00:00:00 2001 From: cauterize Date: Thu, 25 Aug 2022 17:23:32 +0200 Subject: [PATCH 1/3] :sparkles: Adds state option for PublicHolidays --- docs/widgets.md | 4 +++- src/components/Widgets/PublicHolidays.vue | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/widgets.md b/docs/widgets.md index d1acd419..8ec4d860 100644 --- a/docs/widgets.md +++ b/docs/widgets.md @@ -694,7 +694,8 @@ Counting down to the next day off work? This widget displays upcoming public hol **Field** | **Type** | **Required** | **Description** --- | --- | --- | --- -**`country`** | `string` | Required | The region to fetch holiday data for, specified as a country code, e.g. `GB` or `US` +**`country`** | `string` | Required | The country to fetch holiday data for, specified as a country code, e.g. `GB` or `US` +**`state`** | `string` | **Optional** | restrict a country to a specific state defined by [ISO_3166-2](https://en.wikipedia.org/wiki/ISO_3166-2), e.g. `LND`. **`holidayType`** | `string` | **Optional** | The type of holidays to fetch. Can be: `all`, `public_holiday`, `observance`, `school_holiday`, `other_day` or `extra_working_day`. Defaults to `public_holiday` **`monthsToShow`** | `number` | **Optional** | The number of months in advance to show. Min: `1`, max: `24`. Defaults to `12` @@ -704,6 +705,7 @@ Counting down to the next day off work? This widget displays upcoming public hol - type: public-holidays options: country: GB + region: LND holidayType: all monthsToShow: 12 ``` diff --git a/src/components/Widgets/PublicHolidays.vue b/src/components/Widgets/PublicHolidays.vue index 4cab3584..0cd990ed 100644 --- a/src/components/Widgets/PublicHolidays.vue +++ b/src/components/Widgets/PublicHolidays.vue @@ -57,7 +57,8 @@ export default { endpoint() { return `${widgetApiEndpoints.holidays}` + `&fromDate=${this.startDate}&toDate=${this.endDate}` - + `&country=${this.country}&holidayType=${this.holidayType}`; + + `&country=${this.country}&holidayType=${this.holidayType}` + + `${this.options?.state ? `®ion=${this.options.state}` : ''}`; }, }, methods: { From 38ad08a1014a0be18416d954bba71f5ff4e7b67d Mon Sep 17 00:00:00 2001 From: cauterize Date: Fri, 26 Aug 2022 20:18:09 +0200 Subject: [PATCH 2/3] :rotating_light: fix lint warning --- src/components/Widgets/PublicHolidays.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Widgets/PublicHolidays.vue b/src/components/Widgets/PublicHolidays.vue index 0cd990ed..4ff00cc8 100644 --- a/src/components/Widgets/PublicHolidays.vue +++ b/src/components/Widgets/PublicHolidays.vue @@ -54,11 +54,17 @@ export default { const then = new Date((now.setMonth(now.getMonth() + this.monthsToShow))); return `${then.getDate()}-${then.getMonth() + 1}-${then.getFullYear()}`; }, + region() { + if (this.options?.state) { + return `®ion=${this.options.state}`; + } + return ''; + }, endpoint() { - return `${widgetApiEndpoints.holidays}` + return `${`${widgetApiEndpoints.holidays}` + `&fromDate=${this.startDate}&toDate=${this.endDate}` - + `&country=${this.country}&holidayType=${this.holidayType}` - + `${this.options?.state ? `®ion=${this.options.state}` : ''}`; + + `&country=${this.country}&holidayType=${this.holidayType}`}${ + this.region}`; }, }, methods: { From 86b56f6b483e4a49ed786eb2f899d88273f74cef Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 4 Sep 2022 23:38:13 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Small=20refactor=20end?= =?UTF-8?q?point=20into=20single=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Widgets/PublicHolidays.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Widgets/PublicHolidays.vue b/src/components/Widgets/PublicHolidays.vue index 4ff00cc8..6d3d1e12 100644 --- a/src/components/Widgets/PublicHolidays.vue +++ b/src/components/Widgets/PublicHolidays.vue @@ -61,10 +61,10 @@ export default { return ''; }, endpoint() { - return `${`${widgetApiEndpoints.holidays}` + return `${widgetApiEndpoints.holidays}` + `&fromDate=${this.startDate}&toDate=${this.endDate}` - + `&country=${this.country}&holidayType=${this.holidayType}`}${ - this.region}`; + + `&country=${this.country}&holidayType=${this.holidayType}` + + `${this.region}`; }, }, methods: {