feat(help): made help-modules matching module access to ensure a personnalized help-page experience.
This commit is contained in:
parent
63472ebe88
commit
84e51d2c6b
BIN
src/assets/help-ss/default-employee-list.png
Normal file
BIN
src/assets/help-ss/default-employee-list.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 778 KiB |
BIN
src/assets/help-ss/default-employee-management.png
Normal file
BIN
src/assets/help-ss/default-employee-management.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 802 KiB |
BIN
src/assets/help-ss/default-validation-page.png
Normal file
BIN
src/assets/help-ss/default-validation-page.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 681 KiB |
|
|
@ -3,25 +3,28 @@
|
||||||
import default_dashboard from 'src/assets/help-ss/default-dashboard.png';
|
import default_dashboard from 'src/assets/help-ss/default-dashboard.png';
|
||||||
import default_personal_profile from 'src/assets/help-ss/default-personnal_profile.png';
|
import default_personal_profile from 'src/assets/help-ss/default-personnal_profile.png';
|
||||||
import default_timesheet from 'src/assets/help-ss/default-timesheet.png';
|
import default_timesheet from 'src/assets/help-ss/default-timesheet.png';
|
||||||
|
import default_employee_list from 'src/assets/help-ss/default-employee-list.png';
|
||||||
|
import default_employee_management from 'src/assets/help-ss/default-employee-management.png';
|
||||||
|
import default_validation_page from 'src/assets/help-ss/default-validation-page.png';
|
||||||
|
|
||||||
const default_images: Record<HelpModuleKey, string> = {
|
const default_images: Record<HelpModuleKey, string> = {
|
||||||
dashboard: default_dashboard,
|
dashboard: default_dashboard,
|
||||||
personal_profile: default_personal_profile,
|
personal_profile: default_personal_profile,
|
||||||
timesheets: default_timesheet,
|
timesheets: default_timesheet,
|
||||||
employee_list: '',
|
employee_list: default_employee_list,
|
||||||
employee_management: '',
|
employee_management: default_employee_management,
|
||||||
timesheets_approval: '',
|
timesheets_approval: default_validation_page,
|
||||||
};
|
};
|
||||||
|
|
||||||
import type { HelpModuleKey } from 'src/modules/help/models/help-module.model';
|
import type { HelpModuleKey, HelpModuleOptions } from 'src/modules/help/models/help-module.model';
|
||||||
import { useHelpStore } from 'src/stores/help-store';
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
help_module: HelpModuleKey;
|
help_module: HelpModuleKey;
|
||||||
|
options: HelpModuleOptions[];
|
||||||
moduleIndex: number;
|
moduleIndex: number;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const help_store = useHelpStore();
|
|
||||||
const help_module = props.help_module;
|
const help_module = props.help_module;
|
||||||
const current_path = ref<string>(default_images[help_module]);
|
const current_path = ref<string>(default_images[help_module]);
|
||||||
|
|
||||||
|
|
@ -70,7 +73,7 @@ const switchSide = (index: number) => {
|
||||||
<div class="col column">
|
<div class="col column">
|
||||||
|
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
v-for="option, index in help_store.help_module_options[help_module]"
|
v-for="option, index in options"
|
||||||
:key="index"
|
:key="index"
|
||||||
hide-expand-icon
|
hide-expand-icon
|
||||||
class="bg-gray-2 text-weight-bolder row"
|
class="bg-gray-2 text-weight-bolder row"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
|
export type HelpModuleKey =
|
||||||
|
| 'dashboard'
|
||||||
|
| 'personal_profile'
|
||||||
|
| 'timesheets'
|
||||||
|
| 'employee_list'
|
||||||
|
| 'employee_management'
|
||||||
|
| 'timesheets_approval';
|
||||||
|
|
||||||
export type HelpModuleOptions = {
|
export type HelpModuleOptions = {
|
||||||
label: string;
|
label: string;
|
||||||
path: string;
|
path: string;
|
||||||
|
|
@ -5,15 +13,8 @@ export type HelpModuleOptions = {
|
||||||
icon: string;
|
icon: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type HelpModuleKey =
|
|
||||||
| 'dashboard'
|
|
||||||
| 'personal_profile'
|
|
||||||
| 'timesheets'
|
|
||||||
| 'employee_list'
|
|
||||||
| 'employee_management'
|
|
||||||
| 'timesheets_approval';
|
|
||||||
|
|
||||||
export type Options = Record<HelpModuleKey, HelpModuleOptions[]>;
|
export type Options = Record<HelpModuleKey, HelpModuleOptions[]>;
|
||||||
|
export type PartialOptions = Partial<Record<HelpModuleKey, HelpModuleOptions[]>>;
|
||||||
|
|
||||||
|
|
||||||
//Shared images and descriptions
|
//Shared images and descriptions
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,11 @@ onMounted(async () => {
|
||||||
class="text-accent"
|
class="text-accent"
|
||||||
/>
|
/>
|
||||||
<help-module
|
<help-module
|
||||||
v-for="help_module, index in help_store.help_modules"
|
v-for="(options, help_module, index) in help_store.help_module_filters"
|
||||||
:key="help_module"
|
:key="help_module"
|
||||||
:help_module="help_module"
|
:help_module="help_module"
|
||||||
:module-index="index"
|
:module-index="index"
|
||||||
|
:options="options"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</q-page>
|
</q-page>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref } from "vue";
|
import { computed, ref } from "vue";
|
||||||
import { HelpService } from "src/modules/help/services/help.service";
|
import { HelpService } from "src/modules/help/services/help.service";
|
||||||
import { type Options, type HelpModuleKey, profile_options, timesheets_options, employee_list_options, employee_management_options, timesheets_approval_options, dashboard_options } from "src/modules/help/models/help-module.model";
|
import { profile_options, timesheets_options, employee_list_options, employee_management_options, timesheets_approval_options, dashboard_options } from "src/modules/help/models/help-module.model";
|
||||||
|
import type { Options, HelpModuleKey, HelpModuleOptions } from "src/modules/help/models/help-module.model";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const useHelpStore = defineStore('help', () => {
|
export const useHelpStore = defineStore('help', () => {
|
||||||
const is_loading = ref(false);
|
const is_loading = ref(false);
|
||||||
const help_modules = ref<HelpModuleKey[]>([]);
|
const help_modules = ref<HelpModuleKey[]>([]);
|
||||||
const help_module_options = ref<Options>({
|
|
||||||
|
const help_module_details = ref<Options>({
|
||||||
dashboard: dashboard_options,
|
dashboard: dashboard_options,
|
||||||
personal_profile: profile_options,
|
personal_profile: profile_options,
|
||||||
timesheets: timesheets_options,
|
timesheets: timesheets_options,
|
||||||
|
|
@ -15,29 +19,40 @@ export const useHelpStore = defineStore('help', () => {
|
||||||
timesheets_approval: timesheets_approval_options,
|
timesheets_approval: timesheets_approval_options,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const help_module_filters = computed<Record<HelpModuleKey, HelpModuleOptions[]>>(() => {
|
||||||
|
const entries = help_modules.value
|
||||||
|
.map((key) => {
|
||||||
|
const options = help_module_details.value[key];
|
||||||
|
return options ? ([key, options] as const) : null;
|
||||||
|
})
|
||||||
|
.filter(
|
||||||
|
(entry): entry is readonly [HelpModuleKey, HelpModuleOptions[]] =>
|
||||||
|
entry !== null
|
||||||
|
);
|
||||||
|
|
||||||
|
return Object.fromEntries(entries) as Record<HelpModuleKey, HelpModuleOptions[]>;
|
||||||
|
});
|
||||||
|
|
||||||
const getHelpModules = async (): Promise<boolean> => {
|
const getHelpModules = async (): Promise<boolean> => {
|
||||||
is_loading.value = true;
|
is_loading.value = true;
|
||||||
try {
|
try {
|
||||||
const response = await HelpService.getHelpModules();
|
const response = await HelpService.getHelpModules();
|
||||||
if (response.success && response.data) help_modules.value = response.data;
|
if (response.success && response.data) help_modules.value = response.data;
|
||||||
is_loading.value = false;
|
|
||||||
return response.success;
|
return response.success;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('An error occured while fetching Help modules', error);
|
console.error('An error occured while fetching Help modules', error);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
is_loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildHelpModuleOptions = () => {
|
|
||||||
//todo: build a custom versions of help_module_options with only the module the employee has access
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
is_loading,
|
is_loading,
|
||||||
help_modules,
|
help_modules,
|
||||||
help_module_options,
|
help_module_details,
|
||||||
|
help_module_filters,
|
||||||
getHelpModules,
|
getHelpModules,
|
||||||
buildHelpModuleOptions,
|
};
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue
Block a user