Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
f3046f9a
Commit
f3046f9a
authored
7 months ago
by
Ron Lucke
Committed by
Marcus Eibrink-Lunzenauer
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
evaluate image type of structural element on import and export
Closes #3743 Merge request
studip/studip!3175
parent
3271f73e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
resources/vue/mixins/courseware/export.js
+22
-18
22 additions, 18 deletions
resources/vue/mixins/courseware/export.js
resources/vue/mixins/courseware/import.js
+23
-15
23 additions, 15 deletions
resources/vue/mixins/courseware/import.js
with
45 additions
and
33 deletions
resources/vue/mixins/courseware/export.js
+
22
−
18
View file @
f3046f9a
...
@@ -134,7 +134,7 @@ export default {
...
@@ -134,7 +134,7 @@ export default {
root_element
.
children
=
children
;
root_element
.
children
=
children
;
}
}
}
}
root_element
.
imageId
=
await
this
.
exportStructuralElementImage
(
root_element
);
[
root_element
.
imageId
,
root_element
.
imageType
]
=
await
this
.
exportStructuralElementImage
(
root_element
);
delete
root_element
.
relationships
;
delete
root_element
.
relationships
;
delete
root_element
.
links
;
delete
root_element
.
links
;
...
@@ -236,7 +236,7 @@ export default {
...
@@ -236,7 +236,7 @@ export default {
}
}
// export file data (if any)
// export file data (if any)
content
.
imageId
=
await
this
.
exportStructuralElementImage
(
element
);
[
content
.
imageId
,
content
.
imageType
]
=
await
this
.
exportStructuralElementImage
(
element
);
delete
content
.
relationships
;
delete
content
.
relationships
;
content
.
children
=
new_childs
;
content
.
children
=
new_childs
;
...
@@ -249,25 +249,29 @@ export default {
...
@@ -249,25 +249,29 @@ export default {
},
},
async
exportStructuralElementImage
(
element
)
{
async
exportStructuralElementImage
(
element
)
{
let
fileId
=
element
.
relationships
.
image
?.
data
?.
id
;
const
fileId
=
element
.
relationships
.
image
?.
data
?.
id
;
const
fileType
=
element
.
relationships
.
image
?.
data
?.
type
;
if
(
fileId
)
{
if
(
fileId
)
{
await
this
.
loadFileRefsById
({
id
:
fileId
});
if
(
fileType
===
'
file-refs
'
)
{
let
fileRef
=
this
.
fileRefsById
({
id
:
fileId
});
await
this
.
loadFileRefsById
({
id
:
fileId
});
let
fileRef
=
this
.
fileRefsById
({
id
:
fileId
});
let
fileRefData
=
{};
fileRefData
.
id
=
fileRef
.
id
;
let
fileRefData
=
{};
fileRefData
.
attributes
=
fileRef
.
attributes
;
fileRefData
.
id
=
fileRef
.
id
;
fileRefData
.
related_element_id
=
element
.
id
;
fileRefData
.
attributes
=
fileRef
.
attributes
;
fileRefData
.
folder
=
null
;
fileRefData
.
related_element_id
=
element
.
id
;
fileRefData
.
folder
=
null
;
this
.
exportFiles
.
json
.
push
(
fileRefData
);
this
.
exportFiles
.
download
[
fileRef
.
id
]
=
{
this
.
exportFiles
.
json
.
push
(
fileRefData
);
folder
:
null
,
this
.
exportFiles
.
download
[
fileRef
.
id
]
=
{
url
:
fileRef
.
meta
[
'
download-url
'
]
folder
:
null
,
};
url
:
fileRef
.
meta
[
'
download-url
'
]
};
}
}
}
return
fileId
;
return
[
fileId
,
fileType
]
;
},
},
async
exportContainer
(
container_ref
)
{
async
exportContainer
(
container_ref
)
{
...
...
This diff is collapsed.
Click to expand it.
resources/vue/mixins/courseware/import.js
+
23
−
15
View file @
f3046f9a
...
@@ -152,7 +152,7 @@ export default {
...
@@ -152,7 +152,7 @@ export default {
}
}
// compare image
// compare image
if
(
element
.
imageId
&&
root
.
relationships
.
image
.
data
===
null
)
{
if
(
element
.
imageId
&&
root
.
relationships
.
image
.
data
===
null
)
{
await
this
.
setStructuralElementImage
(
root
,
element
.
imageId
,
files
);
await
this
.
setStructuralElementImage
(
root
,
element
,
files
);
}
}
// add children
// add children
...
@@ -187,7 +187,7 @@ export default {
...
@@ -187,7 +187,7 @@ export default {
if
(
element
[
i
].
imageId
)
{
if
(
element
[
i
].
imageId
)
{
await
this
.
setStructuralElementImage
(
new_element
,
element
[
i
]
.
imageId
,
files
);
await
this
.
setStructuralElementImage
(
new_element
,
element
[
i
],
files
);
}
}
...
@@ -205,19 +205,27 @@ export default {
...
@@ -205,19 +205,27 @@ export default {
}
}
},
},
async
setStructuralElementImage
(
new_element
,
imageId
,
files
)
{
async
setStructuralElementImage
(
new_element
,
element
,
files
)
{
let
imageFile
=
files
.
find
((
file
)
=>
{
return
file
.
id
===
imageId
});
const
imageId
=
element
.
imageId
;
let
zip_filedata
=
await
this
.
zip
.
file
(
imageFile
.
id
).
async
(
'
blob
'
);
const
imageType
=
element
.
imageType
??
'
file-refs
'
;
// create new blob with correct type
if
(
imageType
===
'
file-refs
'
)
{
let
filedata
=
zip_filedata
.
slice
(
0
,
zip_filedata
.
size
,
imageFile
.
attributes
[
'
mime-type
'
]);
const
imageFile
=
files
.
find
((
file
)
=>
{
return
file
.
id
===
imageId
});
this
.
setImportStructuresState
(
this
.
$gettext
(
'
Lade Vorschaubild hoch
'
));
if
(
!
(
imageFile
))
{
this
.
uploadImageForStructuralElement
({
this
.
currentImportErrors
.
push
(
this
.
$gettext
(
'
Fehler beim Laden des Vorschaubildes.
'
));
structuralElement
:
new_element
,
return
;
file
:
filedata
,
}
}).
catch
((
error
)
=>
{
let
zip_filedata
=
await
this
.
zip
.
file
(
imageFile
.
id
).
async
(
'
blob
'
);
console
.
error
(
error
);
// create new blob with correct type
this
.
currentImportErrors
.
push
(
this
.
$gettext
(
'
Fehler beim Hochladen des Vorschaubildes.
'
));
const
filedata
=
zip_filedata
.
slice
(
0
,
zip_filedata
.
size
,
imageFile
.
attributes
[
'
mime-type
'
]);
});
this
.
setImportStructuresState
(
this
.
$gettext
(
'
Lade Vorschaubild hoch
'
));
this
.
uploadImageForStructuralElement
({
structuralElement
:
new_element
,
file
:
filedata
,
}).
catch
((
error
)
=>
{
console
.
error
(
error
);
this
.
currentImportErrors
.
push
(
this
.
$gettext
(
'
Fehler beim Hochladen des Vorschaubildes.
'
));
});
}
},
},
async
importContainer
(
container
,
structuralElement
,
files
)
{
async
importContainer
(
container
,
structuralElement
,
files
)
{
...
...
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