Skip to content

Commit

Permalink
Merge pull request #54 from Feedsystem/fix/date-exeptions
Browse files Browse the repository at this point in the history
fix: date exeptions
  • Loading branch information
fvaldes33 authored Oct 23, 2020
2 parents 38775b7 + 58145ad commit 239ac8d
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
7 changes: 7 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
trailingComma: 'es5',
tabWidth: 4,
semi: true,
singleQuote: true,
printWidth: 120,
};
12 changes: 6 additions & 6 deletions src/assetbundles/resources/src/js/modules/exceptions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
getDayName
} from '../util/helpers';
import { getLocalizeMoment, getLocalizedDayName } from '../util/helpers';

// helper method
const removeChild = (item, child) => {
Expand Down Expand Up @@ -54,18 +52,20 @@ class CalendarException {
close.setAttribute('data-icon', 'remove');
close.addEventListener('click', () => {
removeChild(this.listing, li);
})
});

// create base inputs
const newValue = this.dateField.value;
const localizedMoment = getLocalizeMoment(this.dateField.value);
let newValue = localizedMoment.format('D/M/Y');

const name = this.hiddenName;
const position = name.indexOf('[date]');
const newFieldName = [name.slice(0, position), `[${length || 0}]`, name.slice(position)].join('');

const hidden = this.createInput(newFieldName, 'hidden', newValue);
const timezone = this.createInput(newFieldName.replace('date', 'timezone'), 'hidden', Craft.timezone);

p.innerHTML = getDayName(newValue) + ', ' + newValue;
p.innerHTML = getLocalizedDayName(localizedMoment) + ', ' + localizedMoment.format('L');

li.appendChild(close);
li.appendChild(hidden);
Expand Down
3 changes: 3 additions & 0 deletions src/assetbundles/resources/src/js/util/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const getDayName = (date) => {
return days[d.getDay()];
};

export const getLocalizedDayName = (mom) => {
return mom.format('dddd');
};
export const weekOfMonth = (date) => {
const m = moment(date);
let w = m.isoWeekday(7).week() - moment(m).startOf('month').isoWeekday(7).week() - 1;
Expand Down
7 changes: 4 additions & 3 deletions src/templates/_components/fields/CalendarizeField_input.twig
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@
{% if value.exceptions is defined %}
{% for key, exception in value.exceptions %}
<li>
<div data-icon="remove"></div><p>{{ exception | date('l, m/d/Y') }}</p>
<input type="hidden" name="{{name}}[exceptions][{{key}}][date]" value="{{ exception | date('m/d/Y') }}" />
<input type="hidden" name="{{name}}[exceptions][{{key}}][timezone]" value="{{ craft.app.getTimeZone() }}">
<div data-icon="remove"></div>
<p>{{ exception | date('l, d/m/Y') }}</p>
<input type="hidden" name="{{ name }}[exceptions][{{ key }}][date]" value="{{ exception | date('short') }}"/>
<input type="hidden" name="{{ name }}[exceptions][{{ key }}][timezone]" value="{{ craft.app.getTimeZone() }}"/>
</li>
{% endfor %}
{% endif %}
Expand Down
44 changes: 44 additions & 0 deletions src/translations/nb/calendarize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Calendarize plugin for Craft CMS 3.x
*
* Calendar element types
*
* @link https://union.co
* @copyright Copyright (c) 2018 Franco Valdes
*/

/**
* @author Franco Valdes
* @package Calendarize
* @since 1.0.0
*/
return [
'Calendarize plugin loaded' => 'Calendarize plugin lastet',
'Sun' => 'Sun',
'Mon' => 'Man',
'Tue' => 'Tir',
'Wed' => 'Ons',
'Thu' => 'Tor',
'Fri' => 'Fre',
'Sat' => 'Lør',
'to' => 'til',
'Never' => 'Aldri',
'On Date' => 'På dato',
'Daily' => 'Dag',
'Weekly' => 'Uke',
'Biweekly (every 2 weeks)' => '2 uker',
'Monthly' => 'Måned',
'Yearly' => 'år',
'All Day' => 'Hele dagen',
'Repeats' => 'Repeterer',
'Every' => 'Hver',
'Every month on the' => 'Hver måned den',
'Ends Repeat' => 'Slutter repetering',
'Date Exceptions' => 'Dato unntak',
'Time Exceptions' => 'Tids unntak',
'Occurrences' => 'Hendelser',
'Last Occurrence' => 'Siste hendelse',
'Next Occurrence' => 'Neste hendelse',
'Date' => 'Dato'
];

0 comments on commit 239ac8d

Please sign in to comment.