|
| 1 | +@model IEnumerable<ASP.NET_Core.Models.SampleAppointment> |
| 2 | + |
| 3 | +<style> |
| 4 | + .long-title h3 { |
| 5 | + font-family: 'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana; |
| 6 | + font-weight: 200; |
| 7 | + font-size: 28px; |
| 8 | + text-align: center; |
| 9 | + margin-bottom: 20px; |
| 10 | + } |
| 11 | +</style> |
| 12 | + |
| 13 | +<div class="long-title"> |
| 14 | + <h3>DXCinema Upcoming Movies</h3> |
| 15 | +</div> |
| 16 | + |
| 17 | +@(Html.DevExtreme().Scheduler() |
| 18 | + .ID("scheduler") |
| 19 | + .DataSource(Model) |
| 20 | + .StartDateExpr("StartDate") |
| 21 | + .EndDateExpr("EndDate") |
| 22 | + .TextExpr("Text") |
| 23 | + .Views(new[] { |
| 24 | + SchedulerViewType.Day, |
| 25 | + SchedulerViewType.TimelineDay |
| 26 | + }) |
| 27 | + .CurrentView(SchedulerViewType.Day) |
| 28 | + .CurrentDate(new DateTime(2015, 4, 25)) |
| 29 | + .FirstDayOfWeek(0) |
| 30 | + .StartDayHour(9) |
| 31 | + .EndDayHour(23) |
| 32 | + .ShowAllDayPanel(false) |
| 33 | + .Height(600) |
| 34 | + .OnAppointmentFormOpening("onAppointmentFormOpening")); |
| 35 | + |
| 36 | +@(Html.DevExtreme().Popup() |
| 37 | + .ID("popup") |
| 38 | + .Width(500) |
| 39 | + .Height("80vh") |
| 40 | + .CloseOnOutsideClick(true) |
| 41 | + .Visible(new JS("isCustomPopupVisible")) |
| 42 | + .Title(new JS("editAppointmentData.Text")) |
| 43 | + .OnHiding("onHiding") |
| 44 | + .ContentTemplate(new TemplateName("popup-template")) |
| 45 | + .ToolbarItems(t => |
| 46 | + { |
| 47 | + t.Add() |
| 48 | + .Toolbar(Toolbar.Bottom) |
| 49 | + .Location(ToolbarItemLocation.After). |
| 50 | + Widget(w => w.Button() |
| 51 | + .Text("OK") |
| 52 | + .OnClick("setAppointment")); |
| 53 | + })); |
| 54 | + |
| 55 | + |
| 56 | +@using (Html.DevExtreme().NamedTemplate("popup-template")) |
| 57 | +{ |
| 58 | + @(Html.DevExtreme().ScrollView() |
| 59 | + .Width("100%") |
| 60 | + .Height("100%") |
| 61 | + .Content(@<text> |
| 62 | + <img id="popup-image" src="" class="dx-field-label" /> |
| 63 | + <div class="dx-field-label"> |
| 64 | + <p> |
| 65 | + <b id="popup-text"></b> |
| 66 | + </p> |
| 67 | + <p id="popup-year"></p> |
| 68 | + <p id="popup-duration"></p> |
| 69 | + </div> |
| 70 | + |
| 71 | + <div class="dx-field-label"> |
| 72 | + <b id="popup-date"></b> |
| 73 | + </div> |
| 74 | + |
| 75 | + <div class="dx-field-label"><b>Price ($): </b></div> |
| 76 | + <div id="popup-price" class="dx-field-label"> |
| 77 | + </div> |
| 78 | + |
| 79 | + @(Html.DevExtreme().SelectBox() |
| 80 | + .ID("rowView") |
| 81 | + .ElementAttr(new JS("elementAttr")) |
| 82 | + .DataSource(new JS("rows")) |
| 83 | + .Width(400) |
| 84 | + .Placeholder("Pick a row") |
| 85 | + .Value(new JS("editAppointmentData.SeatRow")) |
| 86 | + .OnValueChanged("onValueChangedRow") |
| 87 | + ) |
| 88 | + |
| 89 | + @(Html.DevExtreme().SelectBox() |
| 90 | + .ID("numberView") |
| 91 | + .ElementAttr(new JS("elementAttr")) |
| 92 | + .DataSource(new JS("seats")) |
| 93 | + .Width(400) |
| 94 | + .Placeholder("Pick a seat") |
| 95 | + .Value(new JS("editAppointmentData.SeatNumber")) |
| 96 | + .OnValueChanged("onValueChangedNumber") |
| 97 | + ) |
| 98 | + </text>) |
| 99 | + ) |
| 100 | +} |
| 101 | + |
| 102 | + |
| 103 | +<script> |
| 104 | + var editAppointmentData = {}; |
| 105 | + var oldAppointment = {}; |
| 106 | + var isCustomPopupVisible = false; |
| 107 | + var customPopupTitle = ""; |
| 108 | +
|
| 109 | + var elementAttr = { |
| 110 | + class: "dx-field-label" |
| 111 | + }; |
| 112 | +
|
| 113 | + var rows = ['A', 'B', 'C', 'D']; |
| 114 | + var seats = [1, 2, 3, 4, 5]; |
| 115 | +
|
| 116 | + function onAppointmentFormOpening(e) { |
| 117 | + e.cancel = true; |
| 118 | + editAppointmentData = { ...e.appointmentData }; |
| 119 | + oldAppointment = e.appointmentData; |
| 120 | + if (editAppointmentData.ID) { |
| 121 | + isCustomPopupVisible = true; |
| 122 | + customPopupTitle = editAppointmentData.Text |
| 123 | +
|
| 124 | + let customPopupOptions = { |
| 125 | + visible: isCustomPopupVisible, |
| 126 | + title: customPopupTitle |
| 127 | + }; |
| 128 | +
|
| 129 | + $("#popup").dxPopup("instance").option(customPopupOptions); |
| 130 | +
|
| 131 | + $("#popup-text").text(editAppointmentData.Text); |
| 132 | + $("#popup-year").text(`Year: ${editAppointmentData.Year}`); |
| 133 | + $("#popup-duration").text(`Duration: ${editAppointmentData.Duration} minutes`); |
| 134 | +
|
| 135 | +
|
| 136 | + $("#popup-date").text(`${DevExpress.localization.formatDate(new Date(editAppointmentData.StartDate), "shortTime")} - ${DevExpress.localization.formatDate(new Date(editAppointmentData.EndDate), "shortTime")}`); |
| 137 | + $("#popup-image").attr("src", editAppointmentData.Image); |
| 138 | + $("#popup-price").text(calculatePrice(editAppointmentData.SeatRow, editAppointmentData.SeatNumber, editAppointmentData.price)) |
| 139 | +
|
| 140 | + $("#rowView").dxSelectBox("instance").option("value", editAppointmentData.SeatRow); |
| 141 | + $("#numberView").dxSelectBox("instance").option("value", editAppointmentData.SeatNumber); |
| 142 | +
|
| 143 | + } |
| 144 | + } |
| 145 | +
|
| 146 | + function setAppointment() { |
| 147 | + if (editAppointmentData.SeatRow && editAppointmentData.SeatNumber) { |
| 148 | + let scheduler = $("#scheduler").dxScheduler("instance"); |
| 149 | + scheduler.updateAppointment( |
| 150 | + oldAppointment, |
| 151 | + editAppointmentData |
| 152 | + ); |
| 153 | + DevExpress.ui.notify(`Selected seat ${editAppointmentData.SeatRow}${editAppointmentData.SeatNumber} for ${editAppointmentData.Text}. Enjoy!`); |
| 154 | + } |
| 155 | + $("#popup").dxPopup("instance").hide(); |
| 156 | + } |
| 157 | +
|
| 158 | + function onHiding(e) { |
| 159 | + editAppointmentData = {}; |
| 160 | + oldAppointment = {}; |
| 161 | + } |
| 162 | +
|
| 163 | + function calculatePrice(SeatRow, SeatNumber, price) { |
| 164 | + return SeatRow && SeatNumber ? "$" + setSeatPrice(price, SeatRow) : "Pick a seat for pricing"; |
| 165 | + } |
| 166 | +
|
| 167 | + function setSeatPrice(price, SeatRow) { |
| 168 | + let rowPrice; |
| 169 | + switch (SeatRow) { |
| 170 | + case 'A': |
| 171 | + rowPrice = 1; |
| 172 | + break; |
| 173 | + case 'B': |
| 174 | + rowPrice = 2; |
| 175 | + break; |
| 176 | + case 'C': |
| 177 | + rowPrice = 3; |
| 178 | + break; |
| 179 | + case 'D': |
| 180 | + rowPrice = 4; |
| 181 | + break; |
| 182 | + default: |
| 183 | + break; |
| 184 | + } |
| 185 | + return price * rowPrice; |
| 186 | + } |
| 187 | +
|
| 188 | + function onValueChangedRow(e) { |
| 189 | + editAppointmentData.SeatRow = e.value; |
| 190 | + if (editAppointmentData.SeatRow && editAppointmentData.SeatNumber) { |
| 191 | + let priceText = calculatePrice(editAppointmentData.SeatRow, editAppointmentData.SeatNumber, editAppointmentData.Price) |
| 192 | + $("#popup-price").text(priceText); |
| 193 | + } |
| 194 | + } |
| 195 | +
|
| 196 | + function onValueChangedNumber(e) { |
| 197 | + editAppointmentData.SeatNumber = e.value; |
| 198 | + if (editAppointmentData.SeatRow && editAppointmentData.SeatNumber) { |
| 199 | + let priceText = calculatePrice(editAppointmentData.SeatRow, editAppointmentData.SeatNumber, editAppointmentData.Price) |
| 200 | + $("#popup-price").text(priceText); |
| 201 | + } |
| 202 | + } |
| 203 | +
|
| 204 | +</script> |
| 205 | + |
0 commit comments