Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Merchandise returns - validation

DanielŻuławski540c48a40477
diff --git a/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml b/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml
index b4c9c6651..02217828e 100644
--- a/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml
+++ b/src/Web/Grand.Web/Views/MerchandiseReturn/MerchandiseReturn.cshtml
@@ -28,7 +28,7 @@
<div class="mt-2">
<h2 class="h5 mt-3"><strong>@Loc["MerchandiseReturns.SelectProduct(s)"]</strong></h2>
<div class="table-responsive">
- <table class="table table-hover data-table">
+ <table class="table table-hover merchandise-table data-table">
<colgroup>
<col />
<col width="200" />
@@ -54,58 +54,83 @@
</tr>
</thead>
<tbody>
- @foreach (var item in Model.Items)
- {
- <tr>
- <td class="product">
- <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>
- @if (!String.IsNullOrEmpty(item.AttributeInfo))
+ @{
+ int index = 0;
+ }
+ <tr>
+ <td>
+ <validation-provider tag="div" rules="required|exact_length:1,@Loc["merchandisereturns.noitemssubmitted"]" v-slot="{ errors, classes }">
+ @foreach (var item in Model.Items)
{
- <div class="attributes p-2">
- @Html.Raw(item.AttributeInfo)
+ index++;
+ <div>
+ <label class="custom-control custom-checkbox">
+ <input type="checkbox" class="custom-control-input" v-model="merchandisereturns.checkboxes" value="@index" @@change="merchandisereturns.allowed($event.target ,'quantity@(item.Id)')" name="checkbox_@(item.Id)" id="check_@(item.Id)">
+ <span class="custom-control-label"></span>
+ <span class="custom-control-description"></span>
+ </label>
</div>
}
- @if (!String.IsNullOrEmpty(item.VendorName))
- {
- <div class="vendor">
- @item.VendorName
+ <span class="field-validation-error" v-if="errors[0]">{{ errors[0] }}</span>
+ </validation-provider>
+ </td>
+ </tr>
+ <tr>
+ @foreach (var item in Model.Items)
+ {
+ index++;
+ <td>
+ <div class="product">
+ <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>
+ @if (!String.IsNullOrEmpty(item.AttributeInfo))
+ {
+ <a id="attributes-btn" class="btn btn-sm btn-outline-info" v-b-tooltip.html.right.hover title="@Html.Raw(item.AttributeInfo)">Attributes</a>
+ }
+ @if (!String.IsNullOrEmpty(item.VendorName))
+ {
+ <div class="vendor">
+ @item.VendorName
+ </div>
+ }
</div>
- }
- </td>
- <td class="unit-price">
- @item.UnitPrice
- </td>
- <td class="quantity">
- <select class="custom-select form-control" name="quantity@(item.Id)">
- @for (int i = 0; i <= item.Quantity; i++)
- {
- <option value="@(i)">@(i)</option>
- }
- </select>
- </td>
- <td>
- @{
- var reasonsSelectList = Model.AvailableReturnReasons.Select(x => new SelectListItem
- {
- Text = x.Name,
- Value = x.Id.ToString()
- }).ToList();
- }
- <select asp-for="@item.MerchandiseReturnReasonId" asp-items="@reasonsSelectList" name="reason@(item.Id)" class="form-control custom-select return-reasons"></select>
- </td>
- <td>
- @{
- var actionsSelectList = Model.AvailableReturnActions.Select(x => new SelectListItem
- {
- Text = x.Name,
- Value = x.Id.ToString()
- }).ToList();
- }
- <select asp-for="@item.MerchandiseReturnReasonId" asp-items="@actionsSelectList" name="action@(item.Id)" class="form-control custom-select return-actions"></select>
- </td>
+ <div class="unit-price">
+ @item.UnitPrice
+ </div>
+ <div class="quantity">
+ <validation-provider tag="div" rules="required" v-slot="{ errors, classes }">
+ <select data-val-required="@(string.Format(Loc["Fields.IsRequired"], Loc["MerchandiseReturns.Products.Quantity"]))" v-bind:class="[classes , 'custom-select form-control']" disabled="disabled" v-model="merchandisereturns.quantity_@(item.Id)" ref="quantity@(item.Id)" name="quantity@(item.Id)">
+ @for (int i = 0; i <= item.Quantity; i++)
+ {
+ <option value="@(i)">@(i)</option>
+ }
+ </select>
+ <span class="field-validation-error">{{ errors[0] }}</span>
+ </validation-provider>
+ </div>
+ <div>
+ @{
+ var reasonsSelectList = Model.AvailableReturnReasons.Select(x => new SelectListItem
+ {
+ Text = x.Name,
+ Value = x.Id.ToString()
+ }).ToList();
+ }
+ <select asp-for="@item.MerchandiseReturnReasonId" asp-items="@reasonsSelectList" name="reason@(item.Id)" class="form-control custom-select return-reasons"></select>
+ </div>
+ <div>
+ @{
+ var actionsSelectList = Model.AvailableReturnActions.Select(x => new SelectListItem
+ {
+ Text = x.Name,
+ Value = x.Id.ToString()
+ }).ToList();
+ }
+ <select asp-for="@item.MerchandiseReturnReasonId" asp-items="@actionsSelectList" name="action@(item.Id)" class="form-control custom-select return-actions"></select>
+ </div>
+ </td>
+ }
</tr>
- }
- </tbody>
+ </tbody>
</table>
</div>
</div>
@@ -211,7 +236,21 @@
</text>
}
newAddress: false,
+ @foreach (var item in Model.Items)
+ {
+ <text>quantity_</text> @item.Id <text>: '0',</text>
+ }
+ checkboxes: []
}),
+ methods: {
+ allowed(checkbox,element) {
+ if (checkbox.checked) {
+ vm.$refs[element].removeAttribute("disabled");
+ } else {
+ vm.$refs[element].setAttribute("disabled", "disabled");
+ }
+ }
+ },
created() {
@if (Model.ShowPickupAddress && (!Model.ExistingAddresses.Any() || Model.NewAddressPreselected))
{
diff --git a/src/Web/Grand.Web/wwwroot/theme/css/common/common.css b/src/Web/Grand.Web/wwwroot/theme/css/common/common.css
index 9dfaa0abf..7cf71e157 100644
--- a/src/Web/Grand.Web/wwwroot/theme/css/common/common.css
+++ b/src/Web/Grand.Web/wwwroot/theme/css/common/common.css
@@ -189,7 +189,10 @@ body:not(.modal-open) {
}
select option:disabled {
color: #aaa;
-}
+}
+.custom-select:disabled {
+ opacity: 0.5;
+}
/* sidebar common */
diff --git a/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css b/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css
index b6952ded9..addb4e9a8 100644
--- a/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css
+++ b/src/Web/Grand.Web/wwwroot/theme/css/common/common.rtl.css
@@ -230,6 +230,9 @@ body:not(.modal-open) {
select option:disabled {
color: #aaa;
}
+.custom-select:disabled {
+ opacity: 0.5;
+}
/* bootstrap slider */
diff --git a/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.css b/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.css
index 689c349ea..4427ae576 100644
--- a/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.css
+++ b/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.css
@@ -38,6 +38,97 @@ table .status.cancelled {
background-color: #f8d7da;
}
+/* merchandise table */
+
+.merchandise-table {
+ display: flex;
+ flex-direction: column;
+ padding: 0 0 25px 0;
+ position: relative;
+}
+.merchandise-table thead {
+}
+.merchandise-table thead tr {
+ display: flex;
+ width: 100%;
+ padding: 0 0 0 50px;
+ border: 0;
+}
+.merchandise-table thead th {
+ flex-basis: 0;
+ flex-grow: 1;
+ max-width: 100%;
+ min-width: 125px;
+ display: flex;
+ align-items: center;
+ border-bottom: 0;
+ border-top: 0;
+}
+.merchandise-table thead th:first-child {
+ display: flex;
+ align-items: center;
+}
+.merchandise-table tbody {
+ display: inline-flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ width: 100%;
+ min-width: 100%;
+}
+.merchandise-table tbody tr:nth-child(1) {
+ display: flex;
+ flex-direction: column;
+ min-width: 50px;
+}
+.merchandise-table tbody tr:nth-child(1) td {
+ height: 100%;
+ padding: 0;
+ border: 0;
+}
+.merchandise-table tbody tr:nth-child(1) td > div {
+ height: 100%;
+ min-height: 100%;
+ display: flex;
+ flex-direction: column;
+}
+.merchandise-table tbody tr:nth-child(1) td > div > div {
+ min-height: 110px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+.merchandise-table tbody tr:nth-child(2) {
+ width: calc(100% - 50px);
+}
+.merchandise-table tbody tr:nth-child(2) td {
+ display: inline-flex;
+ width: 100%;
+ padding: .75rem 0;
+ height: 110px;
+}
+.merchandise-table tbody tr:nth-child(2) td > div {
+ flex-basis: 0;
+ flex-grow: 1;
+ max-width: 100%;
+ padding: 0 0.75rem;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ min-width: 125px;
+}
+.merchandise-table .product a {
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+}
+.merchandise-table .field-validation-error {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ margin: 0;
+}
+
/* pagination */
.pagination .current-page.page-item .page-link {
@@ -46,6 +137,18 @@ table .status.cancelled {
border-color: #0E606C;
}
+@media (max-width: 768px) {
+ .merchandise-table tbody tr:nth-child(2) td > div {
+ max-width: 125px;
+ }
+ .merchandise-table {
+ padding: 0 0 45px 0;
+ }
+ .merchandise-table .field-validation-error {
+ font-size: 14px;
+ }
+}
+
/* dark customer */
[dark-theme="true"] .block-account-navigation ul li a.active, [dark-theme="true"] .block-account-navigation ul li a:hover {
diff --git a/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.rtl.css b/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.rtl.css
index a5c6f1df4..b0e5c0589 100644
--- a/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.rtl.css
+++ b/src/Web/Grand.Web/wwwroot/theme/css/customer/customer.rtl.css
@@ -38,6 +38,97 @@ table .status.cancelled {
background-color: #f8d7da;
}
+/* merchandise table */
+
+.merchandise-table {
+ display: flex;
+ flex-direction: column;
+ padding: 0 0 25px 0;
+ position: relative;
+}
+.merchandise-table thead {
+}
+.merchandise-table thead tr {
+ display: flex;
+ width: 100%;
+ padding: 0 50px 0 0;
+ border: 0;
+}
+.merchandise-table thead th {
+ flex-basis: 0;
+ flex-grow: 1;
+ max-width: 100%;
+ min-width: 125px;
+ display: flex;
+ align-items: center;
+ border-bottom: 0;
+ border-top: 0;
+}
+.merchandise-table thead th:first-child {
+ display: flex;
+ align-items: center;
+}
+.merchandise-table tbody {
+ display: inline-flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ width: 100%;
+ min-width: 100%;
+}
+.merchandise-table tbody tr:nth-child(1) {
+ display: flex;
+ flex-direction: column;
+ min-width: 50px;
+}
+.merchandise-table tbody tr:nth-child(1) td {
+ height: 100%;
+ padding: 0;
+ border: 0;
+}
+.merchandise-table tbody tr:nth-child(1) td > div {
+ height: 100%;
+ min-height: 100%;
+ display: flex;
+ flex-direction: column;
+}
+.merchandise-table tbody tr:nth-child(1) td > div > div {
+ min-height: 110px;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+.merchandise-table tbody tr:nth-child(2) {
+ width: calc(100% - 50px);
+}
+.merchandise-table tbody tr:nth-child(2) td {
+ display: inline-flex;
+ width: 100%;
+ padding: .75rem 0;
+ height: 110px;
+}
+.merchandise-table tbody tr:nth-child(2) td > div {
+ flex-basis: 0;
+ flex-grow: 1;
+ max-width: 100%;
+ padding: 0 0.75rem;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ min-width: 125px;
+}
+.merchandise-table .product a {
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+}
+.merchandise-table .field-validation-error {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ margin: 0;
+}
+
/* pagination */
.pagination .current-page.page-item .page-link {
@@ -46,6 +137,18 @@ table .status.cancelled {
border-color: #0E606C;
}
+@media (max-width: 768px) {
+ .merchandise-table tbody tr:nth-child(2) td > div {
+ max-width: 125px;
+ }
+ .merchandise-table {
+ padding: 0 0 45px 0;
+ }
+ .merchandise-table .field-validation-error {
+ font-size: 14px;
+ }
+}
+
/* dark customer */
[dark-theme="true"] .block-account-navigation ul li a.active, [dark-theme="true"] .block-account-navigation ul li a:hover {