Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-4482 - add board link element #2844

Merged
merged 44 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a720ad2
add basic structure of link-element
OliverHappe Sep 18, 2023
eb90181
Merge branch 'main' of github.com:hpi-schul-cloud/nuxt-client into BC…
OliverHappe Sep 29, 2023
7935aa8
adds add link flow to link element
OliverHappe Sep 29, 2023
302bbb0
chore: improve ui of display mode of linkElement
hoeppner-dataport Oct 2, 2023
c1c3ac8
chore: break down openGraphData-property
hoeppner-dataport Oct 4, 2023
0e30270
Merge branch 'main' of github.com:hpi-schul-cloud/nuxt-client into BC…
hoeppner-dataport Oct 4, 2023
b4f1d47
refactor: use returned data to update modelValue
hoeppner-dataport Oct 4, 2023
b088d19
chore: fix boolean property
hoeppner-dataport Oct 4, 2023
731c297
chore: updated api
hoeppner-dataport Oct 4, 2023
c2510b4
temp solution for weaving response into modelValue
hoeppner-dataport Oct 4, 2023
12baa04
adjusts content-element-state
OliverHappe Oct 4, 2023
711f66b
adds adjusted board menu
OliverHappe Oct 5, 2023
46a5fcd
refactor: use languagekey in ui-comfirmation-dialog
hoeppner-dataport Oct 5, 2023
f0dac95
add conditional form entries
OliverHappe Oct 5, 2023
6966d4b
refactor submission element menu
OliverHappe Oct 5, 2023
2636dcf
refactor: external tool menu
hoeppner-dataport Oct 5, 2023
24f37c4
Merge branch 'BC-4482-add-board-link-element' of github.com:hpi-schul…
hoeppner-dataport Oct 5, 2023
4f7225c
fix tests
OliverHappe Oct 5, 2023
77c369a
fix some stuff
OliverHappe Oct 5, 2023
7600f2d
fixes remaining tests
OliverHappe Oct 5, 2023
fe0597d
adjust menu in external tool element
OliverHappe Oct 5, 2023
c547e0d
adds injection pattern for certain content element props
OliverHappe Oct 6, 2023
9a1ffaa
inject parameters for move-menuActions
hoeppner-dataport Oct 6, 2023
c360f21
chore: remove forgotten console.log
hoeppner-dataport Oct 6, 2023
26967d2
link image alt-text defaults to empty-string
hoeppner-dataport Oct 6, 2023
da8f289
chore: sonar cloud issues
hoeppner-dataport Oct 6, 2023
3a2fb57
chore: fix tests
hoeppner-dataport Oct 6, 2023
52c469c
add feature-flag
hoeppner-dataport Oct 6, 2023
5da6e18
improve test coverage on business logic
hoeppner-dataport Oct 6, 2023
6c0bf25
adds tests for ui-board menu
OliverHappe Oct 9, 2023
af6594f
chore: activate link element for presentation
hoeppner-dataport Oct 9, 2023
15b62cd
Merge branch 'BC-4482-add-board-link-element' of github.com:hpi-schul…
hoeppner-dataport Oct 9, 2023
3b5d438
add tests
OliverHappe Oct 9, 2023
7d0821f
Merge branch 'BC-4482-add-board-link-element' of github.com:hpi-schul…
OliverHappe Oct 9, 2023
1353420
Merge branch 'main' of github.com:hpi-schul-cloud/nuxt-client into BC…
hoeppner-dataport Oct 10, 2023
fc29090
chore: remove unneeded props
hoeppner-dataport Oct 10, 2023
ddb8582
chore: import board menu components
hoeppner-dataport Oct 10, 2023
a6b5e36
chore: remove external tool properties
hoeppner-dataport Oct 10, 2023
fb3f04c
chore: remove some props
hoeppner-dataport Oct 10, 2023
075c2db
add validatorfn type
OliverHappe Oct 10, 2023
22a292d
adds url sanitization on render
OliverHappe Oct 10, 2023
c06d54f
enable feature flags
OliverHappe Oct 10, 2023
cabc0f0
chore: add translations
hoeppner-dataport Oct 11, 2023
9bf6ad7
chore: enable move element by keyboard
hoeppner-dataport Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
{
group: ["@components/page-*", "*/../page-*", "../**/page-*/*"],
message:
"page-Modules have to be imported using the pattern '@page-<name>'",
"Page-Modules have to be imported using the pattern '@page-<name>'",
},
{
group: ["@components/ui-*", "*/../ui-*", "../**/ui-*/*"],
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"generate-client:h5p-editor": "node generate-client.js -u 'http://localhost:4448/api/v3/docs-json/' -p 'src/h5pEditorApi/v3' -c 'openapitools-for-h5p-editor.json'"
},
"dependencies": {
"@braintree/sanitize-url": "^6.0.4",
"@ckeditor/ckeditor5-vue2": "^3.0.1",
"@hpi-schul-cloud/ckeditor": "0.4.0",
"@mdi/js": "^7.2.96",
Expand Down
10 changes: 9 additions & 1 deletion src/components/data-board/BoardApi.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CreateContentElementBodyParams,
ExternalToolElementContent,
FileElementContent,
LinkElementContent,
RichTextElementContent,
RoomsApiFactory,
SubmissionContainerElementContent,
Expand Down Expand Up @@ -73,7 +74,7 @@ export const useBoardApi = () => {
if (element.type === ContentElementType.RichText) {
return {
content: element.content as RichTextElementContent,
type: ContentElementType.RichText,
type: element.type,
};
}

Expand All @@ -98,6 +99,13 @@ export const useBoardApi = () => {
};
}

if (element.type === ContentElementType.Link) {
return {
content: element.content as LinkElementContent,
type: ContentElementType.Link,
};
}

throw new Error("element.type mapping is undefined for updateElementCall");
};

Expand Down
42 changes: 32 additions & 10 deletions src/components/data-board/ContentElementState.composable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { watchDebounced } from "@vueuse/core";
import { ref, toRef, unref } from "vue";
import { computed, ComputedRef, Ref, ref, toRef, unref } from "vue";
import { useBoardApi } from "./BoardApi.composable";
import { AnyContentElement } from "@/types/board/ContentElement";
import { useErrorHandler } from "@/components/error-handling/ErrorHandler.composable";
Expand All @@ -11,28 +11,45 @@ export const useContentElementState = <T extends AnyContentElement>(
},
options: { autoSaveDebounce?: number } = { autoSaveDebounce: 300 }
) => {
const { handleError, notifyWithTemplate } = useErrorHandler();
const elementRef = toRef(props, "element");
const modelValue = ref<T["content"]>(unref<T>(elementRef).content);
const _elementRef: Ref<T> = toRef(props, "element");
const _responseValue = ref<T>(unref<T>(_elementRef));

const { handleError, notifyWithTemplate } = useErrorHandler();
const { updateElementCall } = useBoardApi();

watchDebounced(
elementRef.value,
async (elementRef) => {
await updateElement(unref(elementRef));
const modelValue = ref<T["content"]>(unref<T>(_elementRef).content);

const computedElement: ComputedRef<T> = computed(() => ({
..._elementRef.value,
..._responseValue.value,
}));

const isLoading = ref<boolean>(false);

watchDebounced<T["content"]>(
modelValue.value,
async (modelValue) => {
await updateElement(modelValue);
},
{ debounce: options.autoSaveDebounce, maxWait: 2500 }
);

// TODO: refactor this to be properly typed
const updateElement = async (element: T) => {
const updateElement = async (content: T["content"]) => {
isLoading.value = true;
const payload = {
...computedElement.value,
content: { ...content },
};
try {
await updateElementCall(element);
const response = await updateElementCall(payload);
_responseValue.value = response.data;
} catch (error) {
handleError(error, {
404: notifyWithTemplate("notUpdated", "boardElement"),
});
} finally {
isLoading.value = false;
}
};

Expand All @@ -42,5 +59,10 @@ export const useContentElementState = <T extends AnyContentElement>(
* Will be saved automatically after a debounce
*/
modelValue,
/**
* Contains the whole element as it is currently known in the backend
*/
computedElement,
isLoading,
};
};
2 changes: 1 addition & 1 deletion src/components/error-handling/ErrorHandler.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const useErrorHandler = () => {
if (handlerFunction) {
handlerFunction(responseError);
} else {
console.error(responseError);
console.error(error);
}
};

Expand Down
Loading