Uh oh!
There was an error while loading. Please reload this page.
Create meal-order-menu-container component. - #53
Conversation
| @@ -19,9 +19,8 @@ | |||
| --> | |||
| <link rel="import" href="shell/meal-order-app-namespace.html"> | |||
There was a problem hiding this comment.
URLs should be relative. First is block with dependencies imports, then after empty line goes block with project imports.
| @@ -19,9 +19,8 @@ | |||
| --> | |||
| <link rel="import" href="shell/meal-order-app-namespace.html"> | |||
| <script src="../../bower_components/webcomponentsjs/webcomponents-lite.js"></script> | |||
| icon="icons:date-range" | ||
| drawer-toggle></iron-icon> | ||
| </div> | ||
| </iron-pages> |
There was a problem hiding this comment.
Please extract the <...toolbar> component.
| * | ||
| * @typedef {Object} Menu the menu for the current date | ||
| * | ||
| * @property {String} Vendor a vendor name |
| ]; | ||
| } | ||
| _getClassForDrawer(page) { |
| route="{{route}}" | ||
| pattern="/:page/:date" | ||
| data="{{routeData}}"> | ||
| </app-route> |
There was a problem hiding this comment.
Can you please describe in more detail?
There was a problem hiding this comment.
Is it good practice to change routing by two way binding in this case?
| _changeSelectedDay() { | ||
| const date = new Date(this.routeData.date); | ||
| let dayOfTheWeek = date.toLocaleDateString("ru-RU", {weekday: 'long'}); |
| const day = { | ||
| day: date.getDate(), | ||
| dayOfTheWeek: dayOfTheWeek, |
| */ | ||
| selectedDay: { | ||
| type: Object, | ||
| computed: '_changeSelectedDay(routeData.date)' |
| */ | ||
| inputDate: { | ||
| type: String, | ||
| computed: '_changeCalendarDate(routeData.date)', |
| } | ||
| } | ||
| _drawerToggle() { |
| } | ||
| if (this.routeData.page.startsWith("history")) { | ||
| if (!this.routeData.date) { | ||
| let yesterday = new Date(this.serverTime); |
| } | ||
| if (this.routeData.page.startsWith("history")) { | ||
| if (!this.routeData.date) { | ||
| let yesterday = new Date(this.serverTime); |
There was a problem hiding this comment.
yesterday is not yesterday, it's a server date.
| } | ||
| if (this.routeData.page.startsWith("history")) { | ||
| if (!this.routeData.date) { | ||
| let yesterday = new Date(this.serverTime); |
| display: none; | ||
| }; | ||
| } | ||
| return menus.filter(menu => menu.date.getTime() === routeDate.getTime()); | ||
| } | ||
| _getMenuDatesForWeek(menus) { |
| return dayOfTheWeek; | ||
| } | ||
| _getMenuForDay(date) { |
| _getMenuDatesForWeek(menus) { | ||
| const weekDates = []; | ||
| let menuDates = []; |
| for (let i = 0; i < DAYS_IN_PERIOD; i++) { | ||
| let tempDate = new Date(); | ||
| tempDate.setDate(this.serverTime.getDate() + i); | ||
| tempDate.setMonth(this.serverTime.getMonth()); |
There was a problem hiding this comment.
const newDate = new Date(serverTime);
newDate.setDate(serverTime.getDate() + i);
| const HOURS_PER_DAY = 86400000; | ||
| for (let i = 0; i < menuDates.length; i++) { | ||
| const diff = weekDates[i].getTime() - menuDates[i].getTime(); | ||
| if (diff >= 0 && diff < HOURS_PER_DAY) { |
PaulAgeyev
commented
Apr 27, 2018
@dkalinin PTAL |
…order-component # Conflicts: # client/user/src/mealorder/meal-order-client-app.html # client/user/src/mealorder/menu/meal-order-drawer.html
| * @property {Number} month | ||
| * @property {Number} year | ||
| * | ||
| * @typedef {Array} Categories array contains the category name and dishes |
There was a problem hiding this comment.
You shouldn't duplicate word array
| * @customElement | ||
| * @polymer | ||
| */ | ||
| class MealOrderToolbar extends (Polymer.Element) { |
| * @polymer | ||
| * @appliesMixin MealOrderApp.ReduxMixin | ||
| */ | ||
| class MealOrderMenuContainer extends (Polymer.Element) { |
| test('should instantiate the `meal-order-drawer` component', function (done) { | ||
| const elementShadowRoot = component.shadowRoot; | ||
| const drawer = elementShadowRoot.querySelector("meal-order-drawer"); |
There was a problem hiding this comment.
Those tests look like you are testing polymer
There was a problem hiding this comment.
The component is checked for availability.
| if (!this.routeData.date) { | ||
| const newDate = new Date(this.serverTime); | ||
| newDate.setDate(newDate.getDate() - 1); | ||
| this.set('routeData.date', newDate.toISOString().slice(0, DATE_LENGTH)); |
There was a problem hiding this comment.
.toISOString().slice(0, DATE_LENGTH) is repeated twice in a method.
| */ | ||
| selectedDayOfTheWeek: { | ||
| type: Object, | ||
| computed: '_getSelectedDayOfTheWeek(routeData.date)' |
There was a problem hiding this comment.
It should be a String. Also, we have two properties: selectedDay and selectedDayOfTheWeek. It's hard to find the difference by name or js doc. Let's rename selectedDayOfTheWeek to selectedDayName and extend the js doc.
| <script> | ||
| { | ||
| /** | ||
| * menu-order is container for the vendors' menus and navigation. |
There was a problem hiding this comment.
Is a container. Also, please use `menu-order` when mention the tag name. Example: https://github.com/PolymerElements/paper-input/blob/master/paper-input.html
Also, check the js doc of other components.
| * @polymer | ||
| * @appliesMixin MealOrderApp.ReduxMixin | ||
| */ | ||
| class MealOrderMenuContainer extends Polymer.Element { |
| * Selected day. | ||
| */ | ||
| selectedDate: { | ||
| type: Object, |
| return date.toISOString().slice(0, DATE_LENGTH); | ||
| } | ||
| _getDayOfTheWeek(date) { |
| * @typedef {Object} Date contains day, month, year | ||
| * @property {Number} day | ||
| * @property {Number} month | ||
| * @property {Number} year |
| } | ||
| _getDisplayedDays(menus) { | ||
| const weekDates = []; |
| <paper-tabs id="paper-tabs" selected="[[selectedDate]]" | ||
| attr-for-selected='data-key'> | ||
| <template is="dom-repeat" items="{{displayedDays}}" as="calendar"> |
There was a problem hiding this comment.
It's better to have the day alias instead of calendar.
| if (weekDates[i].getTime() === uniqueDates[i].getTime()) { | ||
| weekDates[i].hasMenu = true; | ||
| } | ||
| } |
There was a problem hiding this comment.
Too much logic to do simple things. All we need is:
- A simple array of 8 dates. It is used in top bar to render days.
- A Map which is computed from
menusarray. The key of map is a date, the value is an array of vendor menus by a key date. It's better to use menus.reduce(...) to compute the Map. In order to computedisabledstate of day just call map.has(date).
PaulAgeyev
commented
Jun 11, 2018
@dkalinin PTAL |
In this PR:
/#/menu/2018-03-21
/#/history/2018-02-22
Created
meal-order-menu-containercomponent that containspaper-tabscomponent that contains days for ordering dishes.Created
meal-order-drawerin themeal-order-client-appcomponent that containsapp-datepicker.View on desktop and on mobile device:
