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-5444 - add due date by typing #2872

Merged
merged 57 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d312d30
don't show adjacent months
odalys-dataport Oct 12, 2023
589b589
first draft time picker autocorrect
odalys-dataport Oct 13, 2023
d8c2402
Merge branch 'main' of https://github.com/hpi-schul-cloud/nuxt-client…
odalys-dataport Oct 18, 2023
7dc7dca
Merge branch 'main' of https://github.com/hpi-schul-cloud/nuxt-client…
odalys-dataport Oct 19, 2023
803d72f
adjust reactivity handling
odalys-dataport Oct 19, 2023
1c83c33
rename function
odalys-dataport Oct 19, 2023
90ad8a3
adds wrappers for maska input masking
OliverHappe Oct 23, 2023
2a7bfee
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Oct 25, 2023
5d957b5
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Oct 25, 2023
193cb19
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Oct 25, 2023
1e4b27b
remove test component
odalys-dataport Oct 25, 2023
613a6ba
remove timepicker autocorrect changes
odalys-dataport Oct 25, 2023
db1b709
remove character prevent func, cause mask takes care of it
odalys-dataport Oct 25, 2023
76910d5
add typing & mask to datepicker
odalys-dataport Oct 25, 2023
8c42838
show error message on datepicker
odalys-dataport Oct 25, 2023
418dc9e
adjust error message for date picker
odalys-dataport Oct 25, 2023
27f1de2
adds explanatory comments
OliverHappe Oct 25, 2023
148398e
Merge branch 'BC-5444-typing-date' of github.com:hpi-schul-cloud/nuxt…
OliverHappe Oct 25, 2023
827dacc
adds test for inputmask factory
OliverHappe Oct 25, 2023
7fb69b6
adjust tests
OliverHappe Oct 25, 2023
fbce93f
refactors submission filter to use reactivity
OliverHappe Oct 25, 2023
6425315
rearrange file
odalys-dataport Oct 25, 2023
7dabb26
use util validators and move format validation
odalys-dataport Oct 26, 2023
2213979
use util validators in date picker
odalys-dataport Oct 26, 2023
c3804d5
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Oct 26, 2023
1ec869e
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Oct 26, 2023
efd1ef1
typing date first draft
odalys-dataport Oct 26, 2023
ec6e490
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Oct 27, 2023
e6f1263
move datetimepicker from feature to ui
odalys-dataport Oct 27, 2023
92246d8
maska.js as ts
odalys-dataport Oct 27, 2023
2db93e7
add message field to datetimepicker
odalys-dataport Nov 2, 2023
e64e023
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Nov 2, 2023
8ed7fe6
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Nov 2, 2023
0276922
show date required when time is set
odalys-dataport Nov 2, 2023
1ff1fe0
don't show message on open empty
odalys-dataport Nov 2, 2023
e9073cd
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Nov 2, 2023
e697403
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Nov 2, 2023
796cbcd
allow empty date
odalys-dataport Nov 3, 2023
cca4aa4
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Nov 3, 2023
489c6f6
reduce complexity
odalys-dataport Nov 3, 2023
c279749
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Nov 3, 2023
6d96060
fix typo
odalys-dataport Nov 3, 2023
67c1558
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Nov 7, 2023
81adb5a
small refactors
odalys-dataport Nov 7, 2023
a282834
small datetimepicker refactor
odalys-dataport Nov 7, 2023
a341d58
check for falsey
odalys-dataport Nov 7, 2023
0a9849f
remove on menutoggle
odalys-dataport Nov 7, 2023
7f9ce36
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Nov 7, 2023
a802817
maska directive mock variable
odalys-dataport Nov 8, 2023
8c90e70
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Nov 8, 2023
7d8e2a6
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Nov 8, 2023
e9c16d5
add tests for validators
odalys-dataport Nov 8, 2023
52dee5f
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Nov 8, 2023
073c363
added unit tests
odalys-dataport Nov 8, 2023
69badf2
Merge branch 'main' into BC-5444-typing-date
odalys-dataport Nov 8, 2023
df4ddd4
fix typo
odalys-dataport Nov 9, 2023
723b7a3
Merge branch 'BC-5444-typing-date' of https://github.com/hpi-schul-cl…
odalys-dataport Nov 9, 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
8 changes: 8 additions & 0 deletions __mocks__/maska.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This is a mock for the vMaska directive exported by maska package.
*/

// eslint-disable-next-line no-undef
const vMaska = jest.fn();

export { vMaska };
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 @@ -27,6 +27,7 @@
"flush-promises": "^1.0.2",
"katex": "^0.12.0",
"kjua": "^0.9.0",
"maska": "^2.1.10",
"mobile-drag-drop": "^3.0.0-rc.0",
"object-hash": "^3.0.0",
"tiptap": "^1.32.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { shallowMount, MountOptions } from "@vue/test-utils";
import SubmissionContentElementEdit from "./SubmissionContentElementEdit.vue";
import SubmissionItemsTeacherDisplay from "./SubmissionItemsTeacherDisplay.vue";
import { i18nMock, submissionsResponseFactory } from "@@/tests/test-utils";
import { DateTimePicker } from "@feature-date-time-picker";
import { DateTimePicker } from "@ui-date-time-picker";

const mockedSubmissions = submissionsResponseFactory.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { defineComponent, PropType } from "vue";
import { useI18n } from "@/composables/i18n.composable";
import { TeacherSubmission } from "../types/submission";
import SubmissionContentElementTitle from "./SubmissionContentElementTitle.vue";
import { DateTimePicker } from "@feature-date-time-picker";
import { DateTimePicker } from "@ui-date-time-picker";
import SubmissionItemsTeacherDisplay from "./SubmissionItemsTeacherDisplay.vue";

export default defineComponent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,20 @@
</template>

<script lang="ts">
import { defineComponent, PropType, computed, ref, watch, unref } from "vue";
import {
defineComponent,
PropType,
computed,
ref,
watch,
toRef,
Ref,
unref,
} from "vue";
import { TeacherSubmission, Status } from "../types/submission";
import { DataTableHeader } from "vuetify";
import { useI18n } from "@/composables/i18n.composable";
import { MaybeRef } from "@vueuse/core";

type StatusFilter = "all" | Status;

Expand Down Expand Up @@ -132,27 +142,51 @@ export default defineComponent({
},
];

const allSubmissions = computed<Array<TeacherSubmission>>(() => {
return props.submissions;
});
const panel = ref<number | undefined>(undefined);
const allSubmissions = toRef(props, "submissions");
const activeFilter = ref<StatusFilter>("all");

const openCount = computed<number>(() => {
return allSubmissions.value.filter((item) => {
return item.status === "open";
}).length;
});
const filteredSubmissions = computed(() =>
filterByStatus(allSubmissions, activeFilter)
);

const completedCount = computed<number>(() => {
return allSubmissions.value.filter((item) => {
return item.status === "completed";
}).length;
});
const filterByStatus = (
submissions: Ref<TeacherSubmission[]>,
statusFilter: MaybeRef<StatusFilter>
) => {
const status = unref(statusFilter);
return submissions.value.filter(
(item) => status === "all" || item.status === status
);
};

const overdueCount = computed<number>(() => {
return allSubmissions.value.filter((item) => {
return item.status === "expired";
}).length;
});
const setFilter = (filter: StatusFilter) => {
if (filter === activeFilter.value) {
activeFilter.value = "all";
} else {
activeFilter.value = filter;
}
};

const openCount = computed<number>(
() => filterByStatus(allSubmissions, "open").length
);

const completedCount = computed<number>(
() => filterByStatus(allSubmissions, "completed").length
);

const overdueCount = computed<number>(
() => filterByStatus(allSubmissions, "expired").length
);

const isDisabled = (count: number) => {
return count === 0;
};

const getTabIndex = (isDisabled: boolean) => {
return isDisabled ? -1 : 0;
};

const getStatusIcon = (item: TeacherSubmission) => {
if (item.status === "open") {
Expand All @@ -175,48 +209,7 @@ export default defineComponent({
: "filter-chip";
};

const isDisabled = (count: number) => {
return count === 0;
};

const getTabIndex = (isDisabled: boolean) => {
return isDisabled ? -1 : 0;
};

// Filter Functionality
const filteredSubmissions = ref<Array<TeacherSubmission>>(
unref(allSubmissions)
);
const activeFilter = ref<StatusFilter>("all");
const panel = ref<number | undefined>(undefined);

watch(allSubmissions, (newValue) => {
filteredSubmissions.value = newValue;
});

const filterByStatus = (statusFilter: StatusFilter) => {
if (statusFilter === "all") {
filteredSubmissions.value = allSubmissions.value;
return;
}

filteredSubmissions.value = allSubmissions.value.filter(
(item: TeacherSubmission) => {
return item.status === statusFilter;
}
);
};

const setFilter = (filter: StatusFilter) => {
if (filter === activeFilter.value) {
activeFilter.value = "all";
} else {
activeFilter.value = filter;
}
};

watch(activeFilter, (newFilter) => {
filterByStatus(newFilter);
watch(activeFilter, () => {
openPanel();
});

Expand Down
119 changes: 0 additions & 119 deletions src/components/feature-date-time-picker/DateTimePicker.vue

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe("DatePicker", () => {
expect(wrapper.emitted("update:date")).toHaveLength(1);
});

describe("when date is required", () => {
it("should not emit update:date event on empty input", async () => {
describe("when date is invalid", () => {
it("should emit error event", async () => {
setup({
date: new Date().toISOString(),
required: true,
Expand All @@ -76,6 +76,22 @@ describe("DatePicker", () => {
await wrapper.vm.$nextTick();

expect(wrapper.emitted("update:date")).toBeUndefined();
expect(wrapper.emitted("error")).toHaveLength(1);
});

it("should emit error event", async () => {
setup({
date: "55.55.5555",
});

const textField = wrapper.findComponent({ name: "v-text-field" });
const input = textField.find("input");

await input.setValue("");
await wrapper.vm.$nextTick();

expect(wrapper.emitted("update:date")).toBeUndefined();
expect(wrapper.emitted("error")).toHaveLength(1);
});
});
});
Loading
Loading