From 008df90c9e61a6337bd5ff5ff56df325820935c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20V=C3=A4nttinen?= Date: Mon, 19 Aug 2024 15:32:45 +0300 Subject: [PATCH 1/4] TMS-1052: Favorite programs-functionalities --- CHANGELOG.MD | 2 + assets/scripts/program-favorite.js | 281 ++++++++++++++++++ assets/scripts/theme.js | 2 + .../header/_header-favorites.scss | 45 +++ .../ui-components/header/_language-nav.scss | 5 +- assets/styles/ui-components/index.scss | 1 + assets/styles/views/_single-program.scss | 24 ++ lang/fi.mo | Bin 16672 -> 17336 bytes lang/fi.po | 196 ++++++------ lang/tms-theme-base.pot | 190 ++++++------ models/shared/program-favorites.php | 73 +++++ models/strings.php | 9 + partials/shared/header-favorite-toggle.dust | 7 + .../shared/header-favorites-container.dust | 22 ++ partials/shared/header-favorites-item.dust | 22 ++ partials/shared/header-inner.dust | 6 +- partials/shared/header-search-toggle.dust | 6 +- partials/shared/program-favorite-button.dust | 11 + partials/single-program.dust | 6 +- partials/views/page-program/program-list.dust | 7 +- 20 files changed, 715 insertions(+), 200 deletions(-) create mode 100644 assets/scripts/program-favorite.js create mode 100644 assets/styles/ui-components/header/_header-favorites.scss create mode 100644 models/shared/program-favorites.php create mode 100644 partials/shared/header-favorite-toggle.dust create mode 100644 partials/shared/header-favorites-container.dust create mode 100644 partials/shared/header-favorites-item.dust create mode 100644 partials/shared/program-favorite-button.dust diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 9d465795..947922f0 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +- TMS-1052: Favorite programs-functionalities + ## [1.8.16] - 2024-06-26 - TMS-925: diff --git a/assets/scripts/program-favorite.js b/assets/scripts/program-favorite.js new file mode 100644 index 00000000..15a1024d --- /dev/null +++ b/assets/scripts/program-favorite.js @@ -0,0 +1,281 @@ +/* eslint-disable no-console */ +/** + * Load more functionality for koulutusnosto-component. + */ + +// Use jQuery as $ within this file scope. +const $ = jQuery; + +/** + * Class LoadMore + */ +export default class FavoritePrograms { + docReady() { + // Bail if browser does not support localStorage. + if ( typeof Storage === 'undefined' ) { + return; + } + + this.cache(); + this.favorites = this.parseFavorites(); + + if ( ! this.hasFavorites() ) { + this.showNoResults(); + } + + // Init functionalities common to all templates. + this.initCommon(); + + // Init functionalities related to page-favorites template. + this.initFavorites(); + + // Favorite popup functionalities + this.favoritePopup(); + } + + cache() { + this.classes = { + hasFavorites: 'has-favorites', + isFavorite: 'is-favorite', + hide: 'is-hidden', + }; + + this.selectors = { + button: '.js-toggle-favorite', + }; + this.storageKey = 'tredu-program-favorites'; + this.closeFavorites = $( '#js-favorites-close' ); + this.openFavorites = $( '#js-favorites-open' ); + this.favoritesContainer = $( '#js-favorites-container' ); + this.favoritePrograms = $( '#js-favorite-programs' ); + this.favoritesContent = $( '#js-favorites-content' ); + this.favoritesNoResults = $( '#js-favorites-no-results' ); + } + + /** + * Initialize functionalities common for all templates. + */ + initCommon() { + this.favoriteButtons = $( this.selectors.button ); + + if ( this.favoriteButtons.length > 0 ) { + this.populateFavorites(); + } + } + + /** + * Initialize functionalities for favorites listing. + */ + initFavorites() { + // Fetch favorites according to localStorage. + if ( this.favorites.length !== 0 ) { + dp( 'ProgramFavorites/FavoritePrograms', { + partial: 'header-favorites-item', + tidy: true, + data: true, + args: { + ids: this.favorites, + }, + } ).then( ( response ) => { + console.log( response ); + if ( ! response.success ) { + this.showNoResults(); + return; + } + + // Set favorites content. + this.favoritePrograms.html( response.success ); + + // Show the container. + this.favoritePrograms.removeClass( this.classes.hide ); + } ).catch( ( error ) => { + console.log( error ); + this.showNoResults(); + } ); + } + + // Update favorites when favorite-button clicked + if ( this.favoritesContainer.length > 0 ) { + this.favoriteButtons.on( 'click', ( e ) => { + e.stopPropagation(); + this.toggleFavorite( e.currentTarget ); + this.loadFavorites(); + } ); + + $( document ).on( 'click', '.js-remove-favorite', ( e ) => { + e.stopPropagation(); + this.removeFavorite( e.currentTarget ); + this.loadFavorites(); + } ); + } + } + + /** + * Update favorite popup button attributes. + */ + favoritePopup() { + this.closeFavorites.on( 'click', ( e ) => { + e.stopPropagation(); + this.openFavorites.attr( 'aria-expanded', 'false' ); + this.openFavorites.removeClass( 'is-active' ); + } ); + } + + /** + * Parse favorite programs from localStorage. + * + * @return {Array} The localStorage values or an empty array. + */ + parseFavorites() { + const favorites = localStorage.getItem( this.storageKey ); + + if ( ! favorites ) { + return []; + } + + return JSON.parse( favorites ); + } + + /** + * Save passed favorites to localStorage. + * + * @param {Array} favorites The favorites as array + */ + saveFavorites( favorites = [] ) { + localStorage.setItem( this.storageKey, JSON.stringify( favorites ) ); + } + + /** + * Populate favorites from localStorage. + * + * @return {void} + */ + populateFavorites() { + // Loop over the favorite buttons and update their favorite-status. + for ( const item of this.favoriteButtons ) { + const programId = $( item ).data( 'program-id' ); + + if ( this.favorites.includes( programId ) ) { + $( item ).addClass( this.classes.isFavorite ); + $( item ).attr( 'aria-pressed', 'true' ); + $( item ).find( '.text-favorite-active' ).removeClass( this.classes.hide ); + $( item ).find( '.text-favorite-inactive' ).addClass( this.classes.hide ); + } + } + } + + /** + * Check if there are favorites in the localStorage. + * + * @return {boolean} True if favorites exist. + */ + hasFavorites() { + return this.favorites.length > 0; + } + + /** + * Changes favorite-status of the selected favorite. + * + * @param {Object} selectedItem The button element to be toggled. + * @return {void} + */ + toggleFavorite( selectedItem ) { + const programId = $( selectedItem ).data( 'program-id' ); + + // Add or remove program ID from localStorage. + if ( this.favorites.includes( programId ) ) { + this.favorites = this.favorites.filter( ( fav ) => fav !== programId ); + $( selectedItem ).removeClass( this.classes.isFavorite ); + $( selectedItem ).find( '.text-favorite-active' ).addClass( this.classes.hide ); + $( selectedItem ).find( '.text-favorite-inactive' ).removeClass( this.classes.hide ); + $( selectedItem ).attr( 'aria-pressed', 'false' ); + } + else { + this.favorites.push( programId ); + $( selectedItem ).addClass( this.classes.isFavorite ); + $( selectedItem ).find( '.text-favorite-active' ).removeClass( this.classes.hide ); + $( selectedItem ).find( '.text-favorite-inactive' ).addClass( this.classes.hide ); + $( selectedItem ).attr( 'aria-pressed', 'true' ); + } + + // Save to localStorage. + this.saveFavorites( this.favorites ); + } + + /** + * Remove favorite. + * + * @param {Object} selectedItem The button element to be toggled. + * @return {void} + */ + removeFavorite( selectedItem ) { + const programId = $( selectedItem ).data( 'program-id' ); + + // Remove program ID from localStorage. + if ( this.favorites.includes( programId ) ) { + this.favorites = this.favorites.filter( ( fav ) => fav !== programId ); + this.toggleFavoriteButton = $( '.js-toggle-favorite[data-program-id="' + programId + '"]' ); + + // Remove toggle-buttons attributes and texts + this.toggleFavoriteButton.removeClass( this.classes.isFavorite ); + this.toggleFavoriteButton.attr( 'aria-pressed', 'false' ); + this.toggleFavoriteButton.find( '.text-favorite-active' ).addClass( this.classes.hide ); + this.toggleFavoriteButton.find( '.text-favorite-inactive' ).removeClass( this.classes.hide ); + } + + // Save to localStorage. + this.saveFavorites( this.favorites ); + } + + /** + * Show "no results" content. + */ + showNoResults() { + this.favoritesContent.addClass( this.classes.hide ); + this.favoritesNoResults.removeClass( this.classes.hide ); + } + + /** + * Show "no results" content. + */ + hideNoResults() { + this.favoritesContent.removeClass( this.classes.hide ); + this.favoritesNoResults.addClass( this.classes.hide ); + } + + /** + * Load and show the favorite programs. + * + * @return {void} + */ + loadFavorites() { + // Fetch favorites according to localStorage. + dp( 'ProgramFavorites/FavoritePrograms', { + partial: 'header-favorites-item', + tidy: true, + data: true, + args: { + ids: this.favorites, + }, + } ).then( ( response ) => { + if ( ! response.success ) { + this.showNoResults(); + } + else { + this.hideNoResults(); + } + + // Set favorites content. + this.favoritePrograms.html( response.success ); + + // Refresh favorite buttons and add event listeners. + this.initCommon(); + + // Show the container. + this.favoritePrograms.removeClass( this.classes.hide ); + } ).catch( () => { + this.showNoResults(); + } ); + } + +} diff --git a/assets/scripts/theme.js b/assets/scripts/theme.js index 3cdec88d..4b18189a 100755 --- a/assets/scripts/theme.js +++ b/assets/scripts/theme.js @@ -30,6 +30,7 @@ import ProgramSearch from './program-search'; import LoadMore from './load-more'; import SearchFilters from './search-filters'; import FocusOnSearch from './focus-on-search'; +import FavoritePrograms from './program-favorite'; const globalControllers = { Common, @@ -59,6 +60,7 @@ const globalControllers = { LoadMore, SearchFilters, FocusOnSearch, + FavoritePrograms, }; const templateControllers = { diff --git a/assets/styles/ui-components/header/_header-favorites.scss b/assets/styles/ui-components/header/_header-favorites.scss new file mode 100644 index 00000000..4b7d51e3 --- /dev/null +++ b/assets/styles/ui-components/header/_header-favorites.scss @@ -0,0 +1,45 @@ +#js-favorites-open { + flex: 1 0 auto; + width: 2.375rem; + height: 2.375rem; + + svg { + margin: 0 !important; + } + + @include from($tablet) { + width: rem(50px); + height: rem(50px); + } +} + +#js-favorites-container { + ul { + list-style: none; + padding: 0; + + li { + &:not(:last-of-type) { + border-bottom: 2px solid $primary; + } + + .button-container { + display: flex; + gap: 2rem; + + .button.js-remove-favorite { + padding: 0; + background-color: transparent; + border-color: transparent; + + svg.icon { + margin-left: .25rem !important; + margin-right: 0 !important; + height: 1.25rem; + width: 1.25rem; + } + } + } + } + } +} diff --git a/assets/styles/ui-components/header/_language-nav.scss b/assets/styles/ui-components/header/_language-nav.scss index e3c35c65..e7cd449b 100644 --- a/assets/styles/ui-components/header/_language-nav.scss +++ b/assets/styles/ui-components/header/_language-nav.scss @@ -5,7 +5,6 @@ .lang-nav { .dropdown-menu { z-index: 25; - } &--horizontal { @@ -16,8 +15,8 @@ height: 2.375rem; @include from($tablet) { - width: rem(50); - height: rem(50); + width: rem(50px); + height: rem(50px); } } } diff --git a/assets/styles/ui-components/index.scss b/assets/styles/ui-components/index.scss index aa62af79..72c9e0c6 100644 --- a/assets/styles/ui-components/index.scss +++ b/assets/styles/ui-components/index.scss @@ -1,3 +1,4 @@ +@import "header/header-favorites"; @import "header/header-top"; @import "header/bulmally-navbar"; @import "header/primary-nav"; diff --git a/assets/styles/views/_single-program.scss b/assets/styles/views/_single-program.scss index 572ef720..4c07ea66 100644 --- a/assets/styles/views/_single-program.scss +++ b/assets/styles/views/_single-program.scss @@ -74,4 +74,28 @@ font-size: .94444444rem; line-height: 1.7; } + + &__add-favorite { + .button { + padding: 0; + background-color: transparent; + border-color: transparent; + + .icon-wrapper { + margin-left: .5rem; + + svg { + height: 1rem; + width: 1.5rem; + } + } + + // Active favorite + &[aria-pressed="true"] { + svg path { + fill: $color-red; + } + } + } + } } diff --git a/lang/fi.mo b/lang/fi.mo index 3381c6e10f83336958548bfcda20ce315a6f9612..a9507e613c7a5809d6d47210cee364661d8d0e5b 100644 GIT binary patch delta 5751 zcmZwLX?#@G0mk7oB#=N73<+c-l97Nw3WN{{31y8N2xUfwLp$26YCAhH&DwU;z(te<&|99r3YVG~;<~irwd(U?741s4C zIyODv2z;ItU28c0K{Cmq7-L2_jH$Uwt;TF>YmAC-VG1^26dpree-h)+(axAeOu!`U zfU%f|$=Dxt|0ryZE{rxNV9F@y!U|MJ)z|_TV{5EIb+E$L>yaDHR@8MnkU5*(wtf)R z-w|wyCs5a)!B+S!w!zETmhnw%rllLQQ8#o)U07i2Ls2sxfm+#E)Wk~dd7rJ%#{}AI zP}eUe2IyRZlKBRCFYG9njFM(soea>^`5 z=4Mu*27c4l_o4>=(zai=CNqex&q3{6F>2h~+Oz*xQ>dV(j+f#u@CD4mL#Ua4hx{=y zEazIxMz!CJn%HF2c`tUurS|+L)P&wc=33HOqdI;8b>SA& z1V2R$bP07|5+^%h4yryHoj4t@!6m3iREL`IR@8L|kUu7Hnx7gtmgUl?>4_S6Bx=AC z+dj|Mm!Vb^!j9O0Ja%&iH9&J`WPmi(b-hp%xe?X>4D5>cBj*FAo&vjJcA{2x0<~5D zMolE0yTcPhbvP0=&=l0Oue9|V)Jj*`ddSvyp(gqoL zK?A>ox}g!(ehKwR5*bByM|Cs|wNoXiN4Eeq@YARr*^Zicqdk8f)o(nr*El(-9V_m_ z{_BPb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_mCf7c))xVTQj z5&!*!o59785|8@7N-7OnniAqapX{p=-nLa*WPpW?wCANogS_YV6%xXurp diff --git a/lang/fi.po b/lang/fi.po index 6a82ba07..f23e036d 100644 --- a/lang/fi.po +++ b/lang/fi.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: TMS Theme Base\n" -"POT-Creation-Date: 2024-05-29 12:12+0300\n" -"PO-Revision-Date: 2024-05-29 12:13+0300\n" +"POT-Creation-Date: 2024-08-19 14:48+0300\n" +"PO-Revision-Date: 2024-08-19 14:49+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: fi\n" @@ -10,7 +10,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 3.4.2\n" +"X-Generator: Poedit 3.4.4\n" "X-Poedit-Basepath: ..\n" "X-Poedit-Flags-xgettext: --add-comments=translators:\n" "X-Poedit-WPHeader: style.css\n" @@ -23,6 +23,11 @@ msgstr "" "X-Poedit-SearchPathExcluded-1: vendor\n" "X-Poedit-SearchPathExcluded-2: node_modules\n" +#: assets/dist/vendor.js:4873 +msgctxt "text direction" +msgid "ltr" +msgstr "ltr" + #: comments.php:14 msgid "Comments" msgstr "Kommentit" @@ -53,7 +58,7 @@ msgstr "Sivun komponentit" #: lib/ACF/FrontPageGroup.php:90 lib/ACF/OnepagerGroup.php:126 #: lib/ACF/PageGroup.php:157 lib/ACF/PageProjectGroup.php:60 -#: lib/ACF/PostGroup.php:173 lib/ACF/ProgramGroup.php:304 +#: lib/ACF/PostGroup.php:173 lib/ACF/ProgramGroup.php:306 #: lib/ACF/ProjectGroup.php:425 msgctxt "theme ACF" msgid "Components" @@ -592,6 +597,16 @@ msgstr "Koulutushaku" msgid "No search results" msgstr "Ei hakutuloksia" +#: models/shared/header.php:68 models/strings.php:213 +msgctxt "theme-frontend" +msgid "Remove from favorites" +msgstr "Poista suosikeista" + +#: models/shared/header.php:69 +msgctxt "theme-frontend" +msgid "Go to program" +msgstr "Siirry koulutukseen" + #: models/single-dial-tredu.php:42 msgid "Go back" msgstr "Takaisin" @@ -693,7 +708,7 @@ msgid "Search from site" msgstr "Etsi sivustolta" #: models/strings.php:56 models/strings.php:83 models/strings.php:146 -#: models/strings.php:159 models/strings.php:168 models/strings.php:267 +#: models/strings.php:159 models/strings.php:168 models/strings.php:276 msgctxt "theme-frontend" msgid "Close" msgstr "Sulje" @@ -843,12 +858,12 @@ msgctxt "theme-frontend" msgid "Articletype:" msgstr "Artikkelityyppi:" -#: models/strings.php:111 models/strings.php:223 +#: models/strings.php:111 models/strings.php:232 msgctxt "theme-frontend" msgid "Month" msgstr "Kuukausi" -#: models/strings.php:112 models/strings.php:224 +#: models/strings.php:112 models/strings.php:233 msgctxt "theme-frontend" msgid "Year" msgstr "Vuosi" @@ -868,62 +883,62 @@ msgctxt "theme-frontend" msgid "The page reloads after the selection." msgstr "Sivu latautuu uudelleen valinnan jälkeen." -#: models/strings.php:118 models/strings.php:237 +#: models/strings.php:118 models/strings.php:246 msgctxt "theme-frontend" msgid "January" msgstr "tammikuu" -#: models/strings.php:119 models/strings.php:238 +#: models/strings.php:119 models/strings.php:247 msgctxt "theme-frontend" msgid "February" msgstr "helmikuu" -#: models/strings.php:120 models/strings.php:239 +#: models/strings.php:120 models/strings.php:248 msgctxt "theme-frontend" msgid "March" msgstr "maaliskuu" -#: models/strings.php:121 models/strings.php:240 +#: models/strings.php:121 models/strings.php:249 msgctxt "theme-frontend" msgid "April" msgstr "huhtikuu" -#: models/strings.php:122 models/strings.php:241 models/strings.php:255 +#: models/strings.php:122 models/strings.php:250 models/strings.php:264 msgctxt "theme-frontend" msgid "May" msgstr "toukokuu" -#: models/strings.php:123 models/strings.php:242 +#: models/strings.php:123 models/strings.php:251 msgctxt "theme-frontend" msgid "June" msgstr "kesäkuu" -#: models/strings.php:124 models/strings.php:243 +#: models/strings.php:124 models/strings.php:252 msgctxt "theme-frontend" msgid "July" msgstr "heinäkuu" -#: models/strings.php:125 models/strings.php:244 +#: models/strings.php:125 models/strings.php:253 msgctxt "theme-frontend" msgid "August" msgstr "elokuu" -#: models/strings.php:126 models/strings.php:245 +#: models/strings.php:126 models/strings.php:254 msgctxt "theme-frontend" msgid "September" msgstr "syyskuu" -#: models/strings.php:127 models/strings.php:246 +#: models/strings.php:127 models/strings.php:255 msgctxt "theme-frontend" msgid "October" msgstr "lokakuu" -#: models/strings.php:128 models/strings.php:247 +#: models/strings.php:128 models/strings.php:256 msgctxt "theme-frontend" msgid "November" msgstr "marraskuu" -#: models/strings.php:129 models/strings.php:248 +#: models/strings.php:129 models/strings.php:257 msgctxt "theme-frontend" msgid "December" msgstr "joulukuu" @@ -1136,219 +1151,208 @@ msgstr "Kuka voi hakea?" #: models/strings.php:207 msgctxt "theme-frontend" +msgid "Favorites" +msgstr "Suosikit" + +#: models/strings.php:208 +msgctxt "theme-frontend" +msgid "No favorites found" +msgstr "Suosikkeja ei löytynyt" + +#: models/strings.php:209 +msgctxt "theme-frontend" +msgid "Open or close favorites" +msgstr "Avaa tai sulje suosikit" + +#: models/strings.php:210 +msgctxt "theme-frontend" +msgid "Close favorites" +msgstr "Sulje suosikkilistaus" + +#: models/strings.php:211 +msgctxt "theme-frontend" +msgid "Add or remove from favorites" +msgstr "Lisää tai poista suosikeista" + +#: models/strings.php:212 +msgctxt "theme-frontend" +msgid "Add to favorites" +msgstr "Lisää suosikkeihin" + +#: models/strings.php:216 +msgctxt "theme-frontend" msgid "Filter by type" msgstr "Rajaa tyypin mukaan" -#: models/strings.php:208 +#: models/strings.php:217 msgctxt "theme-frontend" msgid "Publish date" msgstr "Julkaisupäivä" -#: models/strings.php:209 +#: models/strings.php:218 msgctxt "theme-frontend" msgid "Write search terms" msgstr "Kirjoita hakusanat" -#: models/strings.php:210 +#: models/strings.php:219 msgctxt "theme-frontend" msgid "Page location:" msgstr "Sivun sijainti:" -#: models/strings.php:213 +#: models/strings.php:222 msgctxt "theme-frontend" msgid "Filter" msgstr "Rajaa" -#: models/strings.php:214 +#: models/strings.php:223 msgctxt "theme-frontend" msgid "Clicking the link will download file" msgstr "Linkin avaaminen lataa tiedoston" -#: models/strings.php:218 models/strings.php:226 +#: models/strings.php:227 models/strings.php:235 msgctxt "theme-frontend" msgid "Pick a date" msgstr "Valitse päivämäärä" -#: models/strings.php:219 +#: models/strings.php:228 msgctxt "theme-frontend" msgid "dd.mm.yyyy" msgstr "pp.kk.vvvv" -#: models/strings.php:220 +#: models/strings.php:229 msgctxt "theme-frontend" msgid "The chosen date is" msgstr "Valittu päivämäärä on" -#: models/strings.php:221 +#: models/strings.php:230 msgctxt "theme-frontend" msgid "Previous month" msgstr "Edellinen kuukausi" -#: models/strings.php:222 +#: models/strings.php:231 msgctxt "theme-frontend" msgid "Next month" msgstr "Seuraava kuukausi" -#: models/strings.php:225 +#: models/strings.php:234 msgctxt "theme-frontend" msgid "Close window" msgstr "Sulje ikkuna" -#: models/strings.php:228 +#: models/strings.php:237 msgctxt "theme-frontend" msgid "Sunday" msgstr "Sunnuntai" -#: models/strings.php:229 +#: models/strings.php:238 msgctxt "theme-frontend" msgid "Monday" msgstr "Maanantai" -#: models/strings.php:230 +#: models/strings.php:239 msgctxt "theme-frontend" msgid "Tuesday" msgstr "Tiistai" -#: models/strings.php:231 +#: models/strings.php:240 msgctxt "theme-frontend" msgid "Wednesday" msgstr "Keskiviikko" -#: models/strings.php:232 +#: models/strings.php:241 msgctxt "theme-frontend" msgid "Thursday" msgstr "Torstai" -#: models/strings.php:233 +#: models/strings.php:242 msgctxt "theme-frontend" msgid "Friday" msgstr "Perjantai" -#: models/strings.php:234 +#: models/strings.php:243 msgctxt "theme-frontend" msgid "Saturday" msgstr "Lauantai" -#: models/strings.php:251 +#: models/strings.php:260 msgctxt "theme-frontend" msgid "Jan" msgstr "Tam" -#: models/strings.php:252 +#: models/strings.php:261 msgctxt "theme-frontend" msgid "Feb" msgstr "Hel" -#: models/strings.php:253 +#: models/strings.php:262 msgctxt "theme-frontend" msgid "Mar" msgstr "Maa" -#: models/strings.php:254 +#: models/strings.php:263 msgctxt "theme-frontend" msgid "Apr" msgstr "Huh" -#: models/strings.php:256 +#: models/strings.php:265 msgctxt "theme-frontend" msgid "Jun" msgstr "Kes" -#: models/strings.php:257 +#: models/strings.php:266 msgctxt "theme-frontend" msgid "Jul" msgstr "Hei" -#: models/strings.php:258 +#: models/strings.php:267 msgctxt "theme-frontend" msgid "Aug" msgstr "Elo" -#: models/strings.php:259 +#: models/strings.php:268 msgctxt "theme-frontend" msgid "Sept" msgstr "Syys" -#: models/strings.php:260 +#: models/strings.php:269 msgctxt "theme-frontend" msgid "Oct" msgstr "Loka" -#: models/strings.php:261 +#: models/strings.php:270 msgctxt "theme-frontend" msgid "Nov" msgstr "Mar" -#: models/strings.php:262 +#: models/strings.php:271 msgctxt "theme-frontend" msgid "Dec" msgstr "Jou" -#: models/strings.php:266 +#: models/strings.php:275 msgctxt "theme-frontend" msgid "Enlarged image" msgstr "Suurennettu kuva" -#: models/strings.php:270 +#: models/strings.php:279 msgctxt "theme-frontend" msgid "Load more" msgstr "Lataa lisää" -#: models/strings.php:271 +#: models/strings.php:280 msgctxt "theme-frontend" msgid "Load more programs" msgstr "Lataa lisää koulutuksia" -#: models/strings.php:272 +#: models/strings.php:281 msgctxt "theme-frontend" msgid "More results loaded" msgstr "Lisää tuloksia ladattu" -#: models/strings.php:285 +#: models/strings.php:294 msgid "Pagination" msgstr "Sivutus" -#: wp-content/mu-plugins/acf-codifier/src/Field/FlexibleContent.php:67 -#: wp-content/mu-plugins/acf-codifier/src/Field/Repeater.php:60 -msgid "Add Row" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisitePostObject.php:24 -msgid "Multisite Post Object" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteRelationship.php:24 -msgid "Multisite Relationship" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteTaxonomy.php:23 -msgid "Multisite taxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:23 -msgid "Multitaxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:516 -#, php-format -msgctxt "No terms" -msgid "No %s" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:18 -msgid "PHP" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:48 -msgid "Instructions" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:50 -msgid "" -"This field can only be used with ACF Codifier. Doesn't do anything if " -"defined in the admin side." -msgstr "" - #. Theme Name of the plugin/theme msgid "TMS Theme Tredu" msgstr "" @@ -1365,10 +1369,6 @@ msgstr "Geniem" msgid "https://geniem.fi" msgstr "" -#~ msgctxt "text direction" -#~ msgid "ltr" -#~ msgstr "ltr" - #~ msgid "Ongoing projects only" #~ msgstr "Näytä vain käynnissä olevat projektit" diff --git a/lang/tms-theme-base.pot b/lang/tms-theme-base.pot index fc8d7ba1..d87fd701 100644 --- a/lang/tms-theme-base.pot +++ b/lang/tms-theme-base.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: TMS Theme Base\n" -"POT-Creation-Date: 2024-05-29 12:12+0300\n" +"POT-Creation-Date: 2024-08-19 14:48+0300\n" "PO-Revision-Date: 2022-01-12 10:08+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -10,7 +10,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -"X-Generator: Poedit 3.4.2\n" +"X-Generator: Poedit 3.4.4\n" "X-Poedit-Basepath: ..\n" "X-Poedit-Flags-xgettext: --add-comments=translators:\n" "X-Poedit-WPHeader: style.css\n" @@ -23,6 +23,11 @@ msgstr "" "X-Poedit-SearchPathExcluded-1: vendor\n" "X-Poedit-SearchPathExcluded-2: node_modules\n" +#: assets/dist/vendor.js:4873 +msgctxt "text direction" +msgid "ltr" +msgstr "" + #: comments.php:14 msgid "Comments" msgstr "" @@ -53,7 +58,7 @@ msgstr "" #: lib/ACF/FrontPageGroup.php:90 lib/ACF/OnepagerGroup.php:126 #: lib/ACF/PageGroup.php:157 lib/ACF/PageProjectGroup.php:60 -#: lib/ACF/PostGroup.php:173 lib/ACF/ProgramGroup.php:304 +#: lib/ACF/PostGroup.php:173 lib/ACF/ProgramGroup.php:306 #: lib/ACF/ProjectGroup.php:425 msgctxt "theme ACF" msgid "Components" @@ -586,6 +591,16 @@ msgstr "" msgid "No search results" msgstr "" +#: models/shared/header.php:68 models/strings.php:213 +msgctxt "theme-frontend" +msgid "Remove from favorites" +msgstr "" + +#: models/shared/header.php:69 +msgctxt "theme-frontend" +msgid "Go to program" +msgstr "" + #: models/single-dial-tredu.php:42 msgid "Go back" msgstr "" @@ -687,7 +702,7 @@ msgid "Search from site" msgstr "" #: models/strings.php:56 models/strings.php:83 models/strings.php:146 -#: models/strings.php:159 models/strings.php:168 models/strings.php:267 +#: models/strings.php:159 models/strings.php:168 models/strings.php:276 msgctxt "theme-frontend" msgid "Close" msgstr "" @@ -837,12 +852,12 @@ msgctxt "theme-frontend" msgid "Articletype:" msgstr "" -#: models/strings.php:111 models/strings.php:223 +#: models/strings.php:111 models/strings.php:232 msgctxt "theme-frontend" msgid "Month" msgstr "" -#: models/strings.php:112 models/strings.php:224 +#: models/strings.php:112 models/strings.php:233 msgctxt "theme-frontend" msgid "Year" msgstr "" @@ -862,62 +877,62 @@ msgctxt "theme-frontend" msgid "The page reloads after the selection." msgstr "" -#: models/strings.php:118 models/strings.php:237 +#: models/strings.php:118 models/strings.php:246 msgctxt "theme-frontend" msgid "January" msgstr "" -#: models/strings.php:119 models/strings.php:238 +#: models/strings.php:119 models/strings.php:247 msgctxt "theme-frontend" msgid "February" msgstr "" -#: models/strings.php:120 models/strings.php:239 +#: models/strings.php:120 models/strings.php:248 msgctxt "theme-frontend" msgid "March" msgstr "" -#: models/strings.php:121 models/strings.php:240 +#: models/strings.php:121 models/strings.php:249 msgctxt "theme-frontend" msgid "April" msgstr "" -#: models/strings.php:122 models/strings.php:241 models/strings.php:255 +#: models/strings.php:122 models/strings.php:250 models/strings.php:264 msgctxt "theme-frontend" msgid "May" msgstr "" -#: models/strings.php:123 models/strings.php:242 +#: models/strings.php:123 models/strings.php:251 msgctxt "theme-frontend" msgid "June" msgstr "" -#: models/strings.php:124 models/strings.php:243 +#: models/strings.php:124 models/strings.php:252 msgctxt "theme-frontend" msgid "July" msgstr "" -#: models/strings.php:125 models/strings.php:244 +#: models/strings.php:125 models/strings.php:253 msgctxt "theme-frontend" msgid "August" msgstr "" -#: models/strings.php:126 models/strings.php:245 +#: models/strings.php:126 models/strings.php:254 msgctxt "theme-frontend" msgid "September" msgstr "" -#: models/strings.php:127 models/strings.php:246 +#: models/strings.php:127 models/strings.php:255 msgctxt "theme-frontend" msgid "October" msgstr "" -#: models/strings.php:128 models/strings.php:247 +#: models/strings.php:128 models/strings.php:256 msgctxt "theme-frontend" msgid "November" msgstr "" -#: models/strings.php:129 models/strings.php:248 +#: models/strings.php:129 models/strings.php:257 msgctxt "theme-frontend" msgid "December" msgstr "" @@ -1124,219 +1139,208 @@ msgstr "" #: models/strings.php:207 msgctxt "theme-frontend" -msgid "Filter by type" +msgid "Favorites" msgstr "" #: models/strings.php:208 msgctxt "theme-frontend" -msgid "Publish date" +msgid "No favorites found" msgstr "" #: models/strings.php:209 msgctxt "theme-frontend" -msgid "Write search terms" +msgid "Open or close favorites" msgstr "" #: models/strings.php:210 msgctxt "theme-frontend" +msgid "Close favorites" +msgstr "" + +#: models/strings.php:211 +msgctxt "theme-frontend" +msgid "Add or remove from favorites" +msgstr "" + +#: models/strings.php:212 +msgctxt "theme-frontend" +msgid "Add to favorites" +msgstr "" + +#: models/strings.php:216 +msgctxt "theme-frontend" +msgid "Filter by type" +msgstr "" + +#: models/strings.php:217 +msgctxt "theme-frontend" +msgid "Publish date" +msgstr "" + +#: models/strings.php:218 +msgctxt "theme-frontend" +msgid "Write search terms" +msgstr "" + +#: models/strings.php:219 +msgctxt "theme-frontend" msgid "Page location:" msgstr "" -#: models/strings.php:213 +#: models/strings.php:222 msgctxt "theme-frontend" msgid "Filter" msgstr "" -#: models/strings.php:214 +#: models/strings.php:223 msgctxt "theme-frontend" msgid "Clicking the link will download file" msgstr "" -#: models/strings.php:218 models/strings.php:226 +#: models/strings.php:227 models/strings.php:235 msgctxt "theme-frontend" msgid "Pick a date" msgstr "" -#: models/strings.php:219 +#: models/strings.php:228 msgctxt "theme-frontend" msgid "dd.mm.yyyy" msgstr "" -#: models/strings.php:220 +#: models/strings.php:229 msgctxt "theme-frontend" msgid "The chosen date is" msgstr "" -#: models/strings.php:221 +#: models/strings.php:230 msgctxt "theme-frontend" msgid "Previous month" msgstr "" -#: models/strings.php:222 +#: models/strings.php:231 msgctxt "theme-frontend" msgid "Next month" msgstr "" -#: models/strings.php:225 +#: models/strings.php:234 msgctxt "theme-frontend" msgid "Close window" msgstr "" -#: models/strings.php:228 +#: models/strings.php:237 msgctxt "theme-frontend" msgid "Sunday" msgstr "" -#: models/strings.php:229 +#: models/strings.php:238 msgctxt "theme-frontend" msgid "Monday" msgstr "" -#: models/strings.php:230 +#: models/strings.php:239 msgctxt "theme-frontend" msgid "Tuesday" msgstr "" -#: models/strings.php:231 +#: models/strings.php:240 msgctxt "theme-frontend" msgid "Wednesday" msgstr "" -#: models/strings.php:232 +#: models/strings.php:241 msgctxt "theme-frontend" msgid "Thursday" msgstr "" -#: models/strings.php:233 +#: models/strings.php:242 msgctxt "theme-frontend" msgid "Friday" msgstr "" -#: models/strings.php:234 +#: models/strings.php:243 msgctxt "theme-frontend" msgid "Saturday" msgstr "" -#: models/strings.php:251 +#: models/strings.php:260 msgctxt "theme-frontend" msgid "Jan" msgstr "" -#: models/strings.php:252 +#: models/strings.php:261 msgctxt "theme-frontend" msgid "Feb" msgstr "" -#: models/strings.php:253 +#: models/strings.php:262 msgctxt "theme-frontend" msgid "Mar" msgstr "" -#: models/strings.php:254 +#: models/strings.php:263 msgctxt "theme-frontend" msgid "Apr" msgstr "" -#: models/strings.php:256 +#: models/strings.php:265 msgctxt "theme-frontend" msgid "Jun" msgstr "" -#: models/strings.php:257 +#: models/strings.php:266 msgctxt "theme-frontend" msgid "Jul" msgstr "" -#: models/strings.php:258 +#: models/strings.php:267 msgctxt "theme-frontend" msgid "Aug" msgstr "" -#: models/strings.php:259 +#: models/strings.php:268 msgctxt "theme-frontend" msgid "Sept" msgstr "" -#: models/strings.php:260 +#: models/strings.php:269 msgctxt "theme-frontend" msgid "Oct" msgstr "" -#: models/strings.php:261 +#: models/strings.php:270 msgctxt "theme-frontend" msgid "Nov" msgstr "" -#: models/strings.php:262 +#: models/strings.php:271 msgctxt "theme-frontend" msgid "Dec" msgstr "" -#: models/strings.php:266 +#: models/strings.php:275 msgctxt "theme-frontend" msgid "Enlarged image" msgstr "" -#: models/strings.php:270 +#: models/strings.php:279 msgctxt "theme-frontend" msgid "Load more" msgstr "" -#: models/strings.php:271 +#: models/strings.php:280 msgctxt "theme-frontend" msgid "Load more programs" msgstr "" -#: models/strings.php:272 +#: models/strings.php:281 msgctxt "theme-frontend" msgid "More results loaded" msgstr "" -#: models/strings.php:285 +#: models/strings.php:294 msgid "Pagination" msgstr "" -#: wp-content/mu-plugins/acf-codifier/src/Field/FlexibleContent.php:67 -#: wp-content/mu-plugins/acf-codifier/src/Field/Repeater.php:60 -msgid "Add Row" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisitePostObject.php:24 -msgid "Multisite Post Object" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteRelationship.php:24 -msgid "Multisite Relationship" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/MultisiteTaxonomy.php:23 -msgid "Multisite taxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:23 -msgid "Multitaxonomy" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/Multitaxonomy.php:516 -#, php-format -msgctxt "No terms" -msgid "No %s" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:18 -msgid "PHP" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:48 -msgid "Instructions" -msgstr "" - -#: wp-content/mu-plugins/acf-codifier/src/Fields/PHP.php:50 -msgid "" -"This field can only be used with ACF Codifier. Doesn't do anything if " -"defined in the admin side." -msgstr "" - #. Theme Name of the plugin/theme msgid "TMS Theme Tredu" msgstr "" diff --git a/models/shared/program-favorites.php b/models/shared/program-favorites.php new file mode 100644 index 00000000..8aaa48cb --- /dev/null +++ b/models/shared/program-favorites.php @@ -0,0 +1,73 @@ +get_args(); + $data = [ + 'Favorites' => [], + ]; + $posts = []; + + if ( ! empty( $args ) ) { + $program_ids = $args->ids ?? []; + } + + if ( empty( $program_ids ) ) { + return []; + } + + if ( ! empty( $program_ids ) ) { + foreach ( $program_ids as $key => $post_id ) { + // ID + $posts[ $key ]['ID'] = $post_id; + + // Program title + $posts[ $key ]['title'] = \get_the_title( $post_id ); + + // Comma separated program-type terms + $term_obj_list = \get_the_terms( $post_id, 'program-type' ); + $terms_string = join( ', ', wp_list_pluck( $term_obj_list, 'name' ) ); + $posts[ $key ]['program_types'] = $terms_string; + + // Dates + $posts[ $key ]['start_date'] = date( "d.m.Y", strtotime( \get_field( 'start_date', $post_id ) ) ); + $posts[ $key ]['start_info'] = \get_field( 'start_info', $post_id ); + + // Permalink + $posts[ $key ]['permalink'] = \get_the_permalink( $post_id ); + + // Texts + $posts[ $key ]['remove_favorite_text'] = \_x( 'Remove from favorites', 'theme-frontend', 'tms-theme-tredu' ); + $posts[ $key ]['go_to_program_text'] = \_x( 'Go to program', 'theme-frontend', 'tms-theme-tredu' ); + } + + // Assign favorite posts + $data['Favorites']['posts'] = $posts; + } + + return $data; + } +} diff --git a/models/strings.php b/models/strings.php index efdc553d..d5d3a8a7 100644 --- a/models/strings.php +++ b/models/strings.php @@ -203,6 +203,15 @@ public function s() : array { 'scope' => _x( 'Scope', 'theme-frontend', 'tms-theme-tredu' ), 'who_can_apply' => _x( 'Who can apply?', 'theme-frontend', 'tms-theme-tredu' ), ], + 'program_favorite' => [ + 'favorites_title' => _x( 'Favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'no_favorites_text' => _x( 'No favorites found', 'theme-frontend', 'tms-theme-tredu' ), + 'open_or_close_favorites_text' => _x( 'Open or close favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'close_favorites_text' => _x( 'Close favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'add_to_favorites_aria_label' => _x( 'Add or remove from favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'add_to_favorites_text' => _x( 'Add to favorites', 'theme-frontend', 'tms-theme-tredu' ), + 'remove_from_favorites_text' => _x( 'Remove from favorites', 'theme-frontend', 'tms-theme-tredu' ), + ], 'search' => [ 'filter_by_post_type' => _x( 'Filter by type', 'theme-frontend', 'tms-theme-tredu' ), 'filter_by_date' => _x( 'Publish date', 'theme-frontend', 'tms-theme-tredu' ), diff --git a/partials/shared/header-favorite-toggle.dust b/partials/shared/header-favorite-toggle.dust new file mode 100644 index 00000000..54ecbbd7 --- /dev/null +++ b/partials/shared/header-favorite-toggle.dust @@ -0,0 +1,7 @@ + diff --git a/partials/shared/header-favorites-container.dust b/partials/shared/header-favorites-container.dust new file mode 100644 index 00000000..d4b3ec26 --- /dev/null +++ b/partials/shared/header-favorites-container.dust @@ -0,0 +1,22 @@ + diff --git a/partials/shared/header-favorites-item.dust b/partials/shared/header-favorites-item.dust new file mode 100644 index 00000000..3ae43fd7 --- /dev/null +++ b/partials/shared/header-favorites-item.dust @@ -0,0 +1,22 @@ +{#Favorites.posts} +
  • +

    {title|html}

    +

    {program_types|html}

    + {^start_info} +

    {start_date|html}

    + {:else} +

    {start_info|html}

    + {/start_info} +
    + {go_to_program_text|html} + +
    +
  • +{/Favorites.posts} diff --git a/partials/shared/header-inner.dust b/partials/shared/header-inner.dust index 1df407d2..0f8a2b5f 100644 --- a/partials/shared/header-inner.dust +++ b/partials/shared/header-inner.dust @@ -29,8 +29,10 @@ {>"ui/menu/language-nav-dropdown" links=Header.language_nav.links /} {/Header.lang_nav_horizontal} + {>"shared/header-favorite-toggle" /} + {^Header.hide_search} - {>"shared/header-search-toggle" /} + {>"shared/header-search-toggle" /} {/Header.hide_search} {?Header.has_nav_menu} @@ -45,6 +47,8 @@ + {>"shared/header-favorites-container" /} + {^Header.hide_search}