Skip to content

Commit

Permalink
Merge pull request #612 from magento-vanilla/PR
Browse files Browse the repository at this point in the history
[Vanilla] Bugfixes
  • Loading branch information
Momotenko,Natalia(nmomotenko) committed May 13, 2016
2 parents 584af4d + 6b21f6f commit 5471bca
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ require([
showTime: false,
showHour: false,
showMinute: false,
serverTimezoneSeconds: <?php echo (int) $block->getStoreTimestamp(); ?>,
yearRange: '<?php /* @escapeNotVerified */ echo $block->getYearRange() ?>'
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</field>
<field name="theme">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Framework\View\Design\Theme\Label</item>
<item name="options" xsi:type="object">Magento\Theme\Model\Design\Theme\Label</item>
<item name="config" xsi:type="array">
<item name="formElement" xsi:type="string">select</item>
<item name="dataType" xsi:type="string">text</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ define([
return this;
},

/**
* Calls 'destroy' of parent and
* clear listing provider source
*
* @returns {Object} Chainable.
*/
destroy: function () {
this._super();
this.source.set(this.listingDataProvider, []);

return this;
},

/**
* Call parent "action" method
* and set new data to record and listing.
Expand Down
24 changes: 24 additions & 0 deletions app/code/Magento/Theme/Model/Design/Theme/Label.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Theme\Model\Design\Theme;

class Label extends \Magento\Framework\View\Design\Theme\Label
{
/**
* Return labels collection array
*
* @param bool|string $label add empty values to result with specific label
* @return array
*/
public function getLabelsCollection($label = false)
{
$options = parent::getLabelsCollection();
if ($label) {
array_unshift($options, ['value' => 0, 'label' => $label]);
}
return $options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,6 @@ define([
this.setMaxPosition();
}

elems.forEach(function (record) {
_.where(record.elems(),
{
formElement: 'select'
}).forEach(function (elem) {
elem.value(undefined);
});
});

path = this.dataScope + '.' + this.index + '.' + (this.startIndex + idx);
this.source.set(path, rec);
}, this);
Expand Down
36 changes: 21 additions & 15 deletions lib/web/mage/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@
var self = this;

/**
* overwrite jQuery UI datepicker function.
* Overwrite jQuery UI datepicker function.
* Reason: magento date could be set before calendar show
* but local date will be styled as current in original _generateHTML
*
* @param {Object} inst - instance datepicker.
* @return {String} html template
*/
$.datepicker.constructor.prototype._generateHTML = function (inst) {
var today = this._daylightSavingAdjust(self.getTimezoneDate()),
var today = self.getTimezoneDate(),
isRTL = this._get(inst, 'isRTL'),
showButtonPanel = this._get(inst, 'showButtonPanel'),
hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext'),
Expand Down Expand Up @@ -315,17 +318,20 @@

/**
* If server timezone is defined then take to account server timezone shift
* @param {Object} date
* @return {Object} date
*/
getTimezoneDate: function (date) {
date = date || new Date();
getTimezoneDate: function () {

if (this.options.serverTimezoneSeconds) {
date.setTime((this.options.serverTimezoneSeconds + date.getTimezoneOffset() * 60) * 1000);
// Get local time in ms
var ms = Date.now();

// Use store timestamp based on store timezone settings
if (typeof this.options.serverTimezoneSeconds !== 'undefined') {
//Adjust milliseconds according to client local timezone offset
ms = (this.options.serverTimezoneSeconds + new Date().getTimezoneOffset() * 60) * 1000;
}

return date;
return new Date(ms);
},

/**
Expand Down Expand Up @@ -396,10 +402,7 @@
'yy': 'yy' // Always long year format on frontend
},
time: {
'a': 'TT',
'H': 'h',
'MM': 'mm',
'SS': 'ss'
'a': 'TT'
}
},

Expand Down Expand Up @@ -518,9 +521,12 @@
* @param {Object} el
*/
$.datepicker._gotoToday = function (el) {
$.datepicker._gotoTodayOriginal.call(this, el);
$.datepicker._selectDate.call(this, el);
$(el).blur(); // To ensure that user can re-select date field without clicking outside it first.
var pickerObject = $(el);

// Set date/time according to timezone offset
pickerObject.datepicker( "setDate", pickerObject.calendar("getTimezoneDate") )
// To ensure that user can re-select date field without clicking outside it first.
.blur();
};

return {
Expand Down

0 comments on commit 5471bca

Please sign in to comment.