Repository navigation
Expand file tree
/
Copy pathCreateOrUpdate.TabNotes.cshtml
More file actions
124 lines (119 loc) · 6.14 KB
/
Copy pathCreateOrUpdate.TabNotes.cshtml
File metadata and controls
124 lines (119 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@using Grand.Domain.Media
@model CustomerModel
@{
ViewData["DownloadType"] = DownloadType.Customer;
ViewData["ReferenceId"] = Model.Id;
}
@* the merchandise return notes' shape: the notes grid in a flush card, then a card to add one *@
<div class="grand-card">
<div class="grand-card__body grand-card__body--flush">
<vc:admin-widget widget-zone="customer_details_notes_top" additional-data="Model"/>
<admin-grid id="customernotes-grid"
read-url="@Url.Action("CustomerNotesSelect", "CustomerNote", new { customerId = Model.Id, area = Constants.AreaAdmin })"
destroy-url="@Url.Action("CustomerNoteDelete", "CustomerNote", new { customerId = Model.Id, area = Constants.AreaAdmin })"
pager="Compact"
auto-bind="false"
confirm-destroy="true">
<grid-text name="link" value="@Loc["Admin.Customers.CustomerNotes.Fields.Download.Link"]"/>
<grid-text name="no" value="@Loc["Admin.Customers.CustomerNotes.Fields.Download.Link.No"]"/>
<grid-column field="CreatedOn" title="@Loc["Admin.Customers.CustomerNotes.Fields.CreatedOn"]" width="180" format="{0:G}"/>
<grid-column field="Title" title="@Loc["Admin.Customers.CustomerNotes.Fields.Title"]" width="250"/>
<grid-column field="Note" title="@Loc["Admin.Customers.CustomerNotes.Fields.Note"]" width="350"/>
<grid-column field="DownloadId" title="@Loc["Admin.Customers.CustomerNotes.Fields.Download"]" width="100">
<cell-template>
<a data-if="DownloadId != ''" href="@Url.Action("DownloadFile", "Download", new { area = Constants.AreaAdmin })/?downloadGuid={{ DownloadGuid }}">{{ $texts.link }}</a>
<span data-else>{{ $texts.no }}</span>
</cell-template>
</grid-column>
<grid-column field="DisplayToCustomer" title="@Loc["Admin.Customers.CustomerNotes.Fields.DisplayToCustomer"]" width="100" align="Center">
<cell-template>
<i data-if="DisplayToCustomer" class="bi bi-check-lg text-success" aria-hidden="true"></i>
<i data-else class="bi bi-x-lg text-danger" aria-hidden="true"></i>
</cell-template>
</grid-column>
<grid-commands destroy="true" title="@Loc["Admin.Common.Delete"]" width="100"/>
</admin-grid>
<vc:admin-widget widget-zone="customer_details_notes_bottom" additional-data="Model"/>
</div>
</div>
<script>
$(document).ready(function () {
$("#@Html.IdFor(model => model.AddCustomerNoteHasDownload)").change(toggleAddCustomerNoteHasDownload);
toggleAddCustomerNoteHasDownload();
});
function toggleAddCustomerNoteHasDownload() {
if ($('#@Html.IdFor(model => model.AddCustomerNoteHasDownload)').is(':checked')) {
$('#pnlAddCustomerNoteDownloadId').show();
}
else {
$('#pnlAddCustomerNoteDownloadId').hide();
}
}
</script>
<admin-card title="@Loc["Admin.Customers.CustomerNotes.AddTitle"]">
<div class="grand-fields">
<admin-field asp-for="AddCustomerTitle"/>
<admin-field asp-for="AddCustomerNoteMessage">
<admin-textarea asp-for="AddCustomerNoteMessage"></admin-textarea>
</admin-field>
<admin-field asp-for="AddCustomerNoteHasDownload" asp-label-for="AddCustomerNoteDownloadId"/>
<div id="pnlAddCustomerNoteDownloadId">
<admin-input asp-for="AddCustomerNoteDownloadId"/>
<span asp-validation-for="AddCustomerNoteDownloadId"></span>
</div>
<admin-field asp-for="AddCustomerNoteDisplayToCustomer"/>
</div>
<div class="mt-3">
<button type="button" id="addCustomerNote" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc["Admin.Customers.CustomerNotes.AddButton"]</button>
</div>
</admin-card>
<script>
$(document).ready(function () {
$('#addCustomerNote').click(function () {
var customerTitle = $("#@Html.IdFor(model => model.AddCustomerTitle)").val();
if (customerTitle.length == 0) {
alert('Title is required');
return;
}
var customerNoteMessage = $("#@Html.IdFor(model => model.AddCustomerNoteMessage)").val();
if (customerNoteMessage.length == 0) {
alert('Message text is required');
return;
}
var customerNoteDownloadId = '';
if ($('#@Html.IdFor(model => model.AddCustomerNoteHasDownload)').is(':checked')) {
customerNoteDownloadId = $("#@Html.IdFor(model => model.AddCustomerNoteDownloadId)").val();
}
var customerNoteDisplayToCustomer = $("#@Html.IdFor(model => model.AddCustomerNoteDisplayToCustomer)").is(':checked');
$('#addCustomerNote').attr('disabled', true);
var postData = {
DisplayToCustomer: customerNoteDisplayToCustomer,
title: customerTitle,
message: customerNoteMessage,
downloadId: customerNoteDownloadId,
customerId: '@Model.Id'
};
addAntiForgeryToken(postData);
$.ajax({
cache:false,
type: "POST",
url: "@(Url.Action("CustomerNoteAdd", "CustomerNote", new { area = Constants.AreaAdmin }))",
data: postData,
success: function (data) {
if (!data.Result) {
alert(data.Message || 'Failed to add customer note.');
$('#addCustomerNote').attr('disabled', false);
return;
}
var grid = GrandAdmin.grids.get("#customernotes-grid");
grid.dataSource.read();
$('#addCustomerNote').attr('disabled', false);
},
error:function (xhr, ajaxOptions, thrownError){
alert('Failed to add customer note.');
$('#addCustomerNote').attr('disabled', false);
}
});
});
});
</script>