You are here

calendar-week.html.twig in Calendar 8.2

Same filename and directory in other branches
  1. 8 templates/calendar-week.html.twig

Template to display a view as a calendar month.

Available variables:

  • rows: An array of data.

File

templates/calendar-week.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Template to display a view as a calendar month.
  5. *
  6. * Available variables:
  7. * - rows: An array of data.
  8. *
  9. */
  10. #}
  11. {{ attach_library('calendar/calendar') }}
  12. <div class="calendar week">
  13. <div class="labels">
  14. <div class="weekno">
  15. {% for weekcounter,row in rows %}
  16. {{ row.linkdata.week }}
  17. {% endfor %}
  18. </div>
  19. <div class="hour-label">
  20. {% for weekcounter,row in rows %}
  21. {% for day in row.weekdays %}
  22. {% if loop.first %}
  23. {% for key,value in day.other %}
  24. <div class="label">{{ "%05.2f"|format(key) }}</div>
  25. {% endfor %}
  26. {% endif %}
  27. {% endfor %}
  28. {% endfor %}
  29. </div>
  30. </div>
  31. <div class="data">
  32. <div class="headings">
  33. {% for weekcounter,row in rows %}
  34. {% for key,value in row.weekdays %}
  35. <div class="day {{ key }} {{ value.class }}">
  36. {% if row.linkdata.day_route %}
  37. <div class="date"><a href="{{ path(row.linkdata.day_route, {'arg_0': row.linkdata.year ~ row.linkdata.month ~ value.date }) }}">{{ value.date }}</a></div>
  38. {% else %}
  39. {{ value.date }}
  40. {% endif %}
  41. <div class="header">{{ value.header }}</div>
  42. </div>
  43. {% endfor %}
  44. {% endfor %}
  45. </div>
  46. {# multiday events are rendered first #}
  47. <div class="multidays">
  48. {% for weekcounter,row in rows %}
  49. {% for day in row.weekdays %}
  50. {% for event in day.multiday %}
  51. {# {% if event.offset.h > 0 %}#}
  52. {# {% set offset = (event.offset.d + 1) * 100 / 7 %}#}
  53. {# {% else %}#}
  54. {% set offset = event.offset.d * 100 / 7 %}
  55. {# {% endif %}#}
  56. {% if event.length.h > 0 %}
  57. {% set length = (event.length.d + 1) * 100 / 7 %}
  58. {% else %}
  59. {% set length = event.length.d * 100 / 7 %}
  60. {% endif %}
  61. {% if length is same as(0) %}
  62. <div class="multiday" style="margin-left: {{ offset }}%; width: auto;"><div class="inner">{{- event.label -}}</div></div>
  63. {% else %}
  64. <div class="multiday" style="margin-left: {{ offset }}%; width: {{ length }}%;"><div class="inner">{{- event.label -}}</div></div>
  65. {% endif %}
  66. {% endfor %}
  67. {% endfor %}
  68. {% endfor %}
  69. </div>
  70. {# next allday events #}
  71. <div class="alldays">
  72. {% for weekcounter,row in rows %}
  73. {% for key,value in row.weekdays %}
  74. <div class="day {{ key }} {{ value.class }}">
  75. {# {{ row.date }}#}
  76. {% for event in value.allday %}
  77. <div class="allday"><div class="inner">{{- event.label -}}</div></div>
  78. {% endfor %}
  79. </div>
  80. {% endfor %}
  81. {% endfor %}
  82. </div>
  83. {# render other events based on time and duration #}
  84. <div class="otherdays">
  85. {% for weekcounter,row in rows %}
  86. {% for key,value in row.weekdays %}
  87. <div class="day {{ key }} {{ value.class }}">
  88. <div class="labels">
  89. {% for events in value.other %}
  90. <div class="label">
  91. {% if events is not empty %}
  92. {% for event in events %}
  93. {% set height = event.length.h * 1.6 %}
  94. <div class="hour"><div class="event" style="height: {{ height }}rem; margin-left: {{ loop.index0 }}rem; background-color: {{ event.color }};">{{- event.row -}}</div></div>
  95. {% endfor %}
  96. {% else %}
  97. &nbsp;
  98. {% endif %}
  99. </div>
  100. {% endfor %}
  101. </div>
  102. </div>
  103. {% endfor %}
  104. {% endfor %}
  105. </div>
  106. </div>
  107. </div>