Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lesson49
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Пасько Виталий
Lesson49
Commits
81efc36c
Commit
81efc36c
authored
Aug 10, 2022
by
Пасько Виталий
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- вынес скрипты редактирования отзывов в отдельный файл.
parent
66021ec2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
35 deletions
+29
-35
FeedbackController.cs
PhoneStore/Controllers/FeedbackController.cs
+2
-1
About.cshtml
PhoneStore/Views/Phones/About.cshtml
+0
-34
site.js
PhoneStore/wwwroot/js/site.js
+27
-0
No files found.
PhoneStore/Controllers/FeedbackController.cs
View file @
81efc36c
...
...
@@ -28,10 +28,11 @@ namespace PhoneStore.Controllers
[
HttpPost
]
public
async
Task
<
IActionResult
>
Create
(
FeedbackCreateViewModel
model
)
{
var
validationResult
=
await
_feedbackValidation
.
ValidateAsync
(
model
);
// if (!validationResult.IsValid)
// {
//
//
TODO: сформировать сообщение
//TODO: сформировать сообщение
// return NotFound();
// }
var
feedbackViewModel
=
_feedbackService
.
Create
(
model
,
User
);
...
...
PhoneStore/Views/Phones/About.cshtml
View file @
81efc36c
...
...
@@ -38,37 +38,3 @@
@{
await Html.RenderPartialAsync("PartialViews/EditFeedbackModalPartial");
}
@section Scripts
{
<script >
$('#exampleModal').on('show.bs.modal', function (event) {
const button = $(event.relatedTarget);
const oldText = button.attr('text');
const username = button.attr('username');
const feedbackId = button.attr('feedbackId');
const modal = $(this);
modal.find('.modal-title').text('Редактируете от имени: ' + username);
const textarea = modal.find('.modal-body textarea');
textarea.text(oldText);
console.log(textarea.text())
console.log(feedbackId)
$('#feedback-edit-form').on('submit', function (submitEvent){
submitEvent.preventDefault();
$('#exampleModal').modal('hide');
fetch('https://localhost:5001/feedback/update', {
method: 'post',
body: JSON.stringify({id: feedbackId, text: textarea.val()}),
headers: {'content-type': 'application/json'}
}).then(response => {
console.log(response);
return response.text();
}).then(text => {
$(`div[id=${feedbackId}]`).html(text);
}).catch((error) => {
alert(error);
});
});
});
</script>
}
PhoneStore/wwwroot/js/site.js
View file @
81efc36c
...
...
@@ -49,5 +49,32 @@ $(document).ready(function () {
return
true
;
});
});
$
(
'#exampleModal'
).
on
(
'show.bs.modal'
,
function
(
event
)
{
const
button
=
$
(
event
.
relatedTarget
);
const
oldText
=
button
.
attr
(
'text'
);
const
username
=
button
.
attr
(
'username'
);
const
feedbackId
=
button
.
attr
(
'feedbackId'
);
const
modal
=
$
(
this
);
modal
.
find
(
'.modal-title'
).
text
(
'Редактируете от имени: '
+
username
);
const
textarea
=
modal
.
find
(
'.modal-body textarea'
);
textarea
.
text
(
oldText
);
$
(
'#feedback-edit-form'
).
on
(
'submit'
,
function
(
submitEvent
){
submitEvent
.
preventDefault
();
$
(
'#exampleModal'
).
modal
(
'hide'
);
fetch
(
'https://localhost:5001/feedback/update'
,
{
method
:
'post'
,
body
:
JSON
.
stringify
({
id
:
feedbackId
,
text
:
textarea
.
val
()}),
headers
:
{
'content-type'
:
'application/json'
}
}).
then
(
response
=>
{
console
.
log
(
response
);
return
response
.
text
();
}).
then
(
text
=>
{
$
(
`div[id=
${
feedbackId
}
]`
).
html
(
text
);
}).
catch
((
error
)
=>
{
alert
(
error
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment