datetime-picker.component.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <div class="input-wrapper">
  2. <input
  3. readonly
  4. [ngModel]="selected$ | async | date: 'medium'"
  5. class="selected-datetime"
  6. (keydown.enter)="dropdownComponent.toggleOpen()"
  7. (keydown.space)="dropdownComponent.toggleOpen()"
  8. #datetimeInput
  9. />
  10. <button class="clear-value-button btn" [class.visible]="!disabled && !readonly && (selected$ | async)" (click)="clearValue()">
  11. <clr-icon shape="times"></clr-icon>
  12. </button>
  13. </div>
  14. <vdr-dropdown #dropdownComponent>
  15. <button class="btn btn-outline calendar-button" vdrDropdownTrigger [disabled]="readonly || disabled">
  16. <clr-icon shape="calendar"></clr-icon>
  17. </button>
  18. <vdr-dropdown-menu>
  19. <div class="datetime-picker" *ngIf="current$ | async as currentView" (keydown.escape)="closeDatepicker()">
  20. <div class="controls">
  21. <div class="selects">
  22. <div class="month-select">
  23. <select
  24. clrSelect
  25. name="month"
  26. [ngModel]="currentView.month"
  27. (change)="setMonth($event)"
  28. >
  29. <option [value]="1">{{ 'datetime.month-jan' | translate }}</option>
  30. <option [value]="2">{{ 'datetime.month-feb' | translate }}</option>
  31. <option [value]="3">{{ 'datetime.month-mar' | translate }}</option>
  32. <option [value]="4">{{ 'datetime.month-apr' | translate }}</option>
  33. <option [value]="5">{{ 'datetime.month-may' | translate }}</option>
  34. <option [value]="6">{{ 'datetime.month-jun' | translate }}</option>
  35. <option [value]="7">{{ 'datetime.month-jul' | translate }}</option>
  36. <option [value]="8">{{ 'datetime.month-aug' | translate }}</option>
  37. <option [value]="9">{{ 'datetime.month-sep' | translate }}</option>
  38. <option [value]="10">{{ 'datetime.month-oct' | translate }}</option>
  39. <option [value]="11">{{ 'datetime.month-nov' | translate }}</option>
  40. <option [value]="12">{{ 'datetime.month-dec' | translate }}</option>
  41. </select>
  42. </div>
  43. <div class="year-select">
  44. <select
  45. clrSelect
  46. name="month"
  47. [ngModel]="currentView.year"
  48. (change)="setYear($event)"
  49. >
  50. <option *ngFor="let year of years" [value]="year">{{ year }}</option>
  51. </select>
  52. </div>
  53. </div>
  54. <div class="control-buttons">
  55. <button
  56. class="btn btn-link btn-sm"
  57. (click)="prevMonth()"
  58. [title]="'common.view-previous-month' | translate"
  59. >
  60. <clr-icon shape="caret" dir="left"></clr-icon>
  61. </button>
  62. <button class="btn btn-link btn-sm" (click)="selectToday()" [title]="'common.select-today' | translate">
  63. <clr-icon shape="event"></clr-icon>
  64. </button>
  65. <button
  66. class="btn btn-link btn-sm"
  67. (click)="nextMonth()"
  68. [title]="'common.view-next-month' | translate"
  69. >
  70. <clr-icon shape="caret" dir="right"></clr-icon>
  71. </button>
  72. </div>
  73. </div>
  74. <table class="calendar-table" #calendarTable tabindex="0" (keydown)="handleCalendarKeydown($event)">
  75. <thead>
  76. <tr>
  77. <td *ngFor="let weekdayName of weekdays">
  78. {{ weekdayName | translate }}
  79. </td>
  80. </tr>
  81. </thead>
  82. <tbody>
  83. <tr *ngFor="let week of calendarView$ | async">
  84. <td
  85. *ngFor="let day of week"
  86. class="day-cell"
  87. [class.selected]="day.selected"
  88. [class.today]="day.isToday"
  89. [class.viewing]="day.isViewing"
  90. [class.current-month]="day.inCurrentMonth"
  91. [class.disabled]="day.disabled"
  92. (keydown.enter)="selectDay(day)"
  93. (click)="selectDay(day)"
  94. >
  95. {{ day.dayOfMonth }}
  96. </td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. <div class="time-picker">
  101. <span class="flex-spacer"> {{ 'datetime.time' | translate }}: </span>
  102. <select clrSelect name="hour" [ngModel]="selectedHours$ | async" (change)="setHour($event)">
  103. <option *ngFor="let hour of hours" [value]="hour">{{ hour | number: '2.0-0' }}</option>
  104. </select>
  105. <span>:</span>
  106. <select
  107. clrSelect
  108. name="hour"
  109. [ngModel]="selectedMinutes$ | async"
  110. (change)="setMinute($event)"
  111. >
  112. <option *ngFor="let minute of minutes" [value]="minute">{{
  113. minute | number: '2.0-0'
  114. }}</option>
  115. </select>
  116. </div>
  117. </div>
  118. </vdr-dropdown-menu>
  119. </vdr-dropdown>