Skip to content

Commit

Permalink
Merge pull request #2992 from infor-design/2982-patch
Browse files Browse the repository at this point in the history
2982 - Fix the language from resetting [v4.21.x]
  • Loading branch information
tmcconechy committed Oct 16, 2019
2 parents a12ffae + c31787f commit 56beae7
Show file tree
Hide file tree
Showing 21 changed files with 416 additions and 45 deletions.
177 changes: 177 additions & 0 deletions app/views/components/calendar/test-specific-locale-lang.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<div class="calendar" data-init="false">
<div class="calendar-events">
<div class="accordion" data-options="{'allowOnePane': false}">
<div class="accordion-header is-expanded">
<a href="#"><span data-translate="text">Legend</span></a>
</div>
<div class="accordion-pane">
<div class="calendar-event-types accordion-content">
</div>
</div>
<div class="accordion-header is-expanded">
<a href="#"><span data-translate="text">UpComing</span></a>
</div>
<div class="accordion-pane">
<div class="calendar-upcoming-events accordion-content">
</div>
</div>
</div>
</div>
<div class="calendar-monthview">
</div>
<div class="calendar-event-details accordion" data-init="false" data-options="{'allowOnePane': false}">
</div>
</div>

<ul id="calendar-actions-menu" class="popupmenu">
<li><a href="#" data-action="delete-event"><span data-translate="text">DeleteEvent</span></a></li>
<li><a href="#" data-action="show-event"><span data-translate="text">ShowEvent</span></a></li>
</ul>

<script>
$('body').one('initialized', function () {
// Get the Event Type and Events to show in the calendar
var eventTypes = [];
var events = [];

$.getJSON('{{basepath}}api/event-types', function(res) {
eventTypes = res;

$.getJSON('{{basepath}}api/events', function(res) {
events = res;
$('.calendar').calendar({
month: 4,
year: 2019,
locale: 'de-DE',
language: 'es',
eventTypes: eventTypes,
events: events,
upcomingEventDays: 0,
template: 'tmpl-readonly',
modalTemplate: 'tmpl-modal',
menuId: 'calendar-actions-menu'
});
});
});
});
</script>

{{={{{ }}}=}}
<script id="tmpl-readonly" type="text/html">
{{#event}}
<div class="accordion-header is-expanded {{color}}">
<a href="#">{{subject}}</a>
</div>
<div class="accordion-pane is-expanded">
<div class="accordion-content">
{{#status}}
<div class="field">
<span class="label">Status</span>
<span class="data">
{{status}}
{{#icon}}
<svg class="icon {{icon}}" focusable="false" aria-hidden="true" role="presentation" data-status="{{status}}"><use xlink:href="#{{icon}}"></use></svg>
{{/icon}}
</span>
</div>
{{/status}}
<div class="field">
<span class="label">Date</span>
<span class="data">
{{startsLong}} to {{endsLong}}
</span>
</div>
<div class="field">
<span class="label">Event Type</span>
<span class="data">
{{typeLabel}}
</span>
</div>
<div class="field">
<span class="label">Duration</span>
{{#duration}}
<span class="data">
{{duration}} {{durationUnits}}
</span>
{{/duration}}
{{#durationHours}}
<span class="data">
{{durationHours}} {{durationUnits}}
</span>
{{/durationHours}}
</div>
<div class="field">
<span class="label">Comments</span>
<span class="data{{#noComments}} is-placeholder{{/noComments}}" >
{{comments}}
</span>
</div>
</div>
</div>
{{/event}}
</script>

<script id="tmpl-modal" type="text/html">
{{#event}}
<div class="form-responsive row">
<div class="twelve columns">
<div class="field">
<label for="subject" class="label">Subject</label>
<input id="subject" type="text" value="{{subject}}">
</div>
</div>
</div>
<div class="form-responsive row">
<div class="six columns">
<div class="field">
<label for="starts" class="label">From</label>
<input id="starts" class="datepicker" name="starts" type="text" value="{{startsLocale}}"/>
</div>
</div>
<div class="six columns">
<div class="field">
<label for="ends" class="label">To</label>
<input id="ends" class="datepicker" name="ends" type="text" value="{{endsLocale}}"/>
</div>
</div>
</div>
<div class="form-responsive row">
<div class="twelve columns">
<div class="field">
<label for="type" class="label">Type</label>
<select id="type" class="dropdown" name="type">
{{#eventTypes}}
<option value="{{id}}">{{label}}</option>
{{/eventTypes}}
</select>
</div>
</div>
</div>
<div class="form-responsive row">
<div class="six columns">
<div class="field">
<label for="durationHours">Hours</label>
<input id="durationHours" name="durationHours" type="text" class="spinbox"{{#isAllDay}}disabled="true"{{/isAllDay}} data-options="{min: 0, max: 24}" value="8"/>
</div>
</div>
<div class="six columns">
<div class="field field-checkbox">
<input type="checkbox" class="checkbox" name="isAllDay" id="isAllDay" {{#isAllDay}}checked="true"{{/isAllDay}}>
<label for="isAllDay" class="checkbox-label">All Day</label>
</div>
</div>
</div>
<div class="form-responsive row">
<div class="twelve columns">
<div class="field">
<label for="comments" class="label">Comments</label>
<textarea id="comments" type="text" value="{{comments}}"></textarea>
</div>
</div>
</div>
{{/event}}
<div class="modal-buttonset">
<button id="cancel" data-cancel="submit" type="button" class="btn-modal-secondary"><span data-translate="text">Cancel</span></button>
<button id="submit" data-action="submit" type="button" class="btn-modal-primary hide-focus"><span data-translate="text">Submit</span></button>
</div>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<input id="date-field-danish" class="datepicker" name="date-field-danish" type="text" data-options = "{ locale: 'da-DK' }"/>
</div>

<div class="field">
<label for="date-field-sv-de" class="label">Date Field (Swedish Language / De locale)</label>
<input id="date-field-sv-de" class="datepicker" name="date-field-sv-de" type="text" data-options = "{ locale: 'de-DE', language: 'sv' }"/>
</div>

</div>

</div>
17 changes: 17 additions & 0 deletions app/views/components/monthview/test-specific-locale-lang.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="row">
<div class="twelve columns">
<div class="monthview" data-init="false">
</div>
</div>
</div>

<script>
$('body').on('initialized', function () {
$('.monthview').monthview({
locale: 'da-DK',
language: 'de',
month: 9,
year: 2019
});
});
</script>
13 changes: 11 additions & 2 deletions app/views/components/timepicker/test-specific-locale.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<div class="row">
<div class="twelve columns">
<div class="field">
<label for="timepicker-main" class="label">Timepicker (Danish Locale)</label>
<input id="timepicker-main" class="timepicker" type="text" data-options = "{ locale: 'da-DK' }"/>
<label for="timepicker-1" class="label">Timepicker (Danish Locale)</label>
<input id="timepicker-1" class="timepicker" type="text" data-options="{ locale: 'da-DK' }"/>
</div>
</div>
</div>

<div class="row">
<div class="twelve columns">
<div class="field">
<label for="timepicker-2" class="label">Timepicker (Swedish Language De locale)</label>
<input id="timepicker-2" class="timepicker" type="text" data-options="{ locale: 'de-DE', language: 'sv' }"/>
</div>
</div>
</div>
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# What's New with Enterprise

## v4.21.3

### v4.21.3 Fixes

- `[Locale]` Fixed a bug that the language would reset when opening some components if a seperate language is used. ([#2982](https://github.com/infor-design/enterprise/issues/2982))

## v4.21.2

### v4.21.2 Fixes
Expand Down
16 changes: 15 additions & 1 deletion src/behaviors/initialize/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const COMPONENT_NAME = 'initialize';

// Component Defaults
const INITIALIZE_DEFAULTS = {
locale: 'en-US'
locale: 'en-US',
language: null // same as locale by default
};

// Contains excluded CSS selectors that prevent automatic initialization
Expand Down Expand Up @@ -420,6 +421,13 @@ function Initialize(element, settings) {
locale: Locale.currentLocale.name
};
}

if (Locale.currentLanguage && Locale.currentLanguage.name
&& Locale.currentLocale.name.substr(0, 2) !== Locale.currentLanguage.name
&& !settings) {
newSettings.language = Locale.currentLanguage.name;
}

this.settings = utils.mergeSettings(this.element[0], newSettings, INITIALIZE_DEFAULTS);
debug.logTimeStart(COMPONENT_NAME);
this.init();
Expand All @@ -437,6 +445,12 @@ Initialize.prototype = {
init() {
const self = this;
Locale.set(this.settings.locale).done(() => {
if (this.settings.language) {
Locale.setLanguage(this.settings.language).done(() => {
self.initAll();
});
return;
}
self.initAll();
});

Expand Down
Loading

0 comments on commit 56beae7

Please sign in to comment.