templates/index/menu_show.html.twig line 1

Open in your IDE?
  1. {% extends 'index/layout.html.twig' %}
  2. {% block page_name %}menu_detail{% endblock %}
  3. {% block title %}{{ menu.name }}|{{ shop.name }}{% endblock %}
  4. {% block header_title %}{{ menu.name }}{% endblock %}
  5. {% block stylesheet %}
  6.   <link rel="stylesheet" href="/css/detail.css">
  7.   <style>
  8.       [v-cloak] {
  9.           display: none;
  10.       }
  11.   </style>
  12. {% endblock %}
  13. {% block main %}
  14.   <main class="pd0 v-element">
  15. {#    <section class="details_wr">#}
  16. {#      <h1>{{ shop.name }}</h1>#}
  17. {#      <h2>{{ shop.categories|join(' / ') }}</h2>#}
  18. {#      <ul class="provide">#}
  19. {#        {% if shop.toGo %}<li>テイクアウト</li>{% endif %}#}
  20. {#        {% if shop.delivery %}<li>デリバリー</li>{% endif %}#}
  21. {#      </ul>#}
  22. {#      <ul class="time">#}
  23. {#        <li class="indication">提供時間目安 <span>{{ shop.estimatedMinutes|default('-') }}分</span></li>#}
  24. {#        <li class="start">{{ shop.hourFrom|date('H:i') }}〜{{ shop.hourTo|date('H:i') }}受付可</li>#}
  25. {#      </ul>#}
  26. {#      <div class="add">〒{{ shop.zipcode }} {{ shop.address }}</div>#}
  27. {#      #}{#<div class="map">#}
  28. {#      #}{#<div id="map-container" style="height: 150px;width: 100%;"></div>#}
  29. {#      #}{#</div>#}
  30. {#    </section>#}
  31.     <section class="add_cart_wr">
  32.         <img src="{{ menu.image }}" class="shop_img" alt="{{ menu.name }}">
  33.         <h2 class="title">{{ menu.name }}</h2>
  34.         <p class="text">{{ menu.description }}</p>
  35.         <p class="indication">提供目安時間 : <span>{{ menu.minutes|default('-') }}分</span></p>
  36.       {% if menu.shop.shopPlan.slug == constant('App\\Entity\\ShopPlan::SLUG_PAID') %}
  37.         <div class="add_cart_area">
  38.             <form action="{{ path('cart_add', {menu: menu.id}) }}" method="post" v-cloak>
  39.               <input type="hidden" name="token" value="{{ csrf_token('add-item') }}"/>
  40. {#                <input type="hidden" name="form[cart][menu]" :value="{{ menu.id }}">#}
  41.               <input type="hidden" name="cart_add_item[quantity]" :value="amount">
  42.                 <div class="add_control">
  43.                   {% if shop.acceptable %}
  44.                     <button class="add_button" type="button" @click="increment" :disabled="! canIncrement">+</button>
  45.                     <div class="num">[[ amount ]]</div>
  46.                     <button class="delete_button" type="button" @click="decrement" :disabled="! canDecrement">ー</button>
  47.                   {% endif %}
  48.                 </div>
  49.               {% if shop.acceptable %}
  50.                 <button type="submit" name="submit" class="button">[[ amount ]]つカートに入れる &yen;[[ numberFormat(subtotal) ]]</button>
  51.               {% else %}
  52.                 <span class="button tel out-of-service">受付時間外です</span>
  53.               {% endif %}
  54.             </form>
  55.         </div>
  56.       {% endif %}
  57.     </section>
  58.   </main>
  59. {% endblock %}
  60. {% block js %}
  61. <script>
  62.     {{ include('components/common-js.html.twig') }}
  63.     var vApp = new Vue({
  64.         el: '.v-element',
  65.         delimiters: ['[[', ']]'],
  66.         data: function () {
  67.             return {
  68.                 amount: 1,
  69.                 unitPrice: {% if menu.discountedPrice is not same as null %}{{ menu.discountedPrice | default(0) }}{% else %}{{ menu.price | default(0) }}{% endif %},
  70.             };
  71.         },
  72.         computed: {
  73.             canIncrement: function () {
  74.                 return (this.amount < 99);
  75.             },
  76.             canDecrement: function () {
  77.                 return (this.amount > 1);
  78.             },
  79.             subtotal: function () {
  80.                 return this.unitPrice * this.amount;
  81.             },
  82.         },
  83.         methods: {
  84.             numberFormat: function (value) {
  85.                 return _numberFormat(value);
  86.             },
  87.             increment: function () {
  88.                 if (this.canIncrement) {
  89.                     ++this.amount;
  90.                 }
  91.             },
  92.             decrement: function () {
  93.                 if (this.canDecrement) {
  94.                     --this.amount;
  95.                 }
  96.             },
  97.         },
  98.     });
  99. </script>
  100. {% endblock %}