From 5ea3f74488681ffa895452abd3de2e9e36c049f8 Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Tue, 17 Sep 2024 23:57:28 +0200 Subject: [PATCH] implement composer liturgical-calendar/components --- .gitignore | 1 + admin.php | 20 ++++++++++++---- assets/js/admin.js | 42 ++++----------------------------- composer.json | 5 ++++ composer.lock | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 42 deletions(-) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 composer.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48b8bf9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/admin.php b/admin.php index 0953576..ff2bf3f 100644 --- a/admin.php +++ b/admin.php @@ -1,9 +1,11 @@
- - + 'it']; // set the locale to Italian + $CalendarSelect = new CalendarSelect($options); // use the default API url, but set the locale to Italian + echo $CalendarSelect->getSelect([ + 'class' => 'form-select', + 'id' => 'APICalendarSelect', + 'options' => 'all', + 'label' => true, + 'labelStr' => _('Calendar to test') + ]); + ?>
diff --git a/assets/js/admin.js b/assets/js/admin.js index ab0e332..ffd8f8d 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -175,9 +175,10 @@ const setEndpoints = (ev = null) => { } switch(ENDPOINTS.VERSION) { case 'dev': - ENDPOINTS.METADATA = `https://litcal.johnromanodorazio.com/api/dev/calendars/`; - ENDPOINTS.TESTSINDEX = `https://litcal.johnromanodorazio.com/api/dev/tests/`; - ENDPOINTS.EVENTS = `https://litcal.johnromanodorazio.com/api/dev/events/`; + case 'v4': + ENDPOINTS.METADATA = `https://litcal.johnromanodorazio.com/api/dev/calendars`; + ENDPOINTS.TESTSINDEX = `https://litcal.johnromanodorazio.com/api/dev/tests`; + ENDPOINTS.EVENTS = `https://litcal.johnromanodorazio.com/api/dev/events`; break; case 'v3': ENDPOINTS.METADATA = `https://litcal.johnromanodorazio.com/api/v3/LitCalMetadata.php`; @@ -189,44 +190,11 @@ const setEndpoints = (ev = null) => { setEndpoints(); -const COUNTRY_NAMES = new Intl.DisplayNames([locale], {type: 'region'}); +//const COUNTRY_NAMES = new Intl.DisplayNames([locale], {type: 'region'}); let CalendarNations = []; let SelectOptions = {}; let DiocesanCalendars; -//const COUNTRIES is available from Countries.js, included in footer.php for admin.php -fetch( ENDPOINTS.METADATA ) - .then(data => data.json()) - .then(jsonData => { - const { LitCalMetadata } = jsonData; - const { NationalCalendars } = LitCalMetadata; - ({DiocesanCalendars} = LitCalMetadata); - Object.freeze(DiocesanCalendars); - for( const [key,value] of Object.entries( DiocesanCalendars ) ) { - if( false === CalendarNations.includes(value.nation) ) { - CalendarNations.push(value.nation); - SelectOptions[value.nation] = []; - } - SelectOptions[value.nation].push(``); - } - - let nations = Object.keys( NationalCalendars ); - nations.sort((a, b) => COUNTRY_NAMES.of(COUNTRIES[a]).localeCompare(COUNTRY_NAMES.of(COUNTRIES[b]))); - nations.forEach(item => { - if( false === CalendarNations.includes(item) ) { - const calName = item === 'VATICAN' ? 'Universal Roman' : COUNTRY_NAMES.of(COUNTRIES[item]); - $('#APICalendarSelect').append(``); - } - }); - - CalendarNations.sort((a, b) => COUNTRY_NAMES.of(COUNTRIES[a]).localeCompare(COUNTRY_NAMES.of(COUNTRIES[b]))); - CalendarNations.forEach(item => { - $('#APICalendarSelect').append(``); - let $optGroup = $(``); - $('#APICalendarSelect').append($optGroup); - SelectOptions[item].forEach(groupItem => $optGroup.append(groupItem)); - }); - }); /** Prepare PUT new Unit Test */ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..d86cfea --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "liturgical-calendar/components": "^1.0" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..9f0d668 --- /dev/null +++ b/composer.lock @@ -0,0 +1,59 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "b9e651c20da5bfb3d061ab60111e72ac", + "packages": [ + { + "name": "liturgical-calendar/components", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/Liturgical-Calendar/liturgy-components-php.git", + "reference": "7ebbff9c69a97ce9f724b0cb57e3ad7b9d310807" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Liturgical-Calendar/liturgy-components-php/zipball/7ebbff9c69a97ce9f724b0cb57e3ad7b9d310807", + "reference": "7ebbff9c69a97ce9f724b0cb57e3ad7b9d310807", + "shasum": "" + }, + "require": { + "php": ">=7.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "LiturgicalCalendar\\Components\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "John R. D'Orazio", + "email": "priest@johnromanodorazio.com" + } + ], + "description": "Reusable frontend components for the Liturgical Calendar API", + "support": { + "issues": "https://github.com/Liturgical-Calendar/liturgy-components-php/issues", + "source": "https://github.com/Liturgical-Calendar/liturgy-components-php/tree/v1.0.2" + }, + "time": "2024-09-15T23:11:30+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +}