Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
fix(WEATHER_LIST): format date column using date filter (#696)
Browse files Browse the repository at this point in the history
This has small potential to break user's values but only slight because
if the value doesn't contain formatting patterns then it will be just
left unchanged. So if users are currently formatting the date manually,
they should see no change.
  • Loading branch information
rchl authored Apr 11, 2021
1 parent d3c51fe commit c19f4b6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ Tile Object. [Click here for some real-life examples](TILE_EXAMPLES.md)
* Full documentation on fields is below
*/
fields: {},
/** type: WEATHER_LIST **/
/** defines the date format used in the date column */
dateFormat: 'MMM d', // See https://docs.angularjs.org/api/ng/filter/date for info on formatting syntax.
/** type: HISTORY **/
entity: 'sensor.temperatur_innen_gefiltert', // Entity ID (or an array of IDs) to render history for. Default: entity `id` of the tile itself
offset: 24*3600*1000*5, // Start point of the history counting from now(). Default: one day
Expand Down
1 change: 1 addition & 0 deletions TILE_EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ The example below is for the OpenWeatherMap provider. The configuration can vary
},
hideHeader: false,
secondaryTitle: 'Wind',
// dateFormat: 'MMM d', // default value
list: [1,2,3,4,5].map(function (id) {
var ENTITY_ID = 'weather.openweathermap'
return {
Expand Down
2 changes: 1 addition & 1 deletion scripts/directives/tile.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
</tr>
<tr ng-repeat="line in item.list track by $index">
<td class="weather-list-date">
<div ng-bind="weatherListField('date', line, item, entity)"></div>
<div ng-bind="weatherListField('date', line, item, entity) | date: item.dateFormat"></div>
</td>
<td class="weather-list-icon-container">
<div class="weather-list-icon"
Expand Down
3 changes: 3 additions & 0 deletions scripts/globals/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,7 @@ export const TILE_DEFAULTS = {
return this.$scope.toggleVacuum(item, entity);
},
},
[TYPES.WEATHER_LIST]: {
dateFormat: 'MMM d',
},
};

0 comments on commit c19f4b6

Please sign in to comment.