Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend-MECRED
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MECRED
Frontend-MECRED
Commits
aa97fbe1
Commit
aa97fbe1
authored
2 weeks ago
by
mcs22
Browse files
Options
Downloads
Patches
Plain Diff
issue
#63
: fix comments
parent
5fba3a63
No related branches found
No related tags found
No related merge requests found
Pipeline
#42463
passed
2 weeks ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/components/EditResourceModal.js
+55
-30
55 additions, 30 deletions
src/app/components/EditResourceModal.js
with
55 additions
and
30 deletions
src/app/components/EditResourceModal.js
+
55
−
30
View file @
aa97fbe1
...
@@ -8,34 +8,59 @@ import mecredApi from "@/axiosConfig";
...
@@ -8,34 +8,59 @@ import mecredApi from "@/axiosConfig";
export
function
EditResourceModal
({
open
,
onClose
,
resource
,
setEditOpen
})
{
export
function
EditResourceModal
({
open
,
onClose
,
resource
,
setEditOpen
})
{
const
[
title
,
setTitle
]
=
useState
(
""
);
const
[
title
,
setTitle
]
=
useState
(
""
);
const
[
description
,
setDescription
]
=
useState
(
""
);
const
[
description
,
setDescription
]
=
useState
(
""
);
const
[
id
,
setId
]
=
useState
();
const
[
openSuccess
,
setOpenSuccess
]
=
useState
(
false
)
const
[
openSuccess
,
setOpenSuccess
]
=
useState
(
false
)
const
token
=
getStoredValue
(
"
access_token
"
);
const
token
=
getStoredValue
(
"
access_token
"
);
const
client
=
getStoredValue
(
"
client
"
);
const
client
=
getStoredValue
(
"
client
"
);
const
uid
=
getStoredValue
(
"
uid
"
);
const
uid
=
getStoredValue
(
"
uid
"
);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
resource
?.
learning_object
)
{
if
(
resource
?.
learning_object
)
{
setTitle
(
resource
.
learning_object
.
name
??
""
);
setTitle
(
resource
.
learning_object
.
name
??
""
);
setDescription
(
resource
.
learning_object
.
description
??
""
);
setDescription
(
resource
.
learning_object
.
description
??
""
);
setId
(
resource
?.
learning_object
.
id
)
}
else
if
(
resource
?.
id
)
{
setTitle
(
resource
.
name
);
setId
(
resource
.
id
)
setDescription
(
resource
.
description
);
}
}
},
[
resource
]);
},
[
resource
]);
if
(
!
resource
?.
learning_object
)
return
null
;
console
.
log
(
"
resource
"
,
resource
,
resource
.
learning_object
)
if
(
!
resource
?.
id
)
return
null
;
const
handleTitleChange
=
(
e
)
=>
setTitle
(
e
.
target
.
value
);
const
handleTitleChange
=
(
e
)
=>
setTitle
(
e
.
target
.
value
);
const
handleDescriptionChange
=
(
e
)
=>
setDescription
(
e
.
target
.
value
);
const
handleDescriptionChange
=
(
e
)
=>
setDescription
(
e
.
target
.
value
);
const
fetchData
=
async
()
=>
{
const
fetchData
=
async
()
=>
{
let
resourceDraftNew
=
{
...
resource
}
if
(
resource
?.
learning_object
)
{
resourceDraftNew
.
learning_object
.
name
=
title
;
resourceDraftNew
.
learning_object
.
description
=
description
;
}
else
if
(
resource
?.
id
)
{
resourceDraftNew
.
name
=
title
;
resourceDraftNew
.
description
=
description
;
}
const
payload
=
{
const
payload
=
{
"
id
"
:
resource
?.
learning_object
.
id
,
"
learning_object
"
:
{
"
name
"
:
title
,
id
:
id
,
"
description
"
:
description
name
:
resource
?.
learning_object
?.
name
??
resource
.
name
,
description
:
resource
?.
learning_object
?.
description
??
resource
.
description
,
language_ids
:
(
resource
?.
language
)?.
map
(
l
=>
l
.
id
)
}
}
}
console
.
log
(
"
aa
"
)
//:author, :name, :curator, :object_type_id, :description, :license_id, :terms_of_service, :thumbnail, :software, :link, :magnetlink, language_ids: [
console
.
log
(
"
aa
"
,
(
resource
?.
language
)?.
map
(
l
=>
l
.
id
)
)
try
{
try
{
await
mecredApi
.
put
(
`/learning_objects/
${
resource
?.
learning_object
.
id
}
.json`
,
payload
,
{
await
mecredApi
.
put
(
`/learning_objects/
${
id
}
.json`
,
payload
,
{
headers
:
{
headers
:
{
"
access-token
"
:
token
,
"
access-token
"
:
token
,
"
token-type
"
:
"
Bearer
"
,
"
token-type
"
:
"
Bearer
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment