2024-05-15 22:57:54 +02:00
|
|
|
/* eslint no-var: "error"*/
|
|
|
|
/* eslint no-console: "off"*/
|
|
|
|
/* eslint no-unused-vars: warn */
|
|
|
|
/* eslint max-len: ["error", { "code": 160 }] */
|
2024-06-05 23:27:00 +02:00
|
|
|
/* eslint no-trailing-spaces: warn */
|
2024-06-05 22:22:19 +02:00
|
|
|
/* eslint max-depth: ["error", 6] */
|
2024-05-15 22:57:54 +02:00
|
|
|
/* eslint-env es6*/
|
2023-05-17 21:19:14 +02:00
|
|
|
|
2023-08-19 17:54:40 +02:00
|
|
|
import {SimpleLine} from "./simpleline/simpleline";
|
2023-05-17 21:19:14 +02:00
|
|
|
import {call} from 'core/ajax';
|
|
|
|
import notification from 'core/notification';
|
2024-06-05 22:22:19 +02:00
|
|
|
import {loadStringKeys, loadStrings, strformat} from './util/string-helper';
|
|
|
|
import {formatDate, addDays, datespaninfo} from './util/date-helper';
|
|
|
|
import {objCopy, transportItem} from './studyplan-processor';
|
2023-08-19 17:54:40 +02:00
|
|
|
import Debugger from './util/debugger';
|
2024-02-07 22:33:16 +01:00
|
|
|
import Config from 'core/config';
|
2024-06-05 22:22:19 +02:00
|
|
|
import {download, upload} from './downloader';
|
2024-06-03 23:24:16 +02:00
|
|
|
import {processStudyplan, processStudyplanPage} from './studyplan-processor';
|
2024-06-05 22:22:19 +02:00
|
|
|
import {premiumenabled} from "./util/premium";
|
2024-06-03 23:24:16 +02:00
|
|
|
import FitTextVue from './util/fittext-vue';
|
2024-06-05 22:22:19 +02:00
|
|
|
import {settings} from "./util/settings";
|
2023-09-01 12:27:56 +02:00
|
|
|
import TSComponents from './treestudyplan-components';
|
2023-10-20 15:08:54 +02:00
|
|
|
import mFormComponents from "./util/mform-helper";
|
2024-04-21 23:08:03 +02:00
|
|
|
import pSideBarComponents from "./util/psidebar-vue";
|
2023-09-01 12:27:56 +02:00
|
|
|
|
2024-03-09 22:51:34 +01:00
|
|
|
import {Drag, Drop, DropList} from './vue-easy-dnd/vue-easy-dnd.esm';
|
|
|
|
|
2023-09-08 12:47:29 +02:00
|
|
|
const STUDYPLAN_EDITOR_FIELDS =
|
2024-06-05 22:22:19 +02:00
|
|
|
['name', 'shortname', 'description', 'idnumber', 'context_id', 'aggregation', 'aggregation_config'];
|
2023-09-08 12:47:29 +02:00
|
|
|
const PERIOD_EDITOR_FIELDS =
|
2024-06-05 22:22:19 +02:00
|
|
|
['fullname', 'shortname', 'startdate', 'enddate'];
|
2023-05-17 21:19:14 +02:00
|
|
|
|
2023-08-04 22:54:32 +02:00
|
|
|
const LINE_GRAVITY = 1.3;
|
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
export default {
|
2024-05-15 22:57:54 +02:00
|
|
|
install(Vue/* ,options */) {
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('drag', Drag);
|
|
|
|
Vue.component('drop', Drop);
|
|
|
|
Vue.component('drop-list', DropList);
|
2023-09-01 12:27:56 +02:00
|
|
|
Vue.use(TSComponents);
|
2023-10-20 15:08:54 +02:00
|
|
|
Vue.use(mFormComponents);
|
2024-04-21 23:08:03 +02:00
|
|
|
Vue.use(pSideBarComponents);
|
2024-06-03 23:24:16 +02:00
|
|
|
Vue.use(FitTextVue);
|
2023-05-17 21:19:14 +02:00
|
|
|
let debug = new Debugger("treestudyplan-editor");
|
2024-06-05 22:22:19 +02:00
|
|
|
/* **********************************
|
2023-05-17 21:19:14 +02:00
|
|
|
* *
|
|
|
|
* Treestudyplan Editor components *
|
|
|
|
* *
|
2024-06-05 22:22:19 +02:00
|
|
|
* **********************************/
|
2023-05-17 21:19:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if element is visible
|
|
|
|
* @param {Object} elem The element to check
|
|
|
|
* @returns {boolean} True if visible
|
|
|
|
*/
|
2024-05-15 22:57:54 +02:00
|
|
|
function isVisible(elem) {
|
2024-06-05 22:22:19 +02:00
|
|
|
return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create new eventbus for interaction between item components
|
|
|
|
const ItemEventBus = new Vue();
|
|
|
|
|
2024-03-22 22:01:42 +01:00
|
|
|
/*
|
2023-11-27 23:11:17 +01:00
|
|
|
// Add event listener for the edit mode event so we can react to it, or at the very least ignore it
|
|
|
|
document.addEventListener(editSwEventTypes.editModeSet,(e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
ItemEventBus.$emit('editModeSet', e.detail.editMode);
|
|
|
|
});
|
2024-03-22 22:01:42 +01:00
|
|
|
*/
|
2023-11-27 23:11:17 +01:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
let stringKeys = loadStringKeys({
|
2023-05-17 21:19:14 +02:00
|
|
|
conditions: [
|
2024-06-05 22:22:19 +02:00
|
|
|
{value: 'ALL', textkey: 'condition_all'},
|
|
|
|
{value: 'ANY', textkey: 'condition_any'},
|
2023-05-17 21:19:14 +02:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2024-06-03 23:24:16 +02:00
|
|
|
let strings = loadStrings({
|
2024-06-05 22:22:19 +02:00
|
|
|
studyplanText: {
|
|
|
|
'studyline_editmode': 'studyline_editmode',
|
|
|
|
'toolbox_toggle': 'toolbox_toggle',
|
|
|
|
'editmode_modules_hidden': 'editmode_modules_hidden',
|
|
|
|
'studyline_add': 'studyline_add',
|
|
|
|
add: 'add@core',
|
|
|
|
edit: 'edit@core',
|
|
|
|
'delete': "delete@core",
|
|
|
|
'studyline_name': 'studyline_name',
|
|
|
|
'studyline_name_ph': 'studyline_name_ph',
|
|
|
|
'studyline_shortname': 'studyline_shortname',
|
|
|
|
'studyline_shortname_ph': 'studyline_shortname_ph',
|
|
|
|
'studyline_enrollable': 'studyline_enrollable',
|
|
|
|
'studyline_enrolroles': 'studyline_enrolroles',
|
|
|
|
'studyline_color': 'studyline_color',
|
2023-05-17 21:19:14 +02:00
|
|
|
associations: 'associations',
|
2024-06-05 22:22:19 +02:00
|
|
|
'associated_cohorts': 'associated_cohorts',
|
|
|
|
'associated_users': 'associated_users',
|
|
|
|
'studyline_edit': 'studyline_edit',
|
|
|
|
'studyplan_name': 'studyplan_name',
|
|
|
|
'studyplan_name_ph': 'studyplan_name_ph',
|
|
|
|
'studyplan_shortname': 'studyplan_shortname',
|
|
|
|
'studyplan_shortname_ph': 'studyplan_shortname_ph',
|
|
|
|
'studyplan_description': 'studyplan_description',
|
|
|
|
'studyplan_description_ph': 'studyplan_description_ph',
|
|
|
|
'studyplan_idnumber': 'studyplan_idnumber',
|
|
|
|
'studyplan_idnumber_ph': 'studyplan_idnumber_ph',
|
|
|
|
'studyplan_slots': 'studyplan_slots',
|
|
|
|
'studyplan_startdate': 'studyplan_startdate',
|
|
|
|
'studyplan_enddate': 'studyplan_enddate',
|
|
|
|
'line_enrollable_0': 'line_enrollable:0',
|
|
|
|
'line_enrollable_1': 'line_enrollable:1',
|
|
|
|
'line_enrollable_2': 'line_enrollable:2',
|
|
|
|
'line_enrollable_3': 'line_enrollable:3',
|
2024-05-27 22:11:32 +02:00
|
|
|
drophere: 'drophere',
|
2024-06-05 22:22:19 +02:00
|
|
|
studylineConfirmRemove: 'studyline_confirm_remove',
|
|
|
|
studyplanConfirmRemove: 'studyplan_confirm_remove',
|
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
studyplanAdvanced: {
|
|
|
|
'advanced_tools': 'advanced_tools',
|
|
|
|
'confirm_cancel': 'confirm_cancel',
|
|
|
|
'confirm_ok': 'confirm_ok',
|
|
|
|
success: 'success@core',
|
|
|
|
error: 'failed@completion',
|
|
|
|
'advanced_converted': 'advanced_converted',
|
|
|
|
'advanced_skipped': 'advanced_skipped',
|
|
|
|
'advanced_failed': 'advanced_failed',
|
|
|
|
'advanced_locked': 'advanced_locked',
|
|
|
|
'advanced_multiple': 'advanced_multiple',
|
|
|
|
'advanced_error': 'advanced_error',
|
|
|
|
'advanced_tools_heading': 'advanced_tools_heading',
|
|
|
|
'advanced_warning_title': 'advanced_warning_title',
|
|
|
|
'advanced_warning': 'advanced_warning',
|
|
|
|
'advanced_pick_scale': 'advanced_pick_scale',
|
|
|
|
'advanced_course_manipulation_title': 'advanced_course_manipulation_title',
|
2024-06-05 23:27:00 +02:00
|
|
|
'advanced_bulk_course_timing': 'advanced_bulk_course_timing',
|
|
|
|
'advanced_bulk_course_timing_desc': 'advanced_bulk_course_timing_desc',
|
2024-06-05 22:22:19 +02:00
|
|
|
'advanced_force_scale_title': 'advanced_force_scale_title',
|
|
|
|
'advanced_force_scale_desc': 'advanced_force_scale_desc',
|
|
|
|
'advanced_force_scale_button': 'advanced_force_scale_button',
|
|
|
|
'advanced_confirm_header': 'advanced_confirm_header',
|
|
|
|
'advanced_force_scale_confirm': 'advanced_force_scale_confirm',
|
|
|
|
'advanced_backup_restore': 'advanced_backup_restore',
|
|
|
|
'advanced_restore': 'advanced_restore',
|
|
|
|
'advanced_backup': 'advanced_backup',
|
|
|
|
'advanced_restore_pages': 'advanced_restore_pages',
|
|
|
|
'advanced_restore_lines': 'advanced_restore_lines',
|
|
|
|
'advanced_backup_plan': 'advanced_backup_plan',
|
|
|
|
'advanced_backup_page': 'advanced_backup_page',
|
|
|
|
'advanced_export': 'advanced_export',
|
|
|
|
'advanced_export_csv_plan': 'advanced_export_csv_plan',
|
|
|
|
'advanced_export_csv_page': 'advanced_export_csv_page',
|
|
|
|
'advanced_import_from_file': 'advanced_import_from_file',
|
|
|
|
'advanced_purge': "advanced_purge",
|
|
|
|
'advanced_purge_plan': "advanced_purge_plan",
|
|
|
|
'advanced_purge_plan_expl': "advanced_purge_plan_expl",
|
|
|
|
'advanced_purge_page': "advanced_purge_page",
|
|
|
|
'advanced_purge_page_expl': "advanced_purge_page_expl",
|
|
|
|
'advanced_cascade_cohortsync_title': "advanced_cascade_cohortsync_title",
|
|
|
|
'advanced_cascade_cohortsync_desc': "advanced_cascade_cohortsync_desc",
|
|
|
|
'advanced_cascade_cohortsync': "advanced_cascade_cohortsync",
|
2023-11-11 20:17:45 +01:00
|
|
|
currentpage: "currentpage",
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
studyplanEdit: {
|
2024-07-10 19:39:05 +02:00
|
|
|
studyplanEdit: 'studyplan_edit',
|
2024-06-05 22:22:19 +02:00
|
|
|
'studyplan_add': 'studyplan_add',
|
|
|
|
'studyplanpage_add': 'studyplanpage_add',
|
|
|
|
'studyplanpage_edit': 'studyplanpage_edit',
|
|
|
|
'info_periodsextended': 'studyplanpage_info_periodsextended',
|
2023-12-12 23:44:02 +01:00
|
|
|
warning: 'warning@core',
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
periodEdit: {
|
2023-07-28 23:43:11 +02:00
|
|
|
edit: 'period_edit',
|
|
|
|
fullname: 'studyplan_name',
|
|
|
|
shortname: 'studyplan_shortname',
|
|
|
|
startdate: 'studyplan_startdate',
|
|
|
|
enddate: 'studyplan_enddate',
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
courseTiming: {
|
2023-07-30 04:08:57 +02:00
|
|
|
title: 'course_timing_title',
|
|
|
|
desc: 'course_timing_desc',
|
|
|
|
question: 'course_timing_question',
|
|
|
|
warning: 'course_timing_warning',
|
2024-06-05 22:22:19 +02:00
|
|
|
'timing_ok': 'course_timing_ok',
|
|
|
|
'timing_off': 'course_timing_off',
|
2023-09-02 23:25:21 +02:00
|
|
|
course: 'course@core',
|
2023-07-30 04:08:57 +02:00
|
|
|
period: 'period',
|
|
|
|
yes: 'yes$core',
|
|
|
|
no: 'no$core',
|
|
|
|
duration: 'duration',
|
|
|
|
years: 'years$core',
|
|
|
|
year: 'year$core',
|
|
|
|
weeks: 'weeks$core',
|
|
|
|
week: 'week$core',
|
|
|
|
days: 'days$core',
|
|
|
|
day: 'day$core',
|
|
|
|
rememberchoice: 'course_timing_rememberchoice',
|
2023-08-04 12:10:43 +02:00
|
|
|
hidewarning: 'course_timing_hidewarning',
|
2023-08-06 23:17:36 +02:00
|
|
|
periodspan: 'course_period_span',
|
2023-08-07 11:48:06 +02:00
|
|
|
periods: 'periods',
|
2024-06-05 22:22:19 +02:00
|
|
|
'periodspan_desc': 'course_period_span_desc',
|
2023-07-30 04:08:57 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
studyplanAssociate: {
|
|
|
|
'associations': 'associations',
|
|
|
|
'associated_cohorts': 'associated_cohorts',
|
|
|
|
'associated_users': 'associated_users',
|
|
|
|
'associated_coaches': 'associated_coaches',
|
|
|
|
'associate_cohorts': 'associate_cohorts',
|
|
|
|
'associate_users': 'associate_users',
|
|
|
|
'associate_coached': 'associate_coaches',
|
|
|
|
'add_association': 'add_association',
|
|
|
|
'delete_association': 'delete_association',
|
|
|
|
'associations_empty': 'associations_empty',
|
|
|
|
'associations_search': 'associations_search',
|
2023-05-17 21:19:14 +02:00
|
|
|
cohorts: 'cohorts',
|
|
|
|
users: 'users',
|
2024-03-08 17:05:07 +01:00
|
|
|
coaches: 'coaches',
|
2023-05-17 21:19:14 +02:00
|
|
|
selected: 'selected',
|
|
|
|
name: 'name',
|
|
|
|
context: 'context',
|
2024-05-10 15:22:52 +02:00
|
|
|
search: 'search',
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
itemText: {
|
|
|
|
'select_conditions': "select_conditions",
|
|
|
|
'item_configuration': "item_configuration",
|
2023-09-02 23:25:21 +02:00
|
|
|
ok: "ok@core",
|
2024-06-05 22:22:19 +02:00
|
|
|
'delete': "delete@core",
|
|
|
|
'item_delete_message': "item_delete_message",
|
|
|
|
'type_course': "course@core",
|
|
|
|
'type_junction': "tool-junction",
|
|
|
|
'type_start': "tool-start",
|
|
|
|
'type_finish': "tool-finish",
|
|
|
|
'type_badge': "tool-badge",
|
|
|
|
'type_invalid': "course-invalid",
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
itemCourseText: {
|
|
|
|
'select_conditions': "select_conditions",
|
|
|
|
'select_grades': "select_grades",
|
|
|
|
'coursetiming_past': "coursetiming_past",
|
|
|
|
'coursetiming_present': "coursetiming_present",
|
|
|
|
'coursetiming_future': "coursetiming_future",
|
|
|
|
'grade_include': "grade_include",
|
|
|
|
'grade_require': "grade_require",
|
2023-09-02 23:25:21 +02:00
|
|
|
ok: "ok@core",
|
|
|
|
cancel: "cancel@core",
|
2024-06-05 22:22:19 +02:00
|
|
|
'delete': "delete@core",
|
2024-05-10 15:22:52 +02:00
|
|
|
noenddate: "noenddate",
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
invalid: {
|
|
|
|
error: 'error',
|
|
|
|
},
|
2023-06-03 00:01:18 +02:00
|
|
|
completion: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'completion_completed': "completion_completed",
|
|
|
|
'completion_incomplete': "completion_incomplete",
|
|
|
|
'aggregation_all': "aggregation_all",
|
|
|
|
'aggregation_any': "aggregation_any",
|
|
|
|
'aggregation_overall_all': "aggregation_overall_all",
|
|
|
|
'aggregation_overall_any': "aggregation_overall_any",
|
|
|
|
'completion_not_configured': "completion_not_configured",
|
|
|
|
'configure_completion': "configure_completion",
|
2023-06-03 00:01:18 +02:00
|
|
|
},
|
2023-11-23 07:44:04 +01:00
|
|
|
competency: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'competency_not_configured': "competency_not_configured",
|
|
|
|
'configure_competency': "configure_competency",
|
2023-11-26 22:58:26 +01:00
|
|
|
when: "when",
|
|
|
|
required: "required",
|
|
|
|
points: "points@core_grades",
|
|
|
|
heading: "competency_heading",
|
|
|
|
details: "competency_details",
|
2023-11-23 07:44:04 +01:00
|
|
|
},
|
2023-06-03 00:01:18 +02:00
|
|
|
badge: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'share_badge': "share_badge",
|
2023-06-03 00:01:18 +02:00
|
|
|
dateissued: "dateissued",
|
|
|
|
dateexpire: "dateexpire",
|
|
|
|
badgeinfo: "badgeinfo",
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
2024-03-09 08:23:42 +01:00
|
|
|
toolbox: {
|
|
|
|
toolbox: 'toolbox',
|
|
|
|
toolbarRight: 'toolbar-right',
|
|
|
|
courses: 'courses',
|
|
|
|
flow: 'flow',
|
|
|
|
toolJunction: 'tool-junction',
|
|
|
|
toolFinish: 'tool-finish',
|
|
|
|
toolStart: 'tool-start',
|
|
|
|
badges: 'badges',
|
|
|
|
relatedbages: 'relatedbages@badges',
|
|
|
|
filter: 'filter@core',
|
2024-05-31 22:32:43 +02:00
|
|
|
sitebadges: 'sitebadges@badges',
|
2024-03-09 08:23:42 +01:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
2023-07-07 21:45:09 +02:00
|
|
|
* T-STUDYPLAN-ADVANCED
|
2023-05-17 21:19:14 +02:00
|
|
|
*/
|
2023-07-07 21:45:09 +02:00
|
|
|
Vue.component('t-studyplan-advanced', {
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2023-11-11 20:17:45 +01:00
|
|
|
selectedpage: {
|
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-11-11 20:17:45 +01:00
|
|
|
}
|
2023-11-05 22:33:57 +01:00
|
|
|
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 22:22:19 +02:00
|
|
|
forceScales: {
|
|
|
|
selectedScale: null,
|
2023-07-07 21:45:09 +02:00
|
|
|
result: [],
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.studyplanAdvanced,
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2024-06-05 22:22:19 +02:00
|
|
|
scales() {
|
2023-07-07 21:45:09 +02:00
|
|
|
return [{
|
|
|
|
id: null,
|
|
|
|
disabled: true,
|
|
|
|
name: this.text.advanced_pick_scale,
|
|
|
|
}].concat(this.value.advanced.force_scales.scales);
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
forceScalesStart() {
|
|
|
|
// Set confirmation box
|
|
|
|
const self = this;
|
|
|
|
this.$bvModal.msgBoxConfirm(this.text.advanced_force_scale_confirm, {
|
2023-07-07 21:45:09 +02:00
|
|
|
title: this.text.advanced_force_scale_confirm,
|
|
|
|
okVariant: 'danger',
|
|
|
|
okTitle: this.text.confirm_ok,
|
|
|
|
cancelTitle: this.text.confirm_cancel,
|
2024-06-05 22:22:19 +02:00
|
|
|
}).then(value => {
|
|
|
|
if (value == true) {
|
2023-07-07 21:45:09 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_force_studyplan_scale',
|
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'studyplan_id': this.value.id,
|
|
|
|
'scale_id': this.forceScales.selectedScale,
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
self.forceScales.result = response;
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
exportPage(format) {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
if (format == undefined || !["json", "csv"].includes(format)) {
|
2023-07-07 21:45:09 +02:00
|
|
|
format = "json";
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
call([{
|
2023-11-11 20:17:45 +01:00
|
|
|
methodname: 'local_treestudyplan_export_page',
|
2023-07-07 21:45:09 +02:00
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'page_id': this.selectedpage.id,
|
2023-07-07 21:45:09 +02:00
|
|
|
format: format,
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
download(self.value.shortname + ".page." + format, response.content, response.format);
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-11-11 20:17:45 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
exportPlan() {
|
2023-11-11 20:17:45 +01:00
|
|
|
const self = this;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_export_plan',
|
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'studyplan_id': this.value.id,
|
2023-11-11 20:17:45 +01:00
|
|
|
format: "json",
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
download(self.value.shortname + ".plan.json", response.content, response.format);
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-11-11 20:17:45 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
bulkCourseTiming() {
|
2023-11-11 20:17:45 +01:00
|
|
|
const self = this;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_bulk_course_timing',
|
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'page_id': this.selectedpage.id,
|
2023-11-11 20:17:45 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success) {
|
2023-11-11 20:17:45 +01:00
|
|
|
// Reloading the webpage saves trouble reloading the specific page updated.
|
|
|
|
location.reload();
|
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$bvModal.msgBoxOk(response.msg, {title: "Could not set bulk course timing"});
|
|
|
|
debug.error("Could not set bulk course timing: ", response.msg);
|
2023-11-11 20:17:45 +01:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
importStudylines() {
|
|
|
|
const self = this;
|
|
|
|
upload((filename, content)=>{
|
2023-07-07 21:45:09 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_import_studylines',
|
2023-11-11 20:17:45 +01:00
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'page_id': this.selectedpage.id,
|
2023-11-11 20:17:45 +01:00
|
|
|
content: content,
|
|
|
|
format: "application/json",
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success) {
|
2023-11-11 20:17:45 +01:00
|
|
|
location.reload();
|
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$bvModal.msgBoxOk(response.msg, {title: "Import failed"});
|
|
|
|
debug.error("Import failed: ", response.msg);
|
2023-11-11 20:17:45 +01:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-11-11 20:17:45 +01:00
|
|
|
}, "application/json");
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
importPages() {
|
|
|
|
const self = this;
|
|
|
|
upload((filename, content)=>{
|
2023-11-11 20:17:45 +01:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_import_pages',
|
2023-07-07 21:45:09 +02:00
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'studyplan_id': this.value.id,
|
2023-07-07 21:45:09 +02:00
|
|
|
content: content,
|
|
|
|
format: "application/json",
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success) {
|
2023-07-07 21:45:09 +02:00
|
|
|
location.reload();
|
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$bvModal.msgBoxOk(response.msg, {title: "Import failed"});
|
|
|
|
debug.error("Import failed: ", response.msg);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-07-07 21:45:09 +02:00
|
|
|
}, "application/json");
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
purgeStudyplan() {
|
|
|
|
const self = this;
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
2023-07-07 21:45:09 +02:00
|
|
|
methodname: 'local_treestudyplan_delete_studyplan',
|
|
|
|
args: {
|
|
|
|
id: this.value.id,
|
|
|
|
force: true,
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success) {
|
2023-07-07 21:45:09 +02:00
|
|
|
location.reload();
|
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$bvModal.msgBoxOk(response.msg, {title: "Could not delete plan "});
|
|
|
|
debug.error("Could not delete plan: ", response.msg);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
purgeStudyplanpage() {
|
|
|
|
const self = this;
|
2023-11-11 20:17:45 +01:00
|
|
|
if (this.selectedpage) {
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_delete_studyplanpage',
|
|
|
|
args: {
|
|
|
|
id: this.selectedpage.id,
|
|
|
|
force: true,
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success) {
|
2023-11-11 20:17:45 +01:00
|
|
|
location.reload();
|
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$bvModal.msgBoxOk(response.msg, {title: "Could not delete page"});
|
|
|
|
debug.error("Could not delete page: ", response.msg);
|
2023-11-11 20:17:45 +01:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-11-11 20:17:45 +01:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
cascadeCohortsync() {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_cascade_cohortsync',
|
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'studyplan_id': this.value.id,
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
self.$bvModal.msgBoxOk(response.success ? self.text.success : self.text.error,
|
|
|
|
{title: self.text.advanced_cascade_cohortsync});
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
modalClose() {
|
|
|
|
this.forceScales.result = [];
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
|
|
|
},
|
2023-09-08 12:47:29 +02:00
|
|
|
template:
|
2023-05-17 21:19:14 +02:00
|
|
|
`
|
2023-07-07 21:45:09 +02:00
|
|
|
<span>
|
2023-09-08 12:47:29 +02:00
|
|
|
<a v-if="value.advanced"
|
|
|
|
href='#'
|
|
|
|
@click.prevent=''
|
|
|
|
class='text-danger'
|
2023-07-07 21:45:09 +02:00
|
|
|
v-b-modal="'t-studyplan-'+value.id+'-advanced'"
|
2023-09-02 20:34:33 +02:00
|
|
|
><i class='fa fa-wrench'></i> {{text.advanced_tools}}</a>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-modal v-if="value.advanced"
|
2023-07-07 21:45:09 +02:00
|
|
|
:id="'t-studyplan-'+value.id+'-advanced'"
|
|
|
|
size="lg"
|
|
|
|
:title="text.advanced_tools_heading"
|
|
|
|
ok-only
|
2024-06-05 22:22:19 +02:00
|
|
|
@hide="modalClose"
|
2023-11-11 20:17:45 +01:00
|
|
|
body-class="p-0"
|
2023-05-17 21:19:14 +02:00
|
|
|
>
|
2023-07-07 21:45:09 +02:00
|
|
|
<b-tabs card>
|
|
|
|
<b-tab :title="text.advanced_warning_title" active>
|
|
|
|
{{ text.advanced_warning}}
|
|
|
|
</b-tab>
|
|
|
|
<b-tab :title="text.advanced_course_manipulation_title" >
|
2023-11-11 20:17:45 +01:00
|
|
|
<h3>{{ text.advanced_cascade_cohortsync_title}}</h3>
|
|
|
|
<p>{{ text.advanced_cascade_cohortsync_desc}}</p>
|
|
|
|
<p class="mt-2"><b-button
|
2023-07-07 21:45:09 +02:00
|
|
|
variant="info"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="cascadeCohortsync"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_cascade_cohortsync}}</b-button></p>
|
|
|
|
<h3>{{ text.advanced_bulk_course_timing}}</h3>
|
|
|
|
<p>{{ text.advanced_bulk_course_timing_desc}}</p>
|
|
|
|
<p>{{text.currentpage}} <i>{{selectedpage.fullname}}</i></p>
|
|
|
|
<p class="mt-2"><b-button
|
|
|
|
variant="info"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="bulkCourseTiming"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_bulk_course_timing}}</b-button></p>
|
|
|
|
<template v-if="['bistate','tristate'].includes(value.aggregation)">
|
|
|
|
<h3>{{ text.advanced_force_scale_title}}</h3>
|
2023-07-07 21:45:09 +02:00
|
|
|
{{ text.advanced_force_scale_desc}}
|
2024-06-05 22:22:19 +02:00
|
|
|
<p class="mt-2"><b-form-select v-model="forceScales.selectedScale"
|
2023-07-07 21:45:09 +02:00
|
|
|
:options="scales" text-field="name" value-field="id"
|
2023-11-11 20:17:45 +01:00
|
|
|
></b-form-select>
|
|
|
|
<b-button
|
|
|
|
variant="danger"
|
2024-06-05 22:22:19 +02:00
|
|
|
:disabled="forceScales.selectedScale == null"
|
|
|
|
@click.prevent="forceScalesStart"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_force_scale_button}}</b-button>
|
|
|
|
</p>
|
|
|
|
<p class="mt-2">
|
2024-06-05 22:22:19 +02:00
|
|
|
<ul class='t-advanced-scrollable' v-if="forceScales.result.length > 0">
|
|
|
|
<li v-for="c in forceScales.result">
|
2023-07-07 21:45:09 +02:00
|
|
|
<span class='t-advanced-coursename'>{{c.course.fullname}}</span>
|
|
|
|
<ul v-if="c.grades.length > 0">
|
2023-11-11 20:17:45 +01:00
|
|
|
<li v-for='g in c.grades'
|
|
|
|
><span class='t-advanced-gradename'><span v-html="g.name"></span></span>
|
2023-07-07 21:45:09 +02:00
|
|
|
<span v-if="g.changed == 'converted'" class='t-advanced-status changed'
|
|
|
|
>{{text.advanced_converted}}</span
|
|
|
|
><span v-else-if="g.changed == 'skipped'" class='t-advanced-status skipped'
|
|
|
|
>{{text.advanced_skipped}}</span
|
2023-11-11 20:17:45 +01:00
|
|
|
><span v-else class='t-advanced-status skipped'
|
2023-07-07 21:45:09 +02:00
|
|
|
>{{text.advanced_error}}</span
|
2023-11-11 20:17:45 +01:00
|
|
|
></li>
|
2023-07-07 21:45:09 +02:00
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2023-11-11 20:17:45 +01:00
|
|
|
</p>
|
|
|
|
</template>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-tab>
|
2023-11-11 20:17:45 +01:00
|
|
|
<b-tab :title='text.advanced_backup_restore'>
|
|
|
|
<h3>{{ text.advanced_backup }}</h3>
|
|
|
|
<p><b-button
|
|
|
|
variant="primary"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="exportPage('json')"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_backup_page }}</b-button>
|
|
|
|
{{text.currentpage}} <i>{{selectedpage.fullname}}</i></p>
|
|
|
|
<p><b-button
|
2023-07-07 21:45:09 +02:00
|
|
|
variant="primary"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="exportPlan('json')"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_backup_plan }}</b-button></p>
|
|
|
|
<h3>{{ text.advanced_restore }}</h3>
|
|
|
|
<p><b-button
|
|
|
|
variant="danger"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="importStudylines"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_restore_lines}}</b-button></p>
|
|
|
|
<p><b-button
|
|
|
|
variant="danger"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="importPages"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_restore_pages }}</b-button></p>
|
|
|
|
<h3>{{ text.advanced_export }}</h3>
|
|
|
|
<p><b-button
|
2023-07-07 21:45:09 +02:00
|
|
|
variant="primary"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="exportPage('csv')"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_export_csv_page }}</b-button>
|
|
|
|
{{text.currentpage}} <i>{{selectedpage.fullname}}</i></p>
|
2023-10-23 21:54:09 +02:00
|
|
|
</b-tab>
|
2023-07-07 21:45:09 +02:00
|
|
|
<b-tab :title='text.advanced_purge'>
|
2023-11-11 20:17:45 +01:00
|
|
|
<p>{{text.advanced_purge_page_expl}}</p>
|
|
|
|
<p>{{text.currentpage}} <i>{{selectedpage.fullname}}</i></p>
|
2023-07-07 21:45:09 +02:00
|
|
|
<p><b-button
|
2023-11-11 20:17:45 +01:00
|
|
|
variant="danger"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="purgeStudyplanpage"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_purge_page}}</b-button></p>
|
|
|
|
<p>{{text.advanced_purge_plan_expl}}</p>
|
|
|
|
<p><b-button
|
|
|
|
variant="danger"
|
2024-06-05 22:22:19 +02:00
|
|
|
@click.prevent="purgeStudyplan"
|
2023-11-11 20:17:45 +01:00
|
|
|
>{{ text.advanced_purge_plan}}</b-button></p>
|
2023-10-23 21:54:09 +02:00
|
|
|
</b-tab>
|
|
|
|
</b-tabs>
|
2023-09-08 12:47:29 +02:00
|
|
|
</b-modal>
|
|
|
|
</span>
|
2023-05-17 21:19:14 +02:00
|
|
|
`
|
|
|
|
});
|
|
|
|
|
2023-07-07 21:45:09 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
/*
|
2023-07-07 21:45:09 +02:00
|
|
|
* T-STUDYPLAN-EDIT
|
2023-05-17 21:19:14 +02:00
|
|
|
*/
|
2023-07-07 21:45:09 +02:00
|
|
|
Vue.component('t-studyplan-edit', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'value': {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'mode': {
|
2023-07-07 21:45:09 +02:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "edit";
|
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'type': {
|
2023-07-07 21:45:09 +02:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "link";
|
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'variant': {
|
2023-07-07 21:45:09 +02:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "";
|
|
|
|
},
|
2023-08-07 17:03:49 +02:00
|
|
|
},
|
|
|
|
'contextid': {
|
|
|
|
type: Number,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': 1
|
2023-09-09 21:06:11 +02:00
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.studyplanEdit,
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
planSaved(updatedplan) {
|
2023-05-17 21:19:14 +02:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
debug.info("Got new plan data", updatedplan);
|
2023-07-07 21:45:09 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (self.mode == 'create') {
|
2023-10-23 21:54:09 +02:00
|
|
|
// Inform parent of the details of the newly created plan
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("created", updatedplan);
|
|
|
|
} else {
|
|
|
|
// Determine if the plan moved context...
|
|
|
|
const movedFrom = self.value.context_id;
|
|
|
|
const movedTo = updatedplan.context_id;
|
|
|
|
const moved = (movedFrom != movedTo);
|
2023-07-07 21:45:09 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (updatedplan.pages[0].periods != self.value.pages[0].periods) {
|
2023-10-23 21:54:09 +02:00
|
|
|
// If the pages changed, just reload the entire model for the plan
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_get_studyplan_map',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {id: self.value.id}
|
|
|
|
}])[0].then((response) => {
|
|
|
|
self.value = processStudyplan(response, true);
|
2023-10-23 21:54:09 +02:00
|
|
|
debug.info('studyplan processed');
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit('input', self.value);
|
|
|
|
return;
|
|
|
|
}).catch(function(error) {
|
2023-10-23 21:54:09 +02:00
|
|
|
notification.exception(error);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Copy updated fields and trigger update
|
2024-06-05 22:22:19 +02:00
|
|
|
objCopy(self.value, updatedplan, STUDYPLAN_EDITOR_FIELDS);
|
|
|
|
self.$emit('input', self.value);
|
|
|
|
if (moved) {
|
|
|
|
self.$emit('moved', self.value, movedFrom, movedTo);
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
|
|
|
}
|
2023-10-23 21:54:09 +02:00
|
|
|
}
|
2023-09-09 20:53:39 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
},
|
2023-09-08 12:47:29 +02:00
|
|
|
template:
|
2023-05-17 21:19:14 +02:00
|
|
|
`
|
2023-07-07 21:45:09 +02:00
|
|
|
<span class='s-studyplan-edit'>
|
2024-06-05 23:27:00 +02:00
|
|
|
<mform
|
2024-07-04 12:24:04 +02:00
|
|
|
name="studyplan_editform"
|
2024-06-05 23:27:00 +02:00
|
|
|
:params="{studyplan_id: value.id, mode: mode, contextid: contextid }"
|
2023-10-23 21:54:09 +02:00
|
|
|
@saved="planSaved"
|
|
|
|
:variant="variant"
|
|
|
|
:type="type"
|
2024-06-05 22:22:19 +02:00
|
|
|
:title="(mode == 'create')?text.studyplan_add:text.studyplanEdit"
|
2023-10-23 21:54:09 +02:00
|
|
|
><slot><i class='fa fa-gear'></i></slot></mform>
|
2023-09-08 12:47:29 +02:00
|
|
|
</span>
|
2023-05-17 21:19:14 +02:00
|
|
|
`
|
|
|
|
});
|
|
|
|
|
2023-11-05 15:49:32 +01:00
|
|
|
/*
|
|
|
|
* T-STUDYPLAN-EDIT
|
|
|
|
*/
|
|
|
|
Vue.component('t-studyplan-page-edit', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'value': {
|
2023-11-05 15:49:32 +01:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-11-05 15:49:32 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'mode': {
|
2023-11-05 15:49:32 +01:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "edit";
|
|
|
|
},
|
2023-11-05 15:49:32 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'type': {
|
2023-11-05 15:49:32 +01:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "link";
|
|
|
|
},
|
2023-11-05 15:49:32 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'variant': {
|
2023-11-05 15:49:32 +01:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "";
|
|
|
|
},
|
2023-11-05 15:49:32 +01:00
|
|
|
},
|
|
|
|
'studyplan': {
|
|
|
|
type: Object,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.studyplanEdit,
|
2023-11-05 15:49:32 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
planSaved(updatedpage) {
|
2023-11-05 15:49:32 +01:00
|
|
|
const self = this;
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (self.mode == 'create') {
|
2023-11-05 15:49:32 +01:00
|
|
|
// Inform parent of the details of the newly created plan
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("created", updatedpage);
|
|
|
|
} else {
|
2024-06-03 23:24:16 +02:00
|
|
|
const page = processStudyplanPage(updatedpage);
|
2023-11-05 15:49:32 +01:00
|
|
|
debug.info('studyplan page processed');
|
2023-12-12 23:44:02 +01:00
|
|
|
|
|
|
|
if (self.value.periods < page.periods) {
|
|
|
|
this.$bvModal.msgBoxOk(this.text.info_periodsextended, {
|
|
|
|
title: this.text.warning,
|
|
|
|
okVariant: 'success',
|
|
|
|
centered: true
|
|
|
|
});
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit('input', page);
|
2023-12-12 23:44:02 +01:00
|
|
|
|
2023-11-05 15:49:32 +01:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
},
|
2023-11-05 15:49:32 +01:00
|
|
|
template:
|
|
|
|
`
|
|
|
|
<span class='s-studyplan-page-edit'>
|
2024-06-05 23:27:00 +02:00
|
|
|
<mform
|
|
|
|
name="studyplanpage_editform"
|
|
|
|
:params="{page_id: value.id, studyplan_id: studyplan.id, mode: mode }"
|
2023-11-05 15:49:32 +01:00
|
|
|
@saved="planSaved"
|
|
|
|
:variant="variant"
|
|
|
|
:type="type"
|
2023-11-05 22:33:57 +01:00
|
|
|
:title="(mode == 'create')?text.studyplanpage_add:text.studyplanpage_edit"
|
2023-11-05 15:49:32 +01:00
|
|
|
><slot><i class='fa fa-gear'></i></slot></mform>
|
|
|
|
</span>
|
|
|
|
`
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
/*
|
2023-07-07 21:45:09 +02:00
|
|
|
* T-STUDYPLAN-ASSOCIATE
|
2023-05-17 21:19:14 +02:00
|
|
|
*/
|
2023-07-07 21:45:09 +02:00
|
|
|
Vue.component('t-studyplan-associate', {
|
2024-06-05 22:22:19 +02:00
|
|
|
props: ['value'],
|
2023-05-17 21:19:14 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
show: false,
|
|
|
|
config: {
|
2023-09-08 12:47:29 +02:00
|
|
|
userfields: [
|
2024-06-05 22:22:19 +02:00
|
|
|
{key: "selected"},
|
|
|
|
{key: "firstname", "sortable": true},
|
|
|
|
{key: "lastname", "sortable": true},
|
2023-05-17 21:19:14 +02:00
|
|
|
],
|
2024-06-05 22:22:19 +02:00
|
|
|
cohortfields: [
|
|
|
|
{key: "selected"},
|
|
|
|
{key: "name", "sortable": true},
|
|
|
|
{key: "context", "sortable": true},
|
2023-05-17 21:19:14 +02:00
|
|
|
]
|
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
association: {
|
|
|
|
cohorts: [],
|
|
|
|
users: [],
|
2024-03-08 17:05:07 +01:00
|
|
|
coaches: []
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
loading: {
|
|
|
|
cohorts: false,
|
|
|
|
users: false,
|
2024-03-08 17:05:07 +01:00
|
|
|
coaches: false,
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
search: {users: [], cohorts: [], coaches: []},
|
2023-07-07 21:45:09 +02:00
|
|
|
selected: {
|
2024-06-05 22:22:19 +02:00
|
|
|
search: {users: [], cohorts: [], coaches: []},
|
|
|
|
associated: {users: [], cohorts: [], coaches: []}
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.studyplanAssociate,
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2024-03-08 17:05:07 +01:00
|
|
|
premiumenabled,
|
2024-06-05 22:22:19 +02:00
|
|
|
showModal() {
|
2023-07-07 21:45:09 +02:00
|
|
|
this.show = true;
|
|
|
|
this.loadAssociations();
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
cohortOptionModel(c) {
|
2023-07-07 21:45:09 +02:00
|
|
|
return {
|
2023-09-02 20:34:33 +02:00
|
|
|
value: c.id,
|
2023-07-07 21:45:09 +02:00
|
|
|
text: c.name + ' (' + c.context.path.join(' / ') + ')',
|
|
|
|
};
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
userOptionModel(u) {
|
2023-07-07 21:45:09 +02:00
|
|
|
return {
|
|
|
|
value: u.id,
|
|
|
|
text: u.firstname + ' ' + u.lastname,
|
|
|
|
};
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
loadAssociations() {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
|
|
|
self.loading.cohorts = true;
|
|
|
|
self.loading.users = true;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_associated_users',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2023-07-07 21:45:09 +02:00
|
|
|
self.association.users = response.map(self.userOptionModel);
|
|
|
|
self.loading.users = false;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-07-07 21:45:09 +02:00
|
|
|
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_associated_cohorts',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2023-07-07 21:45:09 +02:00
|
|
|
self.association.cohorts = response.map(self.cohortOptionModel);
|
|
|
|
self.loading.cohorts = false;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2024-03-08 17:05:07 +01:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (premiumenabled()) {
|
2024-03-08 17:05:07 +01:00
|
|
|
self.loading.coaches = true;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_associated_coaches',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2024-03-08 17:05:07 +01:00
|
|
|
self.association.coaches = response.map(self.userOptionModel);
|
|
|
|
self.loading.coaches = false;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2024-03-08 17:05:07 +01:00
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
searchCohorts(searchtext) {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (searchtext.length > 0) {
|
2023-07-07 21:45:09 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_list_cohort',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
like: searchtext,
|
|
|
|
'studyplan_id': self.value.id
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2023-07-07 21:45:09 +02:00
|
|
|
self.search.cohorts = response.map(self.cohortOptionModel);
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2023-07-07 21:45:09 +02:00
|
|
|
self.search.cohorts = [];
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
cohortAssociate() {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
|
|
|
let requests = [];
|
|
|
|
const associated = self.association.cohorts;
|
|
|
|
const search = self.search.cohorts;
|
|
|
|
const searchselected = self.selected.search.cohorts;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const i in searchselected) {
|
2023-09-08 12:47:29 +02:00
|
|
|
const r = searchselected[i];
|
2024-06-05 22:22:19 +02:00
|
|
|
call([{
|
2023-07-07 21:45:09 +02:00
|
|
|
methodname: 'local_treestudyplan_connect_cohort',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
'cohort_id': r,
|
|
|
|
},
|
2024-06-05 22:32:18 +02:00
|
|
|
}])[0].then((response) => {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (response.success) {
|
|
|
|
transportItem(associated, search, r);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2023-07-07 21:45:09 +02:00
|
|
|
call(requests);
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
cohortDisassociate() {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
|
|
|
const associatedselected = self.selected.associated.cohorts;
|
|
|
|
const associated = self.association.cohorts;
|
2024-06-05 22:22:19 +02:00
|
|
|
const search = self.search.cohorts;
|
|
|
|
for (const i in associatedselected) {
|
2023-09-08 12:47:29 +02:00
|
|
|
const r = associatedselected[i];
|
2024-06-05 22:22:19 +02:00
|
|
|
call([{
|
2023-07-07 21:45:09 +02:00
|
|
|
methodname: 'local_treestudyplan_disconnect_cohort',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
'cohort_id': r,
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success) {
|
2024-06-05 22:32:18 +02:00
|
|
|
transportItem(search, associated, r);
|
2024-06-05 22:22:19 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
searchUsers(searchtext) {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
if (searchtext.length > 0) {
|
2023-07-07 21:45:09 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_find_user',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
like: searchtext,
|
|
|
|
'studyplan_id': self.value.id
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2023-07-07 21:45:09 +02:00
|
|
|
self.search.users = response.map(self.userOptionModel);
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2023-07-07 21:45:09 +02:00
|
|
|
self.search.users = [];
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
userAssociate() {
|
2023-05-17 21:19:14 +02:00
|
|
|
const self = this;
|
2023-07-07 21:45:09 +02:00
|
|
|
const associated = self.association.users;
|
2024-06-05 22:22:19 +02:00
|
|
|
const search = self.search.users;
|
|
|
|
const searchselected = self.selected.search.users;
|
|
|
|
for (const i in searchselected) {
|
2023-09-08 12:47:29 +02:00
|
|
|
const r = searchselected[i];
|
2024-06-05 22:22:19 +02:00
|
|
|
call([{
|
2023-07-07 21:45:09 +02:00
|
|
|
methodname: 'local_treestudyplan_connect_user',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
'user_id': r,
|
|
|
|
},
|
2024-06-05 22:32:18 +02:00
|
|
|
}])[0].then((response) => {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (response.success) {
|
|
|
|
transportItem(associated, search, r);
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
userDisassociate() {
|
2023-07-07 21:45:09 +02:00
|
|
|
const self = this;
|
|
|
|
const associated = self.association.users;
|
|
|
|
const associatedselected = self.selected.associated.users;
|
|
|
|
const search = self.search.users;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const i in associatedselected) {
|
2023-09-08 12:47:29 +02:00
|
|
|
const r = associatedselected[i];
|
2024-06-05 22:22:19 +02:00
|
|
|
call([{
|
2023-07-07 21:45:09 +02:00
|
|
|
methodname: 'local_treestudyplan_disconnect_user',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
'user_id': r,
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success) {
|
2024-06-05 22:32:18 +02:00
|
|
|
transportItem(search, associated, r);
|
2024-06-05 22:22:19 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
searchCoaches(searchtext) {
|
|
|
|
if (premiumenabled()) {
|
2024-03-08 17:05:07 +01:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
if (searchtext.length > 0) {
|
2024-03-08 17:05:07 +01:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_find_coach',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
like: searchtext,
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2024-03-08 17:05:07 +01:00
|
|
|
self.search.coaches = response.map(self.userOptionModel);
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2024-03-08 17:05:07 +01:00
|
|
|
}).catch(notification.exception);
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2024-03-08 17:05:07 +01:00
|
|
|
self.search.coaches = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
coachAssociate() {
|
|
|
|
if (premiumenabled()) {
|
2024-03-08 17:05:07 +01:00
|
|
|
const self = this;
|
|
|
|
const associated = self.association.coaches;
|
2024-06-05 22:22:19 +02:00
|
|
|
const search = self.search.coaches;
|
|
|
|
const searchselected = self.selected.search.coaches;
|
|
|
|
for (const i in searchselected) {
|
2024-03-08 17:05:07 +01:00
|
|
|
const r = searchselected[i];
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
call([{
|
2024-03-08 17:05:07 +01:00
|
|
|
methodname: 'local_treestudyplan_connect_coach',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
'user_id': r,
|
|
|
|
},
|
2024-06-05 22:32:18 +02:00
|
|
|
}])[0].then((response) => {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (response.success) {
|
|
|
|
transportItem(associated, search, r);
|
2024-03-08 17:05:07 +01:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2024-03-08 17:05:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
coachDisassociate() {
|
|
|
|
if (premiumenabled()) {
|
2024-03-08 17:05:07 +01:00
|
|
|
const self = this;
|
|
|
|
const associatedselected = self.selected.associated.coaches;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const i in associatedselected) {
|
2024-03-08 17:05:07 +01:00
|
|
|
const r = associatedselected[i];
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
call([{
|
2024-03-08 17:05:07 +01:00
|
|
|
methodname: 'local_treestudyplan_disconnect_coach',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.value.id,
|
|
|
|
'user_id': r,
|
2024-03-08 17:05:07 +01:00
|
|
|
}
|
2024-06-12 21:12:00 +02:00
|
|
|
}])[0].then(() => {
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2024-03-08 17:05:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
},
|
2023-09-08 12:47:29 +02:00
|
|
|
template:
|
2023-07-07 21:45:09 +02:00
|
|
|
`
|
|
|
|
<span class='s-studyplan-associate'
|
|
|
|
><a href='#' @click.prevent="showModal" ><slot><i class='fa fa-users'></i></slot></a>
|
|
|
|
<b-modal
|
2023-09-08 12:47:29 +02:00
|
|
|
v-model="show"
|
|
|
|
size="lg"
|
2023-07-07 21:45:09 +02:00
|
|
|
ok-variant="primary"
|
|
|
|
:title="text.associations + ' - ' + value.name"
|
|
|
|
ok-only>
|
|
|
|
<b-tabs class='s-studyplan-associate-window'>
|
|
|
|
<b-tab :title="text.cohorts">
|
|
|
|
<b-container>
|
|
|
|
<b-row class='mb-2 mt-2'>
|
|
|
|
<b-col>{{text.associated_cohorts}}</b-col>
|
|
|
|
<b-col>{{text.associate_cohorts}}</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row class='mb-2'>
|
|
|
|
<b-col>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-form-input
|
|
|
|
type="text" @input="searchCohorts($event)"
|
2023-07-07 21:45:09 +02:00
|
|
|
:placeholder="text.search"></b-form-input>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col>
|
|
|
|
<b-form-select
|
|
|
|
multiple
|
|
|
|
v-model="selected.associated.cohorts"
|
|
|
|
:options="association.cohorts"
|
|
|
|
:select-size="10"
|
|
|
|
></b-form-select>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-form-select
|
|
|
|
multiple
|
|
|
|
v-model="selected.search.cohorts"
|
|
|
|
:options="search.cohorts"
|
|
|
|
:select-size="10"
|
2023-05-17 21:19:14 +02:00
|
|
|
></b-form-select>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row class='mt-2'>
|
|
|
|
<b-col>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-button variant='danger' @click.prevent="cohortDisassociate()"
|
2023-07-07 21:45:09 +02:00
|
|
|
><i class='fa fa-chain-broken'></i> {{text.delete_association}}</b-button>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-button variant='success' @click.prevent="cohortAssociate()"
|
2023-09-03 15:21:30 +02:00
|
|
|
><i class='fa fa-link'></i> {{text.add_association}}</b-button>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
</b-container>
|
|
|
|
</b-tab>
|
|
|
|
<b-tab :title="text.users">
|
|
|
|
<b-container>
|
|
|
|
<b-row class='mb-2 mt-2'>
|
|
|
|
<b-col>{{text.associated_users}}</b-col>
|
|
|
|
<b-col>{{text.associate_users}}</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row class='mb-2'>
|
|
|
|
<b-col>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-form-input
|
|
|
|
type="text"
|
|
|
|
@input="searchUsers($event)"
|
2024-05-10 15:22:52 +02:00
|
|
|
:placeholder="text.search + ' ' + text.users"></b-form-input>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col>
|
|
|
|
<b-form-select
|
|
|
|
multiple
|
|
|
|
v-model="selected.associated.users"
|
|
|
|
:options="association.users"
|
|
|
|
:select-size="10"
|
2023-05-17 21:19:14 +02:00
|
|
|
></b-form-select>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-form-select
|
|
|
|
multiple
|
|
|
|
v-model="selected.search.users"
|
|
|
|
:options="search.users"
|
|
|
|
:select-size="10"
|
|
|
|
></b-form-select>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row class='mt-2'>
|
|
|
|
<b-col>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-button variant='danger' @click.prevent="userDisassociate()"
|
2023-07-07 21:45:09 +02:00
|
|
|
><i class='fa fa-chain-broken'></i> {{text.delete_association}}</b-button>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-button variant='success' @click.prevent="userAssociate()"
|
2023-09-03 15:21:30 +02:00
|
|
|
><i class='fa fa-link'></i> {{text.add_association}}</b-button>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-col>
|
2023-09-08 12:47:29 +02:00
|
|
|
</b-row>
|
2023-09-03 15:21:30 +02:00
|
|
|
</b-container>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-tab>
|
2024-05-10 15:22:52 +02:00
|
|
|
<b-tab :title="text.coaches" v-if="premiumenabled()">
|
2024-03-08 17:05:07 +01:00
|
|
|
<b-container>
|
|
|
|
<b-row class='mb-2 mt-2'>
|
|
|
|
<b-col>{{text.associated_coaches}}</b-col>
|
|
|
|
<b-col>{{text.associate_coaches}}</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row class='mb-2'>
|
|
|
|
<b-col>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-form-input
|
|
|
|
type="text"
|
|
|
|
@input="searchCoaches($event)"
|
2024-05-10 15:22:52 +02:00
|
|
|
:placeholder="text.search + ' ' + text.coaches"></b-form-input>
|
2024-03-08 17:05:07 +01:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col>
|
|
|
|
<b-form-select
|
|
|
|
multiple
|
|
|
|
v-model="selected.associated.coaches"
|
|
|
|
:options="association.coaches"
|
|
|
|
:select-size="10"
|
|
|
|
></b-form-select>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-form-select
|
|
|
|
multiple
|
|
|
|
v-model="selected.search.coaches"
|
|
|
|
:options="search.coaches"
|
|
|
|
:select-size="10"
|
|
|
|
></b-form-select>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row class='mt-2'>
|
|
|
|
<b-col>
|
|
|
|
<b-button variant='danger' @click.prevent="coachDisassociate()"
|
|
|
|
><i class='fa fa-chain-broken'></i> {{text.delete_association}}</b-button>
|
|
|
|
</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-button variant='success' @click.prevent="coachAssociate()"
|
|
|
|
><i class='fa fa-link'></i> {{text.add_association}}</b-button>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
</b-container>
|
|
|
|
</b-tab>
|
2023-07-07 21:45:09 +02:00
|
|
|
</b-tabs>
|
|
|
|
</b-modal>
|
2023-09-03 15:21:30 +02:00
|
|
|
</span>
|
2023-07-07 21:45:09 +02:00
|
|
|
`
|
2023-05-17 21:19:14 +02:00
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
/* * ****************
|
2023-09-08 12:47:29 +02:00
|
|
|
*
|
2023-07-28 23:43:11 +02:00
|
|
|
* Period editor
|
2023-09-08 12:47:29 +02:00
|
|
|
*
|
2023-07-28 23:43:11 +02:00
|
|
|
*************/
|
|
|
|
|
|
|
|
Vue.component('t-period-edit', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'value': {
|
2023-07-28 23:43:11 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-07-28 23:43:11 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'type': {
|
2023-07-28 23:43:11 +02:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "link";
|
|
|
|
},
|
2023-07-28 23:43:11 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'variant': {
|
2023-07-28 23:43:11 +02:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return "";
|
|
|
|
},
|
2023-09-03 15:21:30 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'minstart': {
|
2023-09-03 15:21:30 +02:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-09-03 15:21:30 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'maxend': {
|
2023-09-03 15:21:30 +02:00
|
|
|
type: String,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-07-28 23:43:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
show: false,
|
2023-09-08 12:47:29 +02:00
|
|
|
editdata: {
|
2023-07-28 23:43:11 +02:00
|
|
|
fullname: '',
|
|
|
|
shortname: '',
|
|
|
|
startdate: (new Date()).getFullYear() + '-08-01',
|
2024-06-05 22:22:19 +02:00
|
|
|
enddate: ((new Date()).getFullYear() + 1) + '-08-01',
|
2023-07-28 23:43:11 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.periodEdit,
|
2023-07-28 23:43:11 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
editStart() {
|
|
|
|
objCopy(this.editdata, this.value, PERIOD_EDITOR_FIELDS);
|
2023-07-28 23:43:11 +02:00
|
|
|
this.show = true;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
editFinish() {
|
2023-07-28 23:43:11 +02:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
let args = {'id': this.value.id};
|
2023-07-28 23:43:11 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
objCopy(args, this.editdata, PERIOD_EDITOR_FIELDS);
|
2023-07-28 23:43:11 +02:00
|
|
|
|
|
|
|
call([{
|
2024-07-10 09:08:12 +02:00
|
|
|
methodname: 'local_treestudyplan_edit_period',
|
2023-07-28 23:43:11 +02:00
|
|
|
args: args
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
|
|
|
objCopy(self.value, response, PERIOD_EDITOR_FIELDS);
|
|
|
|
self.$emit('input', self.value);
|
|
|
|
self.$emit('edited', self.value);
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-07-28 23:43:11 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
refresh() {
|
2023-09-03 15:21:30 +02:00
|
|
|
const self = this;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_get_period',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {'id': this.value.id},
|
|
|
|
}])[0].then((response) => {
|
|
|
|
objCopy(self.value, response, PERIOD_EDITOR_FIELDS);
|
|
|
|
self.$emit('input', self.value);
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-09-03 15:21:30 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
addDay(date, days) {
|
|
|
|
if (days === undefined) {
|
2023-09-03 16:54:09 +02:00
|
|
|
days = 1;
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return addDays(date, days);
|
2023-09-03 16:54:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
subDay(date, days) {
|
|
|
|
if (days === undefined) {
|
2023-09-03 16:54:09 +02:00
|
|
|
days = 1;
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return addDays(date, 0 - days);
|
2023-09-03 16:54:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
},
|
2023-09-08 12:47:29 +02:00
|
|
|
template:
|
2023-07-28 23:43:11 +02:00
|
|
|
`
|
|
|
|
<span class='t-period-edit'>
|
|
|
|
<b-button :variant="variant" v-if='type == "button"' @click.prevent='editStart()'
|
2023-09-02 20:34:33 +02:00
|
|
|
><slot><i class='fa fa-gear'></i></slot></b-button>
|
2023-07-28 23:43:11 +02:00
|
|
|
<a variant="variant" v-else href='#' @click.prevent='editStart()'
|
2023-09-02 20:34:33 +02:00
|
|
|
><slot><i class='fa fa-gear'></i></slot></a>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-modal
|
2023-07-28 23:43:11 +02:00
|
|
|
v-model="show"
|
|
|
|
size="lg"
|
|
|
|
ok-variant="primary"
|
2023-08-07 16:11:14 +02:00
|
|
|
:title="text.edit"
|
2023-07-28 23:43:11 +02:00
|
|
|
@ok="editFinish()"
|
|
|
|
:ok-disabled="Math.min(editdata.fullname.length,editdata.shortname.length) == 0"
|
|
|
|
>
|
|
|
|
<b-container>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="4">{{ text.fullname}}</b-col>
|
|
|
|
<b-col cols="8">
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-form-input v-model="editdata.fullname"
|
2023-07-28 23:43:11 +02:00
|
|
|
:state='editdata.fullname.length>0'
|
|
|
|
></b-form-input>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="4">{{ text.shortname}}</b-col>
|
|
|
|
<b-col cols="8">
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-form-input v-model="editdata.shortname"
|
2023-07-28 23:43:11 +02:00
|
|
|
:state='editdata.shortname.length>0'
|
|
|
|
></b-form-input>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2024-03-10 23:09:33 +01:00
|
|
|
<b-row v-if="!value.timeless">
|
2023-07-28 23:43:11 +02:00
|
|
|
<b-col cols="4">{{ text.studyplan_startdate}}</b-col>
|
|
|
|
<b-col cols="8">
|
2023-09-03 15:21:30 +02:00
|
|
|
<b-form-datepicker
|
2023-09-08 12:47:29 +02:00
|
|
|
start-weekday="1"
|
2023-09-03 15:21:30 +02:00
|
|
|
v-model="editdata.startdate"
|
|
|
|
:min="(minstart ? minstart : '')"
|
2024-06-05 22:22:19 +02:00
|
|
|
:max="subDay(value.enddate)"
|
2023-09-03 15:21:30 +02:00
|
|
|
></b-form-datepicker>
|
2023-07-28 23:43:11 +02:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2024-03-10 23:09:33 +01:00
|
|
|
<b-row v-if="!value.timeless">
|
2023-07-28 23:43:11 +02:00
|
|
|
<b-col cols="4">{{ text.studyplan_enddate}}</b-col>
|
|
|
|
<b-col cols="8">
|
2023-09-03 15:21:30 +02:00
|
|
|
<b-form-datepicker
|
2023-09-08 12:47:29 +02:00
|
|
|
start-weekday="1"
|
2023-09-03 15:21:30 +02:00
|
|
|
v-model="editdata.enddate"
|
2024-06-05 22:22:19 +02:00
|
|
|
:min="addDay(value.startdate)"
|
2023-09-03 15:21:30 +02:00
|
|
|
:max="(maxend ? maxend : '')"
|
|
|
|
></b-form-datepicker>
|
2023-07-28 23:43:11 +02:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
</b-container>
|
2023-09-08 12:47:29 +02:00
|
|
|
</b-modal>
|
|
|
|
</span>
|
2023-07-28 23:43:11 +02:00
|
|
|
`
|
|
|
|
});
|
|
|
|
|
2023-11-05 15:49:32 +01:00
|
|
|
// TAG: Start studyplan component
|
2023-05-17 21:19:14 +02:00
|
|
|
/*
|
2023-07-07 21:45:09 +02:00
|
|
|
* T-STUDYPLAN
|
2023-05-17 21:19:14 +02:00
|
|
|
*/
|
2023-07-07 21:45:09 +02:00
|
|
|
Vue.component('t-studyplan', {
|
2024-06-05 23:27:00 +02:00
|
|
|
props: {
|
2024-03-09 00:11:42 +01:00
|
|
|
'value': {
|
|
|
|
type: Object,
|
2024-06-05 23:27:00 +02:00
|
|
|
},
|
2024-03-09 00:11:42 +01:00
|
|
|
'coaching': {
|
|
|
|
type: Boolean,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': false,
|
2024-03-09 00:11:42 +01:00
|
|
|
},
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
config: {
|
2023-09-08 12:47:29 +02:00
|
|
|
userfields: [
|
2024-06-05 22:22:19 +02:00
|
|
|
{key: "selected"},
|
|
|
|
{key: "firstname", "sortable": true},
|
|
|
|
{key: "lastname", "sortable": true},
|
2023-05-17 21:19:14 +02:00
|
|
|
],
|
2024-06-05 22:22:19 +02:00
|
|
|
cohortfields: [
|
|
|
|
{key: "selected"},
|
|
|
|
{key: "name", "sortable": true},
|
|
|
|
{key: "context", "sortable": true},
|
2023-05-17 21:19:14 +02:00
|
|
|
]
|
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
create: {
|
|
|
|
studyline: {
|
2024-02-25 23:45:39 +01:00
|
|
|
name: '',
|
|
|
|
shortname: '',
|
|
|
|
color: '#DDDDDD',
|
2024-03-04 22:39:29 +01:00
|
|
|
enrol: {
|
|
|
|
enrollable: 0,
|
|
|
|
enrolroles: [],
|
|
|
|
}
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
2023-11-05 15:49:32 +01:00
|
|
|
page: {
|
2024-02-25 23:45:39 +01:00
|
|
|
id: -1,
|
2024-06-05 22:22:19 +02:00
|
|
|
name: '',
|
|
|
|
shortname: ''
|
2023-11-05 15:49:32 +01:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
edit: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'toolbox_shown': false,
|
2023-07-07 21:45:09 +02:00
|
|
|
studyline: {
|
|
|
|
editmode: false,
|
2023-09-08 12:47:29 +02:00
|
|
|
data: {
|
2023-07-07 21:45:09 +02:00
|
|
|
name: '',
|
|
|
|
shortname: '',
|
|
|
|
color: '#DDDDDD',
|
2024-03-04 22:39:29 +01:00
|
|
|
enrol: {
|
|
|
|
enrollable: 0,
|
|
|
|
enrolroles: [],
|
|
|
|
}
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
|
|
|
original: {},
|
2024-02-25 23:45:39 +01:00
|
|
|
availableroles: [],
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
|
|
|
studyplan: {
|
2023-09-08 12:47:29 +02:00
|
|
|
data: {
|
2023-07-07 21:45:09 +02:00
|
|
|
name: '',
|
|
|
|
shortname: '',
|
|
|
|
description: '',
|
2024-06-05 22:22:19 +02:00
|
|
|
slots: 4,
|
2023-07-07 21:45:09 +02:00
|
|
|
startdate: '2020-08-01',
|
|
|
|
enddate: '',
|
|
|
|
aggregation: '',
|
2024-06-05 22:22:19 +02:00
|
|
|
'aggregation_config': '',
|
|
|
|
'aggregation_info': {
|
2023-07-07 21:45:09 +02:00
|
|
|
useRequiredGrades: true,
|
|
|
|
useItemCondition: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
original: {},
|
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.studyplanText,
|
2023-08-07 16:11:14 +02:00
|
|
|
cache: {
|
|
|
|
linelayers: {},
|
2023-11-05 15:49:32 +01:00
|
|
|
},
|
2023-11-05 22:33:57 +01:00
|
|
|
selectedpageindex: 0,
|
|
|
|
emptyline: {
|
|
|
|
id: -1,
|
|
|
|
name: '<No study lines defined>',
|
|
|
|
shortname: '<No study lines>',
|
|
|
|
color: '#FF0000',
|
|
|
|
filterslots: [{}],
|
|
|
|
courseslots: [{}]
|
2024-02-25 23:45:39 +01:00
|
|
|
},
|
|
|
|
availableroles: [],
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
2023-12-02 23:22:00 +01:00
|
|
|
const self = this;
|
2023-11-27 23:11:17 +01:00
|
|
|
// Listener for the signal that a new connection was made and needs to be drawn
|
|
|
|
// Sent by the incoming item - By convention, outgoing items are responsible for drawing the lines
|
2023-12-02 23:22:00 +01:00
|
|
|
ItemEventBus.$on('coursechange', () => {
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit('pagechanged', this.selectedpage);
|
2023-12-02 23:22:00 +01:00
|
|
|
});
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
mounted() {
|
2024-06-05 22:22:19 +02:00
|
|
|
const self = this;
|
|
|
|
if (this.value.pages[0].studylines.length == 0 && !this.coaching) {
|
|
|
|
// Start in editmode if studylines on first page are empty
|
2023-07-07 21:45:09 +02:00
|
|
|
this.edit.studyline.editmode = true;
|
2024-02-09 11:15:05 +01:00
|
|
|
}
|
2024-02-25 23:45:39 +01:00
|
|
|
|
2024-03-09 22:51:34 +01:00
|
|
|
if (!self.coaching) {
|
|
|
|
// Retrieve available roles (only needed as manager)
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_list_roles',
|
|
|
|
args: {
|
|
|
|
'studyplan_id': this.value.id,
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
2024-03-09 22:51:34 +01:00
|
|
|
self.availableroles = response;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2024-03-09 22:51:34 +01:00
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
2023-07-07 21:45:09 +02:00
|
|
|
this.$root.$emit('redrawLines');
|
2024-06-05 22:22:19 +02:00
|
|
|
this.$emit('pagechanged', this.selectedpage);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
updated() {
|
2023-07-07 21:45:09 +02:00
|
|
|
this.$root.$emit('redrawLines');
|
|
|
|
ItemEventBus.$emit('redrawLines');
|
|
|
|
},
|
|
|
|
computed: {
|
2023-11-05 22:33:57 +01:00
|
|
|
selectedpage() {
|
|
|
|
return this.value.pages[this.selectedpageindex];
|
2024-05-27 22:11:32 +02:00
|
|
|
},
|
|
|
|
hivizdrop() {
|
|
|
|
return settings("hivizdropslots");
|
|
|
|
},
|
2023-11-05 15:49:32 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2024-02-25 23:45:39 +01:00
|
|
|
premiumenabled,
|
2023-11-05 15:49:32 +01:00
|
|
|
columns(page) {
|
2024-06-05 22:22:19 +02:00
|
|
|
return 1 + (page.periods * 2);
|
2023-07-07 23:17:21 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
columnsStylerule(page) {
|
2023-07-07 23:17:21 +02:00
|
|
|
// Uses css variables, so width for slots and filters can be configured in css
|
2024-06-05 22:22:19 +02:00
|
|
|
let s = "grid-template-columns: var(--studyplan-filter-width)"; // Use css variable here
|
|
|
|
for (let i = 0; i < page.periods; i++) {
|
|
|
|
s += " var(--studyplan-course-width) var(--studyplan-filter-width)";
|
2023-07-07 23:17:21 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return s + ";";
|
2023-07-26 16:42:34 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
trashbinAccepts(type) {
|
|
|
|
if (type.item) {
|
2023-08-07 17:39:57 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
countLineLayers(line, page) {
|
2023-08-07 16:11:14 +02:00
|
|
|
// For some optimization, we cache the value of this calculation for about a second
|
|
|
|
// Would be a lot nicer if we could use a computed property for this.....
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.cache.linelayers[line.id]
|
|
|
|
&& ((new Date()) - this.cache.linelayers[line.id].timestamp < 1000)
|
|
|
|
) {
|
2023-09-08 12:47:29 +02:00
|
|
|
return this.cache.linelayers[line.id].value;
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2023-08-07 16:11:14 +02:00
|
|
|
let maxLayer = -1;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let i = 0; i <= page.periods; i++) {
|
|
|
|
if (line.slots[i]) {
|
2024-01-28 14:41:35 +01:00
|
|
|
// Determine the amount of used layers in a studyline slot
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const ix in line.slots[i].courses) {
|
2023-08-28 11:26:14 +02:00
|
|
|
const item = line.slots[i].courses[ix];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (item.layer > maxLayer) {
|
2023-08-16 23:36:11 +02:00
|
|
|
maxLayer = item.layer;
|
|
|
|
}
|
2023-08-07 16:11:14 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const ix in line.slots[i].filters) {
|
2023-08-16 23:36:11 +02:00
|
|
|
const item = line.slots[i].filters[ix];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (item.layer > maxLayer) {
|
2023-08-16 23:36:11 +02:00
|
|
|
maxLayer = item.layer;
|
|
|
|
}
|
2023-08-07 16:11:14 +02:00
|
|
|
}
|
2023-08-16 23:36:11 +02:00
|
|
|
|
2023-07-15 22:00:17 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-07 16:11:14 +02:00
|
|
|
this.cache.linelayers[line.id] = {
|
|
|
|
value: (maxLayer + 1),
|
2023-09-08 12:47:29 +02:00
|
|
|
timestamp: (new Date()),
|
2023-08-07 16:11:14 +02:00
|
|
|
};
|
2024-06-05 22:22:19 +02:00
|
|
|
return maxLayer + 1;
|
2023-07-15 22:00:17 +02:00
|
|
|
}
|
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
slotsempty(slots) {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (Array.isArray(slots)) {
|
2023-07-07 21:45:09 +02:00
|
|
|
let count = 0;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let i = 0; i < slots.length; i++) {
|
|
|
|
if (Array.isArray(slots[i].courses)) {
|
2023-08-28 11:26:14 +02:00
|
|
|
count += slots[i].courses.length;
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
if (Array.isArray(slots[i].filters)) {
|
2023-07-07 21:45:09 +02:00
|
|
|
count += slots[i].filters.length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (count == 0);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
movedStudyplan(plan, from, to) {
|
|
|
|
this.$emit('moved', plan, from, to); // Throw the event up....
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
addStudyLine(page, newlineinfo) {
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
2023-07-07 21:45:09 +02:00
|
|
|
methodname: 'local_treestudyplan_add_studyline',
|
|
|
|
args: {
|
2023-07-26 16:42:34 +02:00
|
|
|
'page_id': page.id,
|
2023-07-07 21:45:09 +02:00
|
|
|
'name': newlineinfo.name,
|
|
|
|
'shortname': newlineinfo.shortname,
|
|
|
|
'color': newlineinfo.color,
|
2023-07-26 16:42:34 +02:00
|
|
|
'sequence': page.studylines.length,
|
2024-03-04 22:39:29 +01:00
|
|
|
'enrollable': newlineinfo.enrol.enrollable,
|
|
|
|
'enrolroles': newlineinfo.enrol.enrolroles
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
2023-07-26 16:42:34 +02:00
|
|
|
page.studylines.push(response);
|
2023-07-07 21:45:09 +02:00
|
|
|
newlineinfo.name = '';
|
|
|
|
newlineinfo.shortname = '';
|
|
|
|
newlineinfo.color = "#dddddd";
|
2024-03-04 22:39:29 +01:00
|
|
|
newlineinfo.enrol.enrollable = 0;
|
|
|
|
newlineinfo.enrol.enrolroles = [];
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
|
|
|
editLineStart(line) {
|
2024-02-25 23:45:39 +01:00
|
|
|
const page = this.value.pages[this.selectedpageindex];
|
|
|
|
debug.info("Starting line edit", line);
|
2024-06-05 22:22:19 +02:00
|
|
|
Object.assign(this.edit.studyline.data, line);
|
2023-07-07 21:45:09 +02:00
|
|
|
this.edit.studyline.original = line;
|
2024-06-05 22:22:19 +02:00
|
|
|
this.$bvModal.show('modal-edit-studyline-' + page.id);
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
|
|
|
editLineFinish() {
|
|
|
|
let editedline = this.edit.studyline.data;
|
|
|
|
let originalline = this.edit.studyline.original;
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
2024-07-10 09:08:12 +02:00
|
|
|
methodname: 'local_treestudyplan_edit_studyline',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {'id': editedline.id,
|
2023-07-07 21:45:09 +02:00
|
|
|
'name': editedline.name,
|
|
|
|
'shortname': editedline.shortname,
|
2024-02-25 23:45:39 +01:00
|
|
|
'color': editedline.color,
|
2024-03-04 22:39:29 +01:00
|
|
|
'enrollable': editedline.enrol.enrollable,
|
|
|
|
'enrolroles': editedline.enrol.enrolroles
|
2024-02-25 23:45:39 +01:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].then((response) => {
|
2024-03-04 22:39:29 +01:00
|
|
|
originalline.name = response.name;
|
|
|
|
originalline.shortname = response.shortname;
|
|
|
|
originalline.color = response.color;
|
|
|
|
originalline.enrol.enrollable = response.enrol.enrollable;
|
|
|
|
originalline.enrol.enrolroles = response.enrol.enrolroles;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
deleteLine(page, line) {
|
|
|
|
const self = this;
|
|
|
|
|
|
|
|
self.$bvModal.msgBoxConfirm(this.text.studylineConfirmRemove.replace('{$a}', line.name), {
|
|
|
|
okTitle: this.text.delete,
|
|
|
|
okVariant: 'danger',
|
|
|
|
}).then((modalresponse) => {
|
|
|
|
if (modalresponse) {
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_delete_studyline',
|
|
|
|
args: {'id': line.id}
|
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success == true) {
|
|
|
|
let index = page.studylines.indexOf(line);
|
|
|
|
page.studylines.splice(index, 1);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
reorderLines(event, lines) {
|
2023-07-07 21:45:09 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// Apply reordering
|
2023-07-07 21:45:09 +02:00
|
|
|
event.apply(lines);
|
2024-06-05 22:22:19 +02:00
|
|
|
// Send the new sequence to the server
|
2023-07-07 21:45:09 +02:00
|
|
|
let sequence = [];
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let idx in lines) {
|
|
|
|
sequence.push({'id': lines[idx].id, 'sequence': idx});
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2023-07-07 21:45:09 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_reorder_studylines',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {'sequence': sequence}
|
|
|
|
}])[0].then(() => {
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
deletePlan(studyplan) {
|
|
|
|
const self = this;
|
|
|
|
self.$bvModal.msgBoxConfirm(this.text.studyplabConfirmRemove.replace('{$a}', studyplan.name), {
|
|
|
|
okTitle: this.text.delete,
|
|
|
|
okVariant: 'danger',
|
|
|
|
}).then(function(modalresponse) {
|
|
|
|
if (modalresponse) {
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_delete_studyplan',
|
|
|
|
args: {'id': studyplan.id, force: true}
|
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success == true) {
|
|
|
|
self.$root.$emit("studyplanRemoved", studyplan);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
deleteStudyItem(event) {
|
2023-07-07 21:45:09 +02:00
|
|
|
let item = event.data;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_delete_studyitem',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {'id': item.id}
|
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success == true) {
|
|
|
|
event.source.$emit('cut', event);
|
2023-07-07 21:45:09 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-07-07 21:45:09 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
showslot(page, line, index, layeridx, type) {
|
|
|
|
// Check if the slot should be hidden because a previous slot has an item with a span
|
2023-08-04 11:54:16 +02:00
|
|
|
// so big that it hides this slot
|
2024-06-05 22:22:19 +02:00
|
|
|
const forGradable = (type == 'gradable') ? true : false;
|
2023-11-05 15:49:32 +01:00
|
|
|
const periods = page.periods;
|
2023-08-04 11:54:16 +02:00
|
|
|
let show = true;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let i = 0; i < periods; i++) {
|
|
|
|
if (line.slots[index - i] && line.slots[index - i].courses) {
|
|
|
|
const list = line.slots[index - i].courses;
|
2024-06-05 23:27:00 +02:00
|
|
|
for (const ix in list) {
|
2023-08-04 11:54:16 +02:00
|
|
|
const item = list[ix];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (item.layer == layeridx) {
|
|
|
|
if (forGradable) {
|
|
|
|
if (i > 0 && (item.span - i) > 0) {
|
2023-08-04 11:54:16 +02:00
|
|
|
show = false;
|
|
|
|
}
|
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
if ((item.span - i) > 1) {
|
2023-08-04 11:54:16 +02:00
|
|
|
show = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2023-08-04 11:54:16 +02:00
|
|
|
return show;
|
2023-09-03 15:21:30 +02:00
|
|
|
},
|
|
|
|
periodEdited(pi) {
|
2024-03-10 23:09:33 +01:00
|
|
|
const prev = this.$refs["periodeditor-" + (pi.period - 1)];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (prev && prev[0]) {
|
2024-03-10 23:09:33 +01:00
|
|
|
prev[0].refresh();
|
2023-09-03 15:21:30 +02:00
|
|
|
}
|
2024-03-10 23:09:33 +01:00
|
|
|
const next = this.$refs["periodeditor-" + (pi.period + 1)];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (next && next[0]) {
|
2024-03-10 23:09:33 +01:00
|
|
|
next[0].refresh();
|
2023-09-03 15:21:30 +02:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
addDay(date, days) {
|
|
|
|
if (days === undefined) {
|
2023-09-03 16:54:09 +02:00
|
|
|
days = 1;
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return addDays(date, days);
|
2023-09-03 16:54:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
subDay(date, days) {
|
|
|
|
if (days === undefined) {
|
2023-09-03 16:54:09 +02:00
|
|
|
days = 1;
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return addDays(date, 0 - days);
|
2023-09-03 16:54:09 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
toolboxSwitched(event) {
|
|
|
|
this.$emit('toggletoolbox', event);
|
2023-11-05 15:49:32 +01:00
|
|
|
},
|
|
|
|
pagecreated(page) {
|
|
|
|
this.value.pages.push(page);
|
2023-11-05 22:33:57 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
selectedpageChanged(newTabIndex /* , prevTabIndex*/) {
|
2023-11-05 22:33:57 +01:00
|
|
|
const page = this.value.pages[newTabIndex];
|
2024-06-05 22:22:19 +02:00
|
|
|
this.$emit('pagechanged', page);
|
2024-05-27 22:11:32 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
sumLineLayers(idx, page) {
|
|
|
|
if (idx < 0 || page.studylines.count == 0) {
|
2024-05-27 22:11:32 +02:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
let sum = 0;
|
|
|
|
for (let i = 0; i < idx; i++) {
|
2024-06-05 22:22:19 +02:00
|
|
|
sum += this.countLineLayers(page.studylines[i], page) + 1;
|
2024-05-27 22:11:32 +02:00
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
span(line, slot, layer) {
|
2024-05-27 22:11:32 +02:00
|
|
|
let span = 1;
|
|
|
|
for (const course of line.slots[slot].courses) {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (course.slot == slot && course.layer == layer) {
|
2024-05-27 22:11:32 +02:00
|
|
|
span = course.span;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return span;
|
|
|
|
},
|
|
|
|
onDrop(event, line, slot) {
|
|
|
|
debug.info("dropping", event, line, slot);
|
|
|
|
const self = this;
|
|
|
|
if (event.type.component) { // Double check in case filter fails
|
|
|
|
debug.info("Adding new component");
|
2024-06-05 22:22:19 +02:00
|
|
|
if (event.type.type == "gradable") {
|
2024-05-27 22:11:32 +02:00
|
|
|
// Determine first available layer;
|
|
|
|
const lineslot = line.slots[slot].courses;
|
|
|
|
let nextlayer = 0;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const itm of lineslot) {
|
|
|
|
if (itm.layer >= nextlayer) {
|
2024-05-27 22:11:32 +02:00
|
|
|
nextlayer = itm.layer + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_add_studyitem',
|
|
|
|
args: {
|
|
|
|
"line_id": line.id,
|
2024-06-05 22:22:19 +02:00
|
|
|
"slot": slot,
|
|
|
|
"layer": nextlayer,
|
2024-05-27 22:11:32 +02:00
|
|
|
"type": 'course',
|
|
|
|
"details": {
|
|
|
|
"competency_id": null,
|
2024-06-05 22:22:19 +02:00
|
|
|
'conditions': '',
|
|
|
|
'course_id': event.data.id,
|
|
|
|
'badge_id': null,
|
|
|
|
'continuation_id': null,
|
2024-05-27 22:11:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
|
|
|
let item = response;
|
|
|
|
lineslot.push(item);
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("input", self.value);
|
2024-05-27 22:11:32 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// Call the validate period function on next tick,
|
2024-05-27 22:11:32 +02:00
|
|
|
// since it paints the item in the slot first
|
|
|
|
this.$nextTick(() => {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.$refs.timingChecker) {
|
|
|
|
this.$refs.timingChecker.validateCoursePeriod();
|
2024-05-27 22:11:32 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
ItemEventBus.$emit('coursechange');
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2024-05-27 22:11:32 +02:00
|
|
|
}).catch(notification.exception);
|
2024-06-05 22:22:19 +02:00
|
|
|
} else if (event.type.type == "filter") {
|
2024-05-27 22:11:32 +02:00
|
|
|
debug.info("Adding new filter compenent");
|
|
|
|
// Determine first available layer;
|
|
|
|
const lineslot = line.slots[slot].filters;
|
|
|
|
let nextlayer = 0;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const itm of lineslot) {
|
|
|
|
if (itm.layer >= nextlayer) {
|
2024-05-27 22:11:32 +02:00
|
|
|
nextlayer = itm.layer + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_add_studyitem',
|
|
|
|
args: {
|
|
|
|
"line_id": line.id,
|
2024-06-05 22:22:19 +02:00
|
|
|
"slot": slot,
|
2024-05-27 22:11:32 +02:00
|
|
|
"type": event.data.type,
|
2024-06-05 22:22:19 +02:00
|
|
|
"layer": nextlayer,
|
|
|
|
"details": {
|
|
|
|
"badge_id": event.data.badge ? event.data.badge.id : undefined,
|
2024-05-27 22:11:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
|
|
|
let item = response;
|
|
|
|
lineslot.push(item);
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("input", self.value);
|
|
|
|
return;
|
2024-05-27 22:11:32 +02:00
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
checkTypeCourse(type) {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (type.type == "gradable") {
|
|
|
|
if (settings("hivizdropslots") && !type.item) {
|
2024-05-27 22:11:32 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
checkTypeFilter(type) {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (type.type == "filter") {
|
|
|
|
if (settings("hivizdropslots") && !type.item) {
|
2024-05-27 22:11:32 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2023-09-03 20:57:14 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
},
|
2023-09-08 12:47:29 +02:00
|
|
|
template:
|
2023-07-07 21:45:09 +02:00
|
|
|
`
|
|
|
|
<div>
|
2024-03-09 08:23:42 +01:00
|
|
|
<t-toolbox v-model="edit.toolbox_shown"
|
|
|
|
:activepage="selectedpage"
|
2024-03-09 23:29:58 +01:00
|
|
|
:coaching="coaching"
|
|
|
|
:studyplanid="value.id"></t-toolbox>
|
2023-07-07 21:45:09 +02:00
|
|
|
<div class='controlbox t-studyplan-controlbox'>
|
2023-09-03 20:57:14 +02:00
|
|
|
<div class="controlbox-group">
|
2024-03-09 00:11:42 +01:00
|
|
|
<b-form-checkbox v-if="!coaching"
|
|
|
|
v-model="edit.studyline.editmode" class="sw-studyplan-toolbar" switch
|
2024-06-05 22:22:19 +02:00
|
|
|
@change="toolboxSwitched(edit.toolbox_shown && !edit.studyline.editmode); "
|
2023-09-03 20:57:14 +02:00
|
|
|
>{{ text.studyline_editmode }}</b-form-checkbox>
|
2024-06-05 23:27:00 +02:00
|
|
|
<b-form-checkbox
|
2024-04-21 23:08:03 +02:00
|
|
|
v-if="!edit.studyline.editmode" v-model="edit.toolbox_shown" class="sw-studyplan-toolbar" switch
|
2024-06-05 22:22:19 +02:00
|
|
|
@change="toolboxSwitched"
|
2023-09-03 20:57:14 +02:00
|
|
|
>{{ text.toolbox_toggle}}</b-form-checkbox>
|
2024-06-05 23:27:00 +02:00
|
|
|
<drop
|
2023-09-03 20:57:14 +02:00
|
|
|
mode='copy'
|
|
|
|
class='t-item-deletebox text-danger border-danger'
|
|
|
|
@drop='deleteStudyItem'
|
2024-06-05 22:22:19 +02:00
|
|
|
:accepts-type="trashbinAccepts"
|
2023-09-03 20:57:14 +02:00
|
|
|
><i class='fa fa-trash'></i>
|
|
|
|
</drop>
|
|
|
|
</div>
|
2024-03-09 00:11:42 +01:00
|
|
|
<div class="controlbox-group" v-if="!coaching">
|
2023-09-03 20:57:14 +02:00
|
|
|
<span class='control editable'>
|
2023-11-11 20:17:45 +01:00
|
|
|
<t-studyplan-advanced v-model="value" :selectedpage="selectedpage"></t-studyplan-advanced>
|
2023-09-03 20:57:14 +02:00
|
|
|
</span>
|
|
|
|
<span class='control editable'>
|
2023-09-08 12:47:29 +02:00
|
|
|
<t-studyplan-associate
|
2023-09-03 20:57:14 +02:00
|
|
|
v-model="value"><i class='fa fa-users'></i> {{text.associations}}</t-studyplan-associate>
|
|
|
|
</span>
|
|
|
|
<span class='control editable'>
|
2024-06-05 23:27:00 +02:00
|
|
|
<t-studyplan-edit v-model="value" @moved="movedStudyplan"
|
2024-06-05 22:22:19 +02:00
|
|
|
><i class='fa fa-gear'></i> {{text.edit}}</t-studyplan-edit>
|
2023-09-03 20:57:14 +02:00
|
|
|
</span>
|
|
|
|
<span class='control deletable'>
|
2024-03-04 22:39:29 +01:00
|
|
|
<a v-if='value.pages.length == 0' href='#' @click.prevent='deletePlan(value)'
|
2023-09-03 20:57:14 +02:00
|
|
|
><i class='text-danger fa fa-trash'></i></a>
|
|
|
|
</span>
|
|
|
|
</div>
|
2023-07-07 21:45:09 +02:00
|
|
|
</div>
|
2023-11-05 22:33:57 +01:00
|
|
|
<b-card no-body>
|
2024-06-05 23:27:00 +02:00
|
|
|
<b-tabs
|
|
|
|
v-model='selectedpageindex'
|
2023-11-05 22:33:57 +01:00
|
|
|
@activate-tab='selectedpageChanged'
|
|
|
|
content-class="mt-1">
|
|
|
|
<!-- New Tab Button (Using tabs-end slot) -->
|
|
|
|
<template #tabs-end>
|
2024-06-05 23:27:00 +02:00
|
|
|
<t-studyplan-page-edit
|
2024-03-09 00:11:42 +01:00
|
|
|
v-if="!coaching"
|
2023-11-05 15:49:32 +01:00
|
|
|
:studyplan="value"
|
2023-11-05 22:33:57 +01:00
|
|
|
v-model="create.page"
|
2023-11-05 15:49:32 +01:00
|
|
|
type="link"
|
2023-11-05 22:33:57 +01:00
|
|
|
mode="create"
|
|
|
|
@created="pagecreated"
|
|
|
|
><i class='fa fa-plus'></i></t-studyplan-page-edit>
|
2023-07-07 21:45:09 +02:00
|
|
|
</template>
|
2023-11-05 22:33:57 +01:00
|
|
|
<b-tab
|
|
|
|
v-for="(page,pageindex) in value.pages"
|
|
|
|
:key="page.id"
|
2023-11-05 15:49:32 +01:00
|
|
|
>
|
2023-11-05 22:33:57 +01:00
|
|
|
<template #title>
|
|
|
|
{{page.shortname}}
|
2024-06-05 23:27:00 +02:00
|
|
|
<t-studyplan-page-edit
|
2024-03-09 00:11:42 +01:00
|
|
|
v-if="!coaching && (pageindex == selectedpageindex)"
|
2023-11-05 22:33:57 +01:00
|
|
|
v-model="value.pages[pageindex]"
|
|
|
|
:studyplan="value"
|
|
|
|
type="link"
|
|
|
|
></t-studyplan-page-edit>
|
|
|
|
</template>
|
2024-06-05 23:27:00 +02:00
|
|
|
<div class='t-studyplan-content-edit'
|
2023-11-05 22:33:57 +01:00
|
|
|
v-if="edit.studyline.editmode">
|
|
|
|
<drop-list
|
|
|
|
:items="page.studylines"
|
|
|
|
class="t-slot-droplist"
|
|
|
|
:accepts-type="'studyline-'+page.id"
|
|
|
|
@reorder="reorderLines($event,page.studylines)"
|
|
|
|
mode="copy"
|
|
|
|
row
|
|
|
|
>
|
|
|
|
<template v-slot:item="{item}">
|
|
|
|
<drag
|
|
|
|
:key="item.id"
|
|
|
|
class='t-studyline-drag'
|
|
|
|
:data="item"
|
|
|
|
:type="'studyline-'+page.id"
|
2023-11-05 15:49:32 +01:00
|
|
|
>
|
2023-11-05 22:33:57 +01:00
|
|
|
<template v-slot:drag-image>
|
|
|
|
<i class="fa fa-arrows text-primary"></i>
|
|
|
|
</template>
|
|
|
|
<t-studyline-edit
|
2024-03-09 00:11:42 +01:00
|
|
|
v-if="!coaching"
|
2023-11-05 22:33:57 +01:00
|
|
|
v-model="item"
|
|
|
|
@edit='editLineStart(item)'
|
|
|
|
@delete='deleteLine(page,item)'
|
|
|
|
>
|
|
|
|
<div v-if="!slotsempty(item.slots)"> {{ text.editmode_modules_hidden}} </div>
|
|
|
|
</t-studyline-edit>
|
|
|
|
</drag>
|
|
|
|
</template>
|
|
|
|
</drop-list>
|
2023-11-05 15:49:32 +01:00
|
|
|
</div>
|
2023-11-05 22:33:57 +01:00
|
|
|
<div class='t-studyplan-content' v-else>
|
|
|
|
<!-- Now paint the headings column -->
|
|
|
|
<div class='t-studyplan-headings'>
|
|
|
|
<s-studyline-header-heading :identifier='Number(page.id)'></s-studyline-header-heading>
|
|
|
|
<template v-if="page.studylines.length > 0">
|
|
|
|
<t-studyline-heading v-for="(line,lineindex) in page.studylines"
|
|
|
|
:key="line.id"
|
|
|
|
@resize="headingresized(lineindex,$event)"
|
|
|
|
v-model="page.studylines[lineindex]"
|
|
|
|
:layers='countLineLayers(line,page)+1'
|
|
|
|
:class=" 't-studyline' + ((lineindex%2==0)?' odd ' :' even ' )
|
|
|
|
+ ((lineindex==0)?' first ':' ')
|
|
|
|
+ ((lineindex==page.studylines.length-1)?' last ':' ')"
|
|
|
|
></t-studyline-heading>
|
|
|
|
</template>
|
|
|
|
<t-studyline-heading v-else
|
|
|
|
@resize="headingresized(0,$event)"
|
2024-06-05 23:27:00 +02:00
|
|
|
|
2023-11-05 22:33:57 +01:00
|
|
|
:layers="1"
|
|
|
|
:class="'odd first last'"
|
|
|
|
></t-studyline-heading>
|
|
|
|
</div>
|
|
|
|
<!-- Next, paint all the cells in the scrollable -->
|
|
|
|
<div class="t-studyplan-scrollable" >
|
2024-06-05 22:22:19 +02:00
|
|
|
<div class="t-studyplan-timeline" :style="columnsStylerule(page)">
|
2024-06-05 23:27:00 +02:00
|
|
|
<!-- add period information -->
|
2023-11-05 22:33:57 +01:00
|
|
|
<template v-for="(n,index) in (page.periods+1)">
|
|
|
|
<s-studyline-header-period
|
2024-04-21 23:08:03 +02:00
|
|
|
mode="edit"
|
2024-05-27 22:11:32 +02:00
|
|
|
:x-index="index"
|
2024-06-05 23:27:00 +02:00
|
|
|
:style="'grid-area: 1 / '+ ((2*index)) +';'"
|
2023-11-05 22:33:57 +01:00
|
|
|
:identifier='Number(page.id)'
|
|
|
|
v-if="index > 0"
|
2023-11-05 15:49:32 +01:00
|
|
|
v-model="page.perioddesc[index-1]"
|
2023-11-05 22:33:57 +01:00
|
|
|
><t-period-edit
|
2024-03-09 00:11:42 +01:00
|
|
|
v-if="!coaching"
|
2023-11-05 22:33:57 +01:00
|
|
|
:ref="'periodeditor-'+index"
|
|
|
|
@edited="periodEdited"
|
|
|
|
v-model="page.perioddesc[index-1]"
|
2024-06-05 22:22:19 +02:00
|
|
|
:minstart="(index > 1) ? addDay(page.perioddesc[index-2].startdate,2) : null"
|
|
|
|
:maxend="(index < page.periods) ? subDay(page.perioddesc[index].enddate,2) : null"
|
2023-11-05 22:33:57 +01:00
|
|
|
></t-period-edit
|
|
|
|
></s-studyline-header-period>
|
2024-06-05 23:27:00 +02:00
|
|
|
<div class="s-studyline-header-filter"
|
2024-05-27 22:11:32 +02:00
|
|
|
:x-index="index"
|
2024-06-05 23:27:00 +02:00
|
|
|
:style="'grid-area: 1 / '+ ((2*index)+1) +';'"
|
2024-05-27 22:11:32 +02:00
|
|
|
></div>
|
2023-11-05 22:33:57 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<!-- Line by line add the items -->
|
|
|
|
<!-- The grid layout handles putting it in rows and columns -->
|
|
|
|
<template v-for="(line,lineindex) in page.studylines"
|
|
|
|
><template v-for="(layernr,layeridx) in countLineLayers(line,page)+1"
|
|
|
|
><template v-for="(n,index) in (page.periods+1)"
|
2024-01-27 16:21:04 +01:00
|
|
|
><t-studyline-slot
|
2023-11-05 22:33:57 +01:00
|
|
|
v-if="index > 0 && showslot(page,line, index, layeridx, 'gradable')"
|
2024-06-05 23:27:00 +02:00
|
|
|
:style="'grid-area: '+ (1+sumLineLayers(lineindex,page)+layernr)
|
|
|
|
+ ' / ' + (2 * index)
|
|
|
|
+ ' / ' + (1 + sumLineLayers(lineindex,page)+layernr)
|
|
|
|
+ ' / ' + ( (2 * index) + (2*span(line,index,layeridx) - 1)) + ';'"
|
2023-11-05 22:33:57 +01:00
|
|
|
type='gradable'
|
|
|
|
v-model="line.slots[index].courses"
|
|
|
|
:key="'c-'+lineindex+'-'+index+'-'+layernr"
|
|
|
|
:slotindex="index"
|
|
|
|
:line="line"
|
|
|
|
:plan="value"
|
|
|
|
:page="page"
|
|
|
|
:period="page.perioddesc[index-1]"
|
|
|
|
:layer="layeridx"
|
|
|
|
:class="'t-studyline ' + ((lineindex%2==0)?' odd ':' even ')
|
|
|
|
+ ((lineindex==0 && layernr==1)?' first ':' ')
|
|
|
|
+ ((lineindex==page.studylines.length-1)?' last ':' ')
|
|
|
|
+ ((layernr == countLineLayers(line,page))?' lastlyr ':' ')
|
|
|
|
+ ((layernr == countLineLayers(line,page)+1)?' newlyr ':' ')"
|
|
|
|
></t-studyline-slot
|
|
|
|
><t-studyline-slot
|
|
|
|
type='filter'
|
2024-06-05 23:27:00 +02:00
|
|
|
:style="'grid-area: '+ (1+sumLineLayers(lineindex,page)+layernr) + ' / ' + (2*index+1) +';'"
|
2023-11-05 22:33:57 +01:00
|
|
|
v-if="showslot(page,line, index, layeridx, 'filter')"
|
|
|
|
v-model="line.slots[index].filters"
|
|
|
|
:key="'f-'+lineindex+'-'+index+'-'+layernr"
|
|
|
|
:slotindex="index"
|
|
|
|
:line="line"
|
|
|
|
:plan="value"
|
|
|
|
:page="page"
|
|
|
|
:layer="layeridx"
|
|
|
|
:class="'t-studyline ' + ((lineindex%2==0)?' odd ':' even ')
|
|
|
|
+ ((lineindex==0 && layernr==1)?' first ':'')
|
|
|
|
+ ((lineindex==page.studylines.length-1)?' last ':' ')
|
|
|
|
+ ((index==page.periods)?' rightmost':'')
|
|
|
|
+ ((layernr == countLineLayers(line,page))?' lastlyr ':' ')
|
|
|
|
+ ((layernr == countLineLayers(line,page)+1)?' newlyr ':' ')"
|
|
|
|
></t-studyline-slot
|
|
|
|
></template
|
2023-11-05 15:49:32 +01:00
|
|
|
></template
|
|
|
|
></template
|
2024-05-27 22:11:32 +02:00
|
|
|
><template v-if="hivizdrop"
|
|
|
|
><template v-for="(line,lineindex) in page.studylines"
|
|
|
|
><template v-for="(n,index) in (page.periods+1)"
|
|
|
|
><drop v-if="index > 0"
|
2024-06-05 23:27:00 +02:00
|
|
|
:style="'grid-area: '+ (2 + sumLineLayers(lineindex,page))
|
|
|
|
+ ' / ' + (2 * index)
|
|
|
|
+ ' / ' + (1 + sumLineLayers(lineindex + 1,page))
|
|
|
|
+ ' / ' + (2 * index) + '; overflow: hidden;'"
|
2024-05-27 22:11:32 +02:00
|
|
|
:class="'t-slot-drop t-slot-linedrop course hiviz'"
|
|
|
|
:accepts-type="checkTypeCourse"
|
|
|
|
@drop="onDrop($event,line,index)"
|
|
|
|
mode="cut"
|
|
|
|
><span>{{text.drophere}}</span></drop
|
2024-06-05 23:27:00 +02:00
|
|
|
><drop
|
|
|
|
:style="'grid-area: '+ (2 + sumLineLayers(lineindex,page))
|
2024-05-27 22:11:32 +02:00
|
|
|
+ ' / ' + ((2 * index) + 1)
|
2024-06-05 23:27:00 +02:00
|
|
|
+ ' / ' + (1 + sumLineLayers(lineindex + 1,page))
|
|
|
|
+ ' / ' + ( (2 * index) + 1 ) + '; overflow: hidden;'"
|
2024-05-27 22:11:32 +02:00
|
|
|
:class="'t-slot-drop t-slot-linedrop filter hiviz'"
|
|
|
|
:accepts-type="checkTypeFilter"
|
|
|
|
@drop="onDrop($event,line,index)"
|
|
|
|
mode="cut"
|
|
|
|
><span>{{text.drophere}}</span></drop
|
|
|
|
></template
|
|
|
|
></template
|
|
|
|
></template
|
2023-11-05 22:33:57 +01:00
|
|
|
></div>
|
|
|
|
</div>
|
2023-11-05 15:49:32 +01:00
|
|
|
</div>
|
2023-11-05 22:33:57 +01:00
|
|
|
<div v-if="edit.studyline.editmode" class='t-studyline-add ml-2 mt-1'>
|
2024-03-04 22:39:29 +01:00
|
|
|
<a href="#" v-b-modal="'modal-add-studyline-'+page.id" @click.prevent="false;"
|
2023-11-05 22:33:57 +01:00
|
|
|
><i class='fa fa-plus'></i>{{ text.studyline_add }}</a>
|
|
|
|
</div>
|
|
|
|
<b-modal
|
|
|
|
:id="'modal-add-studyline-'+page.id"
|
|
|
|
size="lg"
|
2024-06-05 22:22:19 +02:00
|
|
|
:ok-title="text.add"
|
2023-11-05 22:33:57 +01:00
|
|
|
ok-variant="primary"
|
|
|
|
:title="text.studyline_add"
|
|
|
|
@ok="addStudyLine(page,create.studyline)"
|
|
|
|
:ok-disabled="Math.min(create.studyline.name.length,create.studyline.shortname.length) == 0"
|
|
|
|
>
|
|
|
|
<b-container>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{text.studyline_name}}</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-form-input v-model="create.studyline.name" :placeholder="text.studyline_name_ph"></b-form-input>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{text.studyline_shortname}}</b-col>
|
|
|
|
<b-col>
|
2023-11-05 15:49:32 +01:00
|
|
|
<b-form-input
|
2023-11-05 22:33:57 +01:00
|
|
|
v-model="create.studyline.shortname"
|
|
|
|
:placeholder="text.studyline_shortname_ph"></b-form-input>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{text.studyline_color}}</b-col>
|
|
|
|
<b-col>
|
|
|
|
<input type="color" v-model="create.studyline.color" />
|
|
|
|
<!-- hsluv-picker v-model="create.studyline.color" horizontal displaysize="175" ></hsluv-picker -->
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2024-02-25 23:45:39 +01:00
|
|
|
<template v-if="premiumenabled()">
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{ text.studyline_enrollable}}</b-col>
|
|
|
|
<b-col>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-form-select v-model="create.studyline.enrol.enrollable">
|
2024-06-05 23:27:00 +02:00
|
|
|
<b-form-select-option
|
2024-02-25 23:45:39 +01:00
|
|
|
v-for="(nr,n) in 4"
|
|
|
|
:value="n"
|
2024-03-09 22:51:34 +01:00
|
|
|
:key="n"
|
2024-02-25 23:45:39 +01:00
|
|
|
>{{text['line_enrollable_'+n]}}</b-form-select-option>
|
|
|
|
</b-form-select>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-row v-if='[2,3].includes(create.studyline.enrol.enrollable)'>
|
2024-02-25 23:45:39 +01:00
|
|
|
<b-col cols="3">{{ text.studyline_enrolroles}}</b-col>
|
|
|
|
<b-col>
|
2024-06-05 23:27:00 +02:00
|
|
|
<b-form-select
|
2024-03-04 22:39:29 +01:00
|
|
|
v-model="create.studyline.enrol.enrolroles"
|
2024-02-25 23:45:39 +01:00
|
|
|
:options="availableroles"
|
|
|
|
multiple
|
|
|
|
value-field="id"
|
|
|
|
text-field="name"
|
|
|
|
:select-size="6"
|
|
|
|
></b-form-select>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2024-06-05 23:27:00 +02:00
|
|
|
</template>
|
2023-11-05 22:33:57 +01:00
|
|
|
</b-container>
|
|
|
|
</b-modal>
|
|
|
|
<b-modal
|
|
|
|
:id="'modal-edit-studyline-'+page.id"
|
|
|
|
size="lg"
|
|
|
|
ok-variant="primary"
|
|
|
|
:title="text.studyline_edit"
|
|
|
|
@ok="editLineFinish()"
|
|
|
|
:ok-disabled="Math.min(edit.studyline.data.name.length,edit.studyline.data.shortname.length) == 0"
|
|
|
|
>
|
|
|
|
<b-container>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{ text.studyline_name}}</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-form-input
|
|
|
|
v-model="edit.studyline.data.name"
|
|
|
|
:placeholder="text.studyline_name_ph"></b-form-input>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{ text.studyline_shortname}}</b-col>
|
|
|
|
<b-col>
|
|
|
|
<b-form-input
|
|
|
|
v-model="edit.studyline.data.shortname"
|
|
|
|
:placeholder="text.studyline_shortname_ph"></b-form-input>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{ text.studyline_color}}</b-col>
|
|
|
|
<b-col>
|
|
|
|
<input type="color" v-model="edit.studyline.data.color" />
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2024-02-25 23:45:39 +01:00
|
|
|
<template v-if="premiumenabled()">
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="3">{{ text.studyline_enrollable}}</b-col>
|
|
|
|
<b-col>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-form-select v-model="edit.studyline.data.enrol.enrollable">
|
2024-06-05 23:27:00 +02:00
|
|
|
<b-form-select-option
|
2024-02-25 23:45:39 +01:00
|
|
|
v-for="(nr,n) in 4"
|
|
|
|
:value="n"
|
|
|
|
>{{text['line_enrollable_'+n]}}</b-form-select-option>
|
|
|
|
</b-form-select>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-row v-if='[2,3].includes(edit.studyline.data.enrol.enrollable)'>
|
2024-02-25 23:45:39 +01:00
|
|
|
<b-col cols="3">{{ text.studyline_enrolroles}}</b-col>
|
|
|
|
<b-col>
|
2024-06-05 23:27:00 +02:00
|
|
|
<b-form-select
|
2024-03-04 22:39:29 +01:00
|
|
|
v-model="edit.studyline.data.enrol.enrolroles"
|
2024-02-25 23:45:39 +01:00
|
|
|
:options="availableroles"
|
|
|
|
multiple
|
|
|
|
value-field="id"
|
|
|
|
text-field="name"
|
|
|
|
:select-size="6"
|
|
|
|
></b-form-select>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
</template>
|
2023-11-05 22:33:57 +01:00
|
|
|
</b-container>
|
|
|
|
</b-modal>
|
|
|
|
</b-tab>
|
|
|
|
</b-tabs>
|
|
|
|
</b-card>
|
2023-07-07 21:45:09 +02:00
|
|
|
</div>
|
|
|
|
`
|
2023-05-17 21:19:14 +02:00
|
|
|
});
|
|
|
|
|
2023-07-07 21:45:09 +02:00
|
|
|
/*
|
|
|
|
* T-STUDYLINE-HEADER
|
|
|
|
*/
|
2023-07-07 23:17:21 +02:00
|
|
|
Vue.component('t-studyline-heading', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-07-26 16:42:34 +02:00
|
|
|
type: Object, // Studyline
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-07-07 23:17:21 +02:00
|
|
|
},
|
2023-07-18 13:19:48 +02:00
|
|
|
layers: {
|
|
|
|
type: Number,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': 1,
|
2023-07-18 13:19:48 +02:00
|
|
|
},
|
2023-07-07 23:17:21 +02:00
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2023-07-18 13:19:48 +02:00
|
|
|
layerHeights: {}
|
2023-07-07 21:45:09 +02:00
|
|
|
};
|
|
|
|
},
|
2023-07-10 23:11:23 +02:00
|
|
|
created() {
|
2023-07-28 00:04:24 +02:00
|
|
|
// Listener for the signal that a new connection was made and needs to be drawn
|
|
|
|
// Sent by the incoming item - By convention, outgoing items are responsible for drawing the lines
|
|
|
|
ItemEventBus.$on('lineHeightChange', this.onLineHeightChange);
|
2023-07-10 23:11:23 +02:00
|
|
|
},
|
2023-07-07 21:45:09 +02:00
|
|
|
computed: {
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
onLineHeightChange(lineid) { // Is called with parameters (lineid, layerid, newheight)
|
2023-07-18 13:19:48 +02:00
|
|
|
// All layers for this line have the first slot send an update message on layer height change.
|
2023-09-08 12:47:29 +02:00
|
|
|
// When one of those updates is received, record the height and recalculate the total height of the
|
2023-07-18 13:19:48 +02:00
|
|
|
// header
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.$refs.main && lineid == this.value.id) {
|
2023-07-18 13:19:48 +02:00
|
|
|
const items = document.querySelectorAll(
|
2023-07-18 13:40:30 +02:00
|
|
|
`.t-studyline-slot-0[data-studyline='${this.value.id}']`);
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// Determine the height of all the lines and add them up.
|
2023-07-18 13:19:48 +02:00
|
|
|
let heightSum = 0;
|
2023-07-18 13:40:30 +02:00
|
|
|
items.forEach((el) => {
|
2024-06-05 22:22:19 +02:00
|
|
|
// Func getBoundingClientRect() Gets the actual fractional height instead of rounded to integer pixels
|
2023-07-18 13:49:41 +02:00
|
|
|
const r = el.getBoundingClientRect();
|
|
|
|
const height = r.height;
|
2023-07-18 13:19:48 +02:00
|
|
|
heightSum += height;
|
2023-07-18 13:40:30 +02:00
|
|
|
});
|
2023-07-18 13:19:48 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
const heightStyle = `${heightSum}px`;
|
2023-07-28 00:04:24 +02:00
|
|
|
this.$refs.main.style.height = heightStyle;
|
2023-07-10 23:11:23 +02:00
|
|
|
}
|
|
|
|
}
|
2023-07-07 21:45:09 +02:00
|
|
|
},
|
|
|
|
template: `
|
2023-09-08 12:47:29 +02:00
|
|
|
<div class="t-studyline t-studyline-heading "
|
2023-07-28 00:04:24 +02:00
|
|
|
:data-studyline="value.id" ref="main"
|
2023-07-07 23:17:21 +02:00
|
|
|
><div class="t-studyline-handle" :style="'background-color: ' + value.color"></div>
|
2023-07-07 21:45:09 +02:00
|
|
|
<div class="t-studyline-title">
|
2023-09-02 20:34:33 +02:00
|
|
|
<abbr v-b-tooltip.hover.right :title="value.name">{{ value.shortname }}</abbr>
|
2023-07-07 21:45:09 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
});
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
/*
|
2023-07-07 21:45:09 +02:00
|
|
|
* T-STUDYLINE (Used only for study line edit mode)
|
2023-05-17 21:19:14 +02:00
|
|
|
*/
|
2023-07-07 23:17:21 +02:00
|
|
|
Vue.component('t-studyline-edit', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-07-26 16:42:34 +02:00
|
|
|
type: Object, // Studyline
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-08-15 15:43:54 +02:00
|
|
|
}
|
2023-07-07 23:17:21 +02:00
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2023-07-07 23:17:21 +02:00
|
|
|
deletable() {
|
|
|
|
// Check if all the slots are empty
|
|
|
|
const slots = this.value.slots;
|
2024-06-05 22:22:19 +02:00
|
|
|
if (Array.isArray(slots)) {
|
2023-07-07 23:17:21 +02:00
|
|
|
let count = 0;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let i = 0; i < slots.length; i++) {
|
|
|
|
if (Array.isArray(slots[i].courses)) {
|
2023-08-28 11:26:14 +02:00
|
|
|
count += slots[i].courses.length;
|
2023-07-07 23:17:21 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
if (Array.isArray(slots[i].filters)) {
|
2023-07-07 23:17:21 +02:00
|
|
|
count += slots[i].filters.length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (count == 0);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2023-08-15 15:43:54 +02:00
|
|
|
},
|
|
|
|
editable() {
|
|
|
|
return true;
|
2023-07-07 23:17:21 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onEdit() {
|
2024-06-05 22:22:19 +02:00
|
|
|
this.$emit('edit', this.value);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
onDelete() {
|
2024-06-05 22:22:19 +02:00
|
|
|
this.$emit('delete', this.value);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
template: `
|
2023-09-08 12:47:29 +02:00
|
|
|
<div :class="'t-studyline '" >
|
2023-07-07 23:17:21 +02:00
|
|
|
<div class="t-studyline-handle" :style="'background-color: ' + value.color"></div>
|
2023-05-17 21:19:14 +02:00
|
|
|
<div class="t-studyline-title">
|
|
|
|
<div>
|
2023-07-07 23:17:21 +02:00
|
|
|
<i class='fa fa-arrows text-primary'></i>
|
|
|
|
<abbr v-b-tooltip.hover :title="value.name">{{ value.shortname }}</abbr>
|
2023-05-17 21:19:14 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-07 23:17:21 +02:00
|
|
|
<div class='t-studyline-editmode-content'>
|
2023-05-17 21:19:14 +02:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2023-07-26 23:24:34 +02:00
|
|
|
<div class='controlbox'>
|
|
|
|
<template v-if='editable || deletable'>
|
2023-08-15 15:43:54 +02:00
|
|
|
<span class='control editable' v-if='editable'>
|
2024-03-04 22:39:29 +01:00
|
|
|
<a href='#' @click.prevent='onEdit'><i class='fa fa-pencil'></i></a>
|
2023-05-17 21:19:14 +02:00
|
|
|
</span>
|
2023-08-15 15:43:54 +02:00
|
|
|
<span class='control deletable' v-if='deletable'>
|
2024-03-04 22:39:29 +01:00
|
|
|
<a v-if='deletable' href='#' @click.prevent='onDelete'><i class='text-danger fa fa-trash'></i></a>
|
2023-05-17 21:19:14 +02:00
|
|
|
</span>
|
2023-07-26 23:24:34 +02:00
|
|
|
</template>
|
2023-05-17 21:19:14 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2023-07-15 22:00:17 +02:00
|
|
|
/*
|
|
|
|
* During a redisign it was decided to have the studyline still get the entire array as a value,
|
2023-09-08 12:47:29 +02:00
|
|
|
* even though it only shows one drop slot for the layer it is in. This is to make repainting easier,
|
2023-07-26 16:42:34 +02:00
|
|
|
* since we modify the array for the layer we handle. FIXME: Make this less weird
|
2023-07-15 22:00:17 +02:00
|
|
|
*/
|
2023-05-17 21:19:14 +02:00
|
|
|
Vue.component('t-studyline-slot', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
type: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: String,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': 'gradable',
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
slotindex: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Number,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': '',
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
line: {
|
2023-07-07 23:17:21 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
layer: {
|
2023-07-15 22:00:17 +02:00
|
|
|
type: Number,
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
value: {
|
2024-06-05 22:22:19 +02:00
|
|
|
type: Array, // Dict with layer as index
|
|
|
|
default() {
|
|
|
|
return [];
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
plan: {
|
2023-07-26 16:42:34 +02:00
|
|
|
type: Object, // Studyplan data
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-07-07 23:17:21 +02:00
|
|
|
},
|
2023-07-30 04:08:57 +02:00
|
|
|
page: {
|
|
|
|
type: Object, // Studyplan data
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-07-30 04:08:57 +02:00
|
|
|
},
|
|
|
|
period: {
|
|
|
|
type: Object, // Studyplan data
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2023-07-10 23:11:23 +02:00
|
|
|
mounted() {
|
2024-06-05 22:22:19 +02:00
|
|
|
const self = this;
|
|
|
|
if (self.type == "gradable" && self.slotindex == 1) {
|
2023-07-10 23:11:23 +02:00
|
|
|
self.resizeListener = new ResizeObserver(() => {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (self.$refs.main) {
|
2023-07-28 00:04:24 +02:00
|
|
|
const size = self.$refs.main.getBoundingClientRect();
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2023-07-28 00:04:24 +02:00
|
|
|
ItemEventBus.$emit('lineHeightChange', self.line.id, self.layer, size.height);
|
2023-07-18 13:19:48 +02:00
|
|
|
}
|
2023-07-28 00:04:24 +02:00
|
|
|
}).observe(self.$refs.main);
|
2023-07-10 23:11:23 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
unmounted() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.resizeListener) {
|
2023-07-10 23:11:23 +02:00
|
|
|
this.resizeListener.disconnect();
|
|
|
|
}
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
computed: {
|
2024-06-05 22:22:19 +02:00
|
|
|
slotkey() {
|
2023-07-30 04:08:57 +02:00
|
|
|
return `${this.type}'-'${this.line.id}-${this.slotindex}-${this.layer}`;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
itemidx() {
|
|
|
|
for (const ix in this.value) {
|
2023-08-07 20:27:36 +02:00
|
|
|
const itm = this.value[ix];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (itm.layer == this.layer) {
|
2023-08-07 20:27:36 +02:00
|
|
|
return ix;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
item() {
|
|
|
|
for (const ix in this.value) {
|
2023-07-27 15:07:14 +02:00
|
|
|
const itm = this.value[ix];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (itm.layer == this.layer) {
|
2023-07-15 22:00:17 +02:00
|
|
|
return itm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
listtype() {
|
|
|
|
return this.type;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
courseHoverDummy() {
|
2023-07-15 22:00:17 +02:00
|
|
|
return {course: this.hover.component};
|
2023-08-03 18:44:57 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
spanCss() {
|
|
|
|
if (this.item && this.item.span > 1) {
|
|
|
|
// Calculate span like this:
|
|
|
|
// const span = (2 * this.item.span) - 1;
|
2024-05-27 22:11:32 +02:00
|
|
|
return `width: 100%; `;
|
2023-08-04 11:54:16 +02:00
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
2023-07-15 22:00:17 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.courseTiming,
|
|
|
|
plantext: strings.studyplanText,
|
2023-07-10 23:11:23 +02:00
|
|
|
resizeListener: null,
|
2023-09-08 12:47:29 +02:00
|
|
|
hover: {
|
2024-06-05 22:22:19 +02:00
|
|
|
component: null,
|
2023-07-15 22:00:17 +02:00
|
|
|
type: null,
|
2023-07-30 04:08:57 +02:00
|
|
|
},
|
|
|
|
datechanger: {
|
|
|
|
coursespan: null,
|
|
|
|
periodspan: null,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': false,
|
2023-07-30 04:08:57 +02:00
|
|
|
defaultchoice: false,
|
|
|
|
hidewarn: false,
|
2023-07-15 22:00:17 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2024-04-21 23:08:03 +02:00
|
|
|
hivizdrop() {
|
|
|
|
return settings("hivizdropslots");
|
|
|
|
},
|
2023-07-15 22:00:17 +02:00
|
|
|
onDrop(event) {
|
|
|
|
this.hover.component = null;
|
|
|
|
this.hover.type = null;
|
2023-08-15 15:34:53 +02:00
|
|
|
debug.info(event);
|
2023-05-17 21:19:14 +02:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
if (event.type.item) {
|
2023-05-17 21:19:14 +02:00
|
|
|
let item = event.data;
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2023-08-04 11:54:16 +02:00
|
|
|
// To avoid weird visuals with the lines,
|
|
|
|
// we add the item to the proper place in the front-end first
|
|
|
|
item.layer = this.layer;
|
|
|
|
item.slot = this.slotindex;
|
|
|
|
self.value.push(item);
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("input", self.value);
|
2023-08-04 11:54:16 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// Then on the next tick, we inform the back end
|
2023-08-04 11:54:16 +02:00
|
|
|
// Since moving things around has never been unsuccessful, unless you have other problems,
|
|
|
|
// it's better to have nice visuals.
|
2024-06-05 22:22:19 +02:00
|
|
|
self.relocateStudyItem(item).then(() => {
|
|
|
|
if (this.$refs.timingChecker) {
|
|
|
|
this.$refs.timingChecker.validateCoursePeriod();
|
2023-08-06 23:17:36 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
|
|
|
} else if (event.type.component) {
|
2023-08-15 15:34:53 +02:00
|
|
|
debug.info("Adding new component");
|
2024-06-05 22:22:19 +02:00
|
|
|
if (event.type.type == "gradable") {
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_add_studyitem',
|
2023-09-08 12:47:29 +02:00
|
|
|
args: {
|
2023-07-07 23:17:21 +02:00
|
|
|
"line_id": self.line.id,
|
2024-06-05 22:22:19 +02:00
|
|
|
"slot": self.slotindex,
|
|
|
|
"layer": self.layer,
|
2023-05-17 21:19:14 +02:00
|
|
|
"type": 'course',
|
|
|
|
"details": {
|
|
|
|
"competency_id": null,
|
2024-06-05 22:22:19 +02:00
|
|
|
'conditions': '',
|
|
|
|
'course_id': event.data.id,
|
|
|
|
'badge_id': null,
|
|
|
|
'continuation_id': null,
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].then((response) => {
|
2023-05-17 21:19:14 +02:00
|
|
|
let item = response;
|
2024-06-05 22:22:19 +02:00
|
|
|
self.relocateStudyItem(item).then(()=>{
|
2023-07-15 22:00:17 +02:00
|
|
|
self.value.push(item);
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("input", self.value);
|
2023-08-06 23:17:36 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// Call the validate period function on next tick,
|
2023-08-04 11:54:16 +02:00
|
|
|
// since it paints the item in the slot first
|
2023-08-06 23:17:36 +02:00
|
|
|
this.$nextTick(() => {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.$refs.timingChecker) {
|
|
|
|
this.$refs.timingChecker.validateCoursePeriod();
|
2023-08-06 23:17:36 +02:00
|
|
|
}
|
|
|
|
});
|
2023-12-02 23:22:00 +01:00
|
|
|
ItemEventBus.$emit('coursechange');
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2024-06-05 22:22:19 +02:00
|
|
|
} else if (event.type.type == "filter") {
|
2023-08-15 15:34:53 +02:00
|
|
|
debug.info("Adding new filter compenent");
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_add_studyitem',
|
2023-09-08 12:47:29 +02:00
|
|
|
args: {
|
2023-07-07 23:17:21 +02:00
|
|
|
"line_id": self.line.id,
|
2024-06-05 22:22:19 +02:00
|
|
|
"slot": self.slotindex,
|
2023-05-17 21:19:14 +02:00
|
|
|
"type": event.data.type,
|
2024-06-05 22:22:19 +02:00
|
|
|
"details": {
|
|
|
|
"badge_id": event.data.badge ? event.data.badge.id : undefined,
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].then((response) => {
|
2023-05-17 21:19:14 +02:00
|
|
|
let item = response;
|
2024-06-05 22:22:19 +02:00
|
|
|
self.relocateStudyItem(item).then(() => {
|
2023-08-15 15:34:53 +02:00
|
|
|
item.layer = this.layer;
|
2023-07-15 22:00:17 +02:00
|
|
|
self.value.push(item);
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("input", self.value);
|
|
|
|
return;
|
|
|
|
}).catch(notification.exception);
|
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-09-08 12:47:29 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
onCut(event) {
|
2024-06-05 22:22:19 +02:00
|
|
|
const self = this;
|
2023-05-17 21:19:14 +02:00
|
|
|
let id = event.data.id;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let i = 0; i < self.value.length; i++) {
|
|
|
|
if (self.value[i].id == id) {
|
2023-09-08 12:47:29 +02:00
|
|
|
self.value.splice(i, 1); i--;
|
2024-06-05 22:22:19 +02:00
|
|
|
break; // Just remove one
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
}
|
2023-07-15 22:00:17 +02:00
|
|
|
// Do something to signal that this item has been removed
|
2024-06-05 22:22:19 +02:00
|
|
|
this.$emit("input", this.value);
|
2023-12-02 23:22:00 +01:00
|
|
|
ItemEventBus.$emit('coursechange');
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
relocateStudyItem(item) {
|
2023-07-15 22:00:17 +02:00
|
|
|
const iteminfo = {'id': item.id, 'layer': this.layer, 'slot': this.slotindex, 'line_id': this.line.id};
|
2023-05-17 21:19:14 +02:00
|
|
|
return call([{
|
|
|
|
methodname: 'local_treestudyplan_reorder_studyitems',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {'items': [iteminfo]} // Function was designed to relocate multiple items at once, hence the array
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
onDragEnter(event) {
|
2023-07-15 22:00:17 +02:00
|
|
|
this.hover.component = event.data;
|
|
|
|
this.hover.type = event.type;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
onDragLeave() {
|
2023-07-15 22:00:17 +02:00
|
|
|
this.hover.component = null;
|
|
|
|
this.hover.type = null;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
maxSpan() {
|
2023-08-04 11:54:16 +02:00
|
|
|
// Determine the maximum span for components in this slot
|
2024-01-26 23:43:02 +01:00
|
|
|
return this.page.periods - this.slotindex + 1;
|
2023-08-04 11:54:16 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
makeType(item) {
|
2023-08-04 11:54:16 +02:00
|
|
|
return {
|
|
|
|
item: true,
|
|
|
|
component: false,
|
|
|
|
span: item.span,
|
|
|
|
type: this.type,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
checkType(type) {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (type.type == this.type) {
|
|
|
|
if (settings("hivizdropslots") && !type.item) {
|
2023-08-04 11:54:16 +02:00
|
|
|
return false;
|
2024-05-27 22:11:32 +02:00
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (type == 'filter') {
|
2024-05-27 22:11:32 +02:00
|
|
|
return true;
|
2024-06-05 22:22:19 +02:00
|
|
|
} else if (type.span <= this.maxSpan()) {
|
2024-05-27 22:11:32 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2023-08-04 11:54:16 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2023-07-30 04:08:57 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
template: `
|
2024-01-27 16:21:04 +01:00
|
|
|
<div :class="'t-studyline-slot '+type + ' t-studyline-slot-'+slotindex + ' ' + ((slotindex==0)?' t-studyline-firstcolumn ':' ')"
|
2023-07-28 00:04:24 +02:00
|
|
|
:data-studyline="line.id" ref="main"
|
2023-08-04 11:54:16 +02:00
|
|
|
:style='spanCss'
|
2023-07-15 22:00:17 +02:00
|
|
|
><drag v-if="item"
|
2023-09-08 12:47:29 +02:00
|
|
|
:key="item.id"
|
|
|
|
class="t-slot-item"
|
|
|
|
:data="item"
|
|
|
|
:type="makeType(item)"
|
2023-07-15 22:00:17 +02:00
|
|
|
@cut="onCut"
|
2023-09-08 12:47:29 +02:00
|
|
|
><t-item
|
2023-09-02 23:25:21 +02:00
|
|
|
@deleted="onCut"
|
|
|
|
v-model="value[itemidx]"
|
|
|
|
:plan="plan"
|
|
|
|
:line='line'
|
|
|
|
:page='page'
|
|
|
|
:period='period'
|
|
|
|
:maxspan='maxSpan()'
|
|
|
|
></t-item
|
|
|
|
></drag
|
2023-07-15 22:00:17 +02:00
|
|
|
><drop v-else
|
2024-04-21 23:08:03 +02:00
|
|
|
:class="'t-slot-drop '+type + (layer > 0?' secondary':' primary') + (hivizdrop()?' hiviz':'')"
|
2023-08-04 11:54:16 +02:00
|
|
|
:accepts-type="checkType"
|
2023-07-15 22:00:17 +02:00
|
|
|
@drop="onDrop"
|
2023-05-17 21:19:14 +02:00
|
|
|
mode="cut"
|
2023-07-15 22:00:17 +02:00
|
|
|
@dragenter="onDragEnter"
|
|
|
|
@dragleave="onDragLeave"
|
|
|
|
><template v-if="hover.component">
|
2023-09-08 12:47:29 +02:00
|
|
|
<div v-if="hover.type.item"
|
|
|
|
class="t-slot-item feedback"
|
2023-07-15 22:00:17 +02:00
|
|
|
:key="hover.component.id"
|
|
|
|
><t-item v-model="hover.component" dummy></t-item
|
|
|
|
></div
|
2023-09-08 12:47:29 +02:00
|
|
|
><div v-else-if="hover.type.type == 'gradable'"
|
|
|
|
class="t-slot-item feedback"
|
2023-07-15 22:00:17 +02:00
|
|
|
:key="'course-'+hover.component.id"
|
|
|
|
><t-item-course v-model="courseHoverDummy"></t-item-course></div
|
2023-09-08 12:47:29 +02:00
|
|
|
><div v-else-if="hover.type.type == 'filter'"
|
|
|
|
class="t-slot-item feedback"
|
2023-07-15 22:00:17 +02:00
|
|
|
key="tooldrop"
|
|
|
|
><t-item-junction v-if="hover.component.type == 'junction'" ></t-item-junction
|
|
|
|
><t-item-start v-else-if="hover.component.type == 'start'" ></t-item-start
|
|
|
|
><t-item-finish v-else-if="hover.component.type == 'finish'" ></t-item-finish
|
|
|
|
><t-item-badge v-else-if="hover.component.type == 'badge'" ></t-item-badge
|
|
|
|
></div
|
2023-09-08 12:47:29 +02:00
|
|
|
><div v-else
|
2023-05-17 21:19:14 +02:00
|
|
|
class="t-slot-item feedback"
|
2023-07-15 22:00:17 +02:00
|
|
|
:key="hover.type">--{{ hover.type }}--</div
|
|
|
|
></template
|
2024-05-27 22:11:32 +02:00
|
|
|
><span v-else-if="hivizdrop()">{{plantext.drophere}}</span></drop>
|
2023-08-06 23:17:36 +02:00
|
|
|
<t-item-timing-checker hidden
|
2023-08-07 20:27:36 +02:00
|
|
|
v-if="value && value[itemidx] && value[itemidx].course"
|
2023-08-06 23:17:36 +02:00
|
|
|
ref="timingChecker"
|
|
|
|
:maxspan="maxSpan()"
|
|
|
|
:page="page"
|
2024-01-26 23:43:02 +01:00
|
|
|
:line="line"
|
2023-08-06 23:17:36 +02:00
|
|
|
:period="period"
|
2023-08-07 20:27:36 +02:00
|
|
|
v-model="value[itemidx]"
|
2023-08-06 23:17:36 +02:00
|
|
|
></t-item-timing-checker>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Vue.component('t-item-timing-checker', {
|
|
|
|
props: {
|
|
|
|
value: {
|
2024-06-05 22:22:19 +02:00
|
|
|
type: Object, // T-item model
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
|
|
|
page: {
|
2024-01-26 23:43:02 +01:00
|
|
|
type: Object, // Studyplanpage
|
|
|
|
},
|
|
|
|
line: {
|
|
|
|
type: Object, // Studyline
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
|
|
|
period: {
|
|
|
|
type: Object, // Studyplan data
|
|
|
|
},
|
|
|
|
maxspan: {
|
|
|
|
type: Number,
|
|
|
|
},
|
|
|
|
hidden: {
|
|
|
|
type: Boolean,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': false,
|
2023-08-06 23:17:36 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
endperiod() {
|
2024-06-05 22:22:19 +02:00
|
|
|
const endperiodnr = Math.min(this.page.periods, this.period.period + (this.value.span - 1));
|
|
|
|
return this.page.perioddesc[endperiodnr - 1];
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
coursePeriodMatches() {
|
|
|
|
const self = this;
|
2024-03-10 23:09:33 +01:00
|
|
|
if (self.page.timeless) {
|
|
|
|
// Always return true in timeless mode.
|
2024-06-05 22:22:19 +02:00
|
|
|
return true;
|
2024-03-10 23:09:33 +01:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
if (self.value && self.value.type == 'course') {
|
|
|
|
self.datechanger.coursespan = datespaninfo(self.value.course.startdate, self.value.course.enddate);
|
|
|
|
self.datechanger.periodspan = datespaninfo(self.period.startdate, self.endperiod.enddate);
|
|
|
|
if (self.datechanger.coursespan.first.getTime() == self.datechanger.periodspan.first.getTime()
|
|
|
|
&& self.datechanger.coursespan.last.getTime() == self.datechanger.periodspan.last.getTime()) {
|
2023-08-06 23:17:36 +02:00
|
|
|
return true;
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2023-08-06 23:17:36 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
2024-06-05 22:22:19 +02:00
|
|
|
debug.warn("Timing thing not properly configured", self.value, self.period, self.maxspan);
|
2023-08-06 23:17:36 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
// Create random id to avoid opening the wrong modals
|
|
|
|
id: Math.floor(Math.random() * Date.now()).toString(16),
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.courseTiming,
|
2023-08-06 23:17:36 +02:00
|
|
|
datechanger: {
|
|
|
|
coursespan: null,
|
|
|
|
periodspan: null,
|
2024-06-05 22:22:19 +02:00
|
|
|
globals: {
|
|
|
|
'default': false,
|
|
|
|
defaultchoice: false,
|
|
|
|
hidewarn: false,
|
|
|
|
},
|
2023-08-06 23:17:36 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
validateCoursePeriod() {
|
2023-08-06 23:17:36 +02:00
|
|
|
const self = this;
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (!self.page.timeless) {
|
2024-03-10 23:09:33 +01:00
|
|
|
debug.info("Validating course and period");
|
2024-06-05 22:22:19 +02:00
|
|
|
if (!(self.coursePeriodMatches)) {
|
2024-03-10 23:09:33 +01:00
|
|
|
debug.info("Course timing does not match period timing");
|
2023-08-06 23:17:36 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (self.value.course.canupdatecourse) {
|
|
|
|
if (!self.hidden || !self.datechanger.globals.default) {
|
2024-03-10 23:09:33 +01:00
|
|
|
// Periods do not match, pop up the date change request
|
2024-06-05 22:22:19 +02:00
|
|
|
this.$bvModal.show('t-course-timing-matching-' + this.id);
|
|
|
|
} else if (self.datechanger.globals.defaultvalue) {
|
|
|
|
// G for it without asking
|
|
|
|
self.changeCoursePeriod();
|
2024-03-10 23:09:33 +01:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
|
|
|
// User is not able to change course timing - show a warning
|
|
|
|
if (!self.hidden || !self.datechanger.globals.hidewarn) {
|
|
|
|
this.$bvModal.show('t-course-timing-warning-' + this.id);
|
2024-03-10 23:09:33 +01:00
|
|
|
}
|
2023-08-06 23:17:36 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
|
|
|
debug.info("Course timing matches period", self.datechanger);
|
2023-08-06 23:17:36 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
|
|
|
debug.info("Skipping course timing check because of timeless mode", self.datechanger);
|
2023-08-06 23:17:36 +02:00
|
|
|
}
|
2024-01-26 23:43:02 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
changeCoursePeriod() {
|
|
|
|
const self = this;
|
2023-08-06 23:17:36 +02:00
|
|
|
// Save the state
|
2024-06-05 22:22:19 +02:00
|
|
|
if (self.datechanger.globals.default) {
|
2023-08-06 23:17:36 +02:00
|
|
|
self.datechanger.globals.defaultvalue = true;
|
|
|
|
}
|
|
|
|
return call([{
|
|
|
|
methodname: 'local_treestudyplan_course_period_timing',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'period_id': self.period.id,
|
|
|
|
'course_id': this.value.course.id,
|
2023-08-06 23:17:36 +02:00
|
|
|
span: this.value.span,
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].catch(notification.exception).then((response) => {
|
2023-08-06 23:17:36 +02:00
|
|
|
self.value.course.startdate = response.startdate;
|
|
|
|
self.value.course.enddate = response.enddate;
|
|
|
|
self.value.course.timing = response.timing;
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit("input", self.value);
|
|
|
|
return;
|
2023-08-06 23:17:36 +02:00
|
|
|
});
|
|
|
|
},
|
2024-01-26 23:43:02 +01:00
|
|
|
checkFilterSlotBusy(slotindex) {
|
2024-06-05 22:22:19 +02:00
|
|
|
debug.info("checking filter", this.line.slots, slotindex, this.value.layer);
|
2024-01-26 23:43:02 +01:00
|
|
|
if (this.line.slots[slotindex]) {
|
|
|
|
const list = this.line.slots[slotindex].filters;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const ix in list) {
|
|
|
|
if (list[ix].layer == this.value.layer) {
|
|
|
|
debug.info("Busy:", list[ix]);
|
2024-01-26 23:43:02 +01:00
|
|
|
return list[ix];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
nextFreeFilterLayer(slotindex) {
|
|
|
|
const layer = this.value.layer;
|
|
|
|
const list = this.line.slots[slotindex].filters;
|
|
|
|
const usedLayers = [];
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const ix in list) {
|
2024-01-26 23:43:02 +01:00
|
|
|
usedLayers.push(list[ix].layer);
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
let nextlyr = layer + 1;
|
2024-01-26 23:43:02 +01:00
|
|
|
while (usedLayers.includes(nextlyr)) {
|
|
|
|
nextlyr++;
|
|
|
|
}
|
|
|
|
return nextlyr;
|
|
|
|
},
|
|
|
|
checkCourseSlotBusy(slotindex) {
|
2024-06-05 22:22:19 +02:00
|
|
|
debug.info("checking ", this.line.slots, slotindex, this.value.layer);
|
2024-01-26 23:43:02 +01:00
|
|
|
if (this.line.slots[slotindex]) {
|
|
|
|
const list = this.line.slots[slotindex].courses;
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const ix in list) {
|
|
|
|
if (list[ix].layer == this.value.layer) {
|
|
|
|
debug.info("Busy:", list[ix]);
|
2024-01-26 23:43:02 +01:00
|
|
|
return list[ix];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
nextFreeCourseLayer(slotindex) {
|
|
|
|
const layer = this.value.layer;
|
|
|
|
const list = this.line.slots[slotindex].courses;
|
|
|
|
const usedLayers = [];
|
2024-06-05 22:22:19 +02:00
|
|
|
for (const ix in list) {
|
2024-01-26 23:43:02 +01:00
|
|
|
usedLayers.push(list[ix].layer);
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
let nextlyr = layer + 1;
|
2024-01-26 23:43:02 +01:00
|
|
|
while (usedLayers.includes(nextlyr)) {
|
|
|
|
nextlyr++;
|
|
|
|
}
|
|
|
|
return nextlyr;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
shiftCollisions(span) {
|
2024-01-26 23:43:02 +01:00
|
|
|
// Check all periods for collision
|
|
|
|
const items = [];
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let i = this.value.slot; i < this.value.slot + span; i++) {
|
2024-01-26 23:43:02 +01:00
|
|
|
const busyFilter = this.checkFilterSlotBusy(i);
|
|
|
|
if (busyFilter) {
|
|
|
|
const nextlyr = this.nextFreeFilterLayer(i);
|
|
|
|
items.push({
|
|
|
|
id: busyFilter.id,
|
|
|
|
layer: nextlyr,
|
2024-06-05 22:22:19 +02:00
|
|
|
'line_id': this.line.id,
|
2024-01-26 23:43:02 +01:00
|
|
|
slot: busyFilter.slot,
|
|
|
|
});
|
|
|
|
busyFilter.layer = nextlyr;
|
|
|
|
}
|
|
|
|
const busyCourse = this.checkCourseSlotBusy(i);
|
|
|
|
if (busyCourse && busyCourse.id != this.value.id) {
|
|
|
|
const nextlyr = this.nextFreeCourseLayer(i);
|
2024-06-05 23:27:00 +02:00
|
|
|
items.push({
|
2024-01-26 23:43:02 +01:00
|
|
|
id: busyCourse.id,
|
|
|
|
layer: nextlyr,
|
2024-06-05 22:22:19 +02:00
|
|
|
'line_id': this.line.id,
|
2024-01-26 23:43:02 +01:00
|
|
|
slot: busyCourse.slot,
|
|
|
|
});
|
|
|
|
busyCourse.layer = nextlyr;
|
|
|
|
}
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
if (items.length > 0) {
|
2024-01-26 23:43:02 +01:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_reorder_studyitems',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {items: items}
|
|
|
|
}])[0].catch(notification.exception);
|
2024-01-26 23:43:02 +01:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
changeSpan(span) {
|
|
|
|
const self = this;
|
|
|
|
this.shiftCollisions(span);
|
2023-08-06 23:17:36 +02:00
|
|
|
return call([{
|
|
|
|
methodname: 'local_treestudyplan_set_studyitem_span',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
id: self.value.id,
|
2023-08-06 23:17:36 +02:00
|
|
|
span: span
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
}])[0].catch(notification.exception).then((response) => {
|
2023-08-06 23:17:36 +02:00
|
|
|
self.value.span = response.span;
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$emit('input', self.value);
|
2023-08-06 23:17:36 +02:00
|
|
|
self.$nextTick(() => {
|
2024-06-05 22:22:19 +02:00
|
|
|
self.validateCoursePeriod();
|
2023-08-06 23:17:36 +02:00
|
|
|
});
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
|
|
|
});
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
formatDuration(dsi) {
|
2023-08-06 23:17:36 +02:00
|
|
|
let s = "";
|
2024-06-05 22:22:19 +02:00
|
|
|
if (dsi.years == 1) {
|
|
|
|
s += `1 ${this.text.year}, `;
|
|
|
|
} else if (dsi.years > 1) {
|
|
|
|
s += `${dsi.years} ${this.text.years}, `;
|
|
|
|
}
|
|
|
|
if (dsi.weeks == 1) {
|
|
|
|
s += `1 ${this.text.week}, `;
|
|
|
|
} else if (dsi.weeks > 1) {
|
|
|
|
s += `${dsi.weeks} ${this.text.weeks}, `;
|
|
|
|
}
|
|
|
|
if (dsi.days == 1) {
|
|
|
|
s += `1 ${this.text.day}, `;
|
|
|
|
} else if (dsi.days > 1) {
|
|
|
|
s += `${dsi.days} ${this.text.days}, `;
|
|
|
|
}
|
2023-08-06 23:17:36 +02:00
|
|
|
|
|
|
|
return s.toLocaleLowerCase();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// To avoid the span creeping in the dom where it shouldn't, set display to none if it is hidden
|
|
|
|
// This does not affect the modals, which are rendered outside of this element when needed
|
|
|
|
template: `
|
2023-08-07 11:48:06 +02:00
|
|
|
<div :class="'t-item-timing-checker'" :style="hidden?'display: none ':''">
|
|
|
|
<template v-if="!hidden" >
|
2024-06-05 22:22:19 +02:00
|
|
|
<span class="mr-1" v-if="coursePeriodMatches">
|
2023-08-07 11:48:06 +02:00
|
|
|
<i class="text-success fa fa-calendar-check-o"
|
|
|
|
v-b-tooltip.hover.topright :title="text.timing_ok"
|
|
|
|
></i>
|
|
|
|
</span>
|
|
|
|
<span class="mr-1" v-else>
|
2024-06-05 22:22:19 +02:00
|
|
|
<a href='#' @click.prevent="validateCoursePeriod()" class="text-warning"
|
2023-08-07 11:55:30 +02:00
|
|
|
v-b-tooltip.hover.bottomleft :title="text.timing_off"
|
2023-09-08 12:47:29 +02:00
|
|
|
><i class="fa fa-calendar-times-o"
|
2023-08-07 11:48:06 +02:00
|
|
|
></i
|
|
|
|
><i class="fa fa-question-circle text-black-50"
|
|
|
|
style="font-size: 0.8em; top: -0.3em; position: relative;"
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2023-08-07 11:48:06 +02:00
|
|
|
></i
|
|
|
|
></a>
|
|
|
|
</span>
|
2023-08-07 11:55:30 +02:00
|
|
|
<span class="ml-1" v-b-tooltip.hover.bottomleft :title="text.periodspan_desc"
|
|
|
|
>{{ text.periodspan
|
2024-01-26 23:43:02 +01:00
|
|
|
}} <b-form-select v-if="maxspan > 1"
|
2023-08-07 11:48:06 +02:00
|
|
|
class=""
|
2024-06-05 22:22:19 +02:00
|
|
|
size="sm" @change="changeSpan" v-model="value.span">
|
2023-08-07 17:39:57 +02:00
|
|
|
<b-form-select-option v-for="(n,i) in maxspan" :value='n' :key='i'
|
2023-08-06 23:17:36 +02:00
|
|
|
>{{ n }}</b-form-select-option>
|
2023-08-07 11:48:06 +02:00
|
|
|
</b-form-select
|
2024-01-26 23:43:02 +01:00
|
|
|
><span v-else>{{value.span}}</span> {{
|
2023-09-08 12:47:29 +02:00
|
|
|
(value.span == 1)?text.period.toLowerCase():text.periods.toLowerCase()
|
|
|
|
}}<i
|
|
|
|
class="fa fa-question-circle text-black-50"
|
2023-08-07 11:48:06 +02:00
|
|
|
style="font-size: 0.8em; top: -0.3em; position: relative;"
|
2023-08-07 11:55:30 +02:00
|
|
|
></i>
|
2023-08-06 23:17:36 +02:00
|
|
|
</span>
|
2023-08-07 11:48:06 +02:00
|
|
|
</template>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-modal
|
|
|
|
:id="'t-course-timing-matching-'+this.id"
|
|
|
|
size="lg"
|
2023-07-30 04:08:57 +02:00
|
|
|
:title="text.title"
|
2024-06-05 22:22:19 +02:00
|
|
|
@ok="changeCoursePeriod"
|
2023-07-30 04:08:57 +02:00
|
|
|
:ok-title="text.yes"
|
2023-08-04 12:10:43 +02:00
|
|
|
ok-variant="danger"
|
|
|
|
:cancel-title="text.no"
|
2023-09-08 12:47:29 +02:00
|
|
|
cancel-variant="primary"
|
2023-07-30 04:08:57 +02:00
|
|
|
>
|
2023-08-06 23:17:36 +02:00
|
|
|
<b-container v-if="datechanger.coursespan && datechanger.periodspan && value && value.course">
|
2023-07-30 04:08:57 +02:00
|
|
|
<b-row><b-col cols="12">{{ text.desc }}</b-col></b-row>
|
|
|
|
<b-row><b-col cols="12"><div class="generalbox alert alert-warning">{{ text.question }}</div></b-col></b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="6">
|
|
|
|
<h3> {{ text.course }} </h3>
|
2023-08-07 16:11:14 +02:00
|
|
|
<p class="mb-0"><b>{{ value.course.fullname }}</b></p>
|
|
|
|
<p class="mb-1"><b>{{ value.course.shortname }}</b></p>
|
|
|
|
<p class="mb-1">{{ datechanger.coursespan.formatted.first}} - {{ datechanger.coursespan.formatted.last}}</p>
|
|
|
|
<p class="mb-0"><b>{{ text.duration }}</b><br>
|
2024-06-05 22:22:19 +02:00
|
|
|
{{ formatDuration(datechanger.coursespan)}}</p>
|
2023-07-30 04:08:57 +02:00
|
|
|
</b-col>
|
|
|
|
<b-col cols="6">
|
|
|
|
<h3> {{ text.period }} </h3>
|
2023-08-07 16:11:14 +02:00
|
|
|
<p class="mb-0"><b>{{ period.fullname }}</b><b v-if="value.span > 1"> - {{ endperiod.fullname }}</b></p>
|
|
|
|
<p class="mb-1"><b>{{ period.shortname }}</b><b v-if="value.span > 1"> - {{ endperiod.shortname }}</b></p>
|
|
|
|
<p class="mb-1">{{ datechanger.periodspan.formatted.first}} - {{ datechanger.periodspan.formatted.last}}</p>
|
|
|
|
<p class="mb-0"><b>{{ text.duration }}</b><br>
|
2024-06-05 22:22:19 +02:00
|
|
|
{{ formatDuration(datechanger.periodspan)}}</p>
|
2023-07-30 04:08:57 +02:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2023-08-07 16:11:14 +02:00
|
|
|
<b-row v-if='hidden' class="pt-2"><b-col cols="12">
|
2023-08-06 23:17:36 +02:00
|
|
|
<b-form-checkbox type="checkbox" v-model="datechanger.globals.default">{{ text.rememberchoice }}</b-form-checkbox>
|
2023-07-30 04:08:57 +02:00
|
|
|
</b-col></b-row>
|
|
|
|
</b-container>
|
|
|
|
</b-modal>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-modal
|
|
|
|
:id="'t-course-timing-warning-'+this.id"
|
|
|
|
size="lg"
|
2023-08-04 12:10:43 +02:00
|
|
|
ok-variant="primary"
|
2023-07-30 04:08:57 +02:00
|
|
|
:title="text.title"
|
|
|
|
:ok-title="text.yes"
|
2023-08-04 12:10:43 +02:00
|
|
|
ok-only
|
2023-07-30 04:08:57 +02:00
|
|
|
>
|
2023-08-06 23:17:36 +02:00
|
|
|
<b-container v-if="datechanger.coursespan && datechanger.periodspan && value && value.course">
|
2023-07-30 04:08:57 +02:00
|
|
|
<b-row><b-col cols="12">{{ text.desc }}</b-col></b-row>
|
|
|
|
<b-row><b-col cols="12"><div class="generalbox alert alert-warning">{{ text.warning }}</div></b-col></b-row>
|
|
|
|
<b-row>
|
|
|
|
<b-col cols="6">
|
|
|
|
<h3> {{ text.course }} </h3>
|
2023-08-07 16:11:14 +02:00
|
|
|
<p class="mb-0"><b>{{ value.course.fullname }}</b></p>
|
|
|
|
<p class="mb-1"><b>{{ value.course.shortname }}</b></p>
|
|
|
|
<p class="mb-1">{{ datechanger.coursespan.formatted.first}} - {{ datechanger.coursespan.formatted.last}}</p>
|
|
|
|
<p class="mb-0"><b>{{ text.duration }}</b><br>
|
2024-06-05 22:22:19 +02:00
|
|
|
{{ formatDuration(datechanger.coursespan)}}</p>
|
2023-07-30 04:08:57 +02:00
|
|
|
</b-col>
|
|
|
|
<b-col cols=>"6">
|
|
|
|
<h3> {{ text.period }} </h3>
|
2023-08-07 16:11:14 +02:00
|
|
|
<p class="mb-0"><b>{{ period.fullname }}</b><b v-if="value.span > 1"> - {{ endperiod.fullname }}</b></p>
|
|
|
|
<p class="mb-1"><b>{{ period.shortname }}</b><b v-if="value.span > 1"> - {{ endperiod.shortname }}</b></p>
|
|
|
|
<p class="mb-1">{{ datechanger.periodspan.formatted.first}} - {{ datechanger.periodspan.formatted.last}}</p>
|
|
|
|
<p class="mb-0"><b>{{ text.duration }}</b><br>
|
2024-06-05 22:22:19 +02:00
|
|
|
{{ formatDuration(datechanger.periodspan)}}</p>
|
2023-07-30 04:08:57 +02:00
|
|
|
</b-col>
|
|
|
|
</b-row>
|
2023-08-07 16:11:14 +02:00
|
|
|
<b-row v-if='hidden' class="pt-2"><b-col cols="12">
|
2023-08-06 23:17:36 +02:00
|
|
|
<b-form-checkbox type="checkbox" v-model="datechanger.globals.hidewarn">{{ text.hidewarning }}</b-form-checkbox>
|
2023-07-30 04:08:57 +02:00
|
|
|
</b-col></b-row>
|
|
|
|
</b-container>
|
|
|
|
</b-modal>
|
2023-08-07 16:11:14 +02:00
|
|
|
</div>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Vue.component('t-item', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
dummy: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Boolean,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return false;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2023-08-06 23:17:36 +02:00
|
|
|
plan: {
|
2023-07-26 16:42:34 +02:00
|
|
|
type: Object, // Studyplan page
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2023-09-02 23:25:21 +02:00
|
|
|
line: {
|
|
|
|
type: Object, // Studyplan page
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-09-02 23:25:21 +02:00
|
|
|
},
|
2023-08-06 23:17:36 +02:00
|
|
|
page: {
|
|
|
|
type: Object, // Studyplan page
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
|
|
|
period: {
|
|
|
|
type: Object, // Studyplan page
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
|
|
|
maxspan: {
|
|
|
|
type: Number,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return 0;
|
|
|
|
},
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dragLine: null,
|
|
|
|
dragEventListener: null,
|
|
|
|
deleteMode: false,
|
2024-06-05 22:22:19 +02:00
|
|
|
conditionOptions: stringKeys.conditions,
|
|
|
|
text: strings.itemText,
|
2023-05-17 21:19:14 +02:00
|
|
|
showContext: false,
|
|
|
|
lines: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
dragStart(event) {
|
2023-05-17 21:19:14 +02:00
|
|
|
// Add line between start point and drag image
|
|
|
|
this.deleteMode = false;
|
2024-06-05 22:22:19 +02:00
|
|
|
let start = document.getElementById('studyitem-' + this.value.id);
|
|
|
|
let dragelement = document.getElementById('t-item-cdrag-' + this.value.id);
|
2023-05-17 21:19:14 +02:00
|
|
|
dragelement.style.position = 'fixed';
|
2024-06-05 22:22:19 +02:00
|
|
|
dragelement.style.left = event.position.x + 'px';
|
|
|
|
dragelement.style.top = event.position.y + 'px';
|
|
|
|
this.dragLine = new SimpleLine(start, dragelement, {
|
2023-08-04 22:54:32 +02:00
|
|
|
color: "#777",
|
|
|
|
gravity: {
|
|
|
|
start: LINE_GRAVITY,
|
|
|
|
end: LINE_GRAVITY,
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
});
|
|
|
|
// Add separate event listener to reposition mouse move
|
2024-06-05 22:22:19 +02:00
|
|
|
document.addEventListener("mousemove", this.onMouseMove);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
dragEnd() {
|
|
|
|
if (this.dragLine !== null) {
|
2023-05-17 21:19:14 +02:00
|
|
|
this.dragLine.remove();
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
let dragelement = document.getElementById('t-item-cdrag-' + this.value.id);
|
2023-05-17 21:19:14 +02:00
|
|
|
dragelement.style.removeProperty('left');
|
|
|
|
dragelement.style.removeProperty('top');
|
|
|
|
dragelement.style.removeProperty('position');
|
2024-06-05 22:22:19 +02:00
|
|
|
document.removeEventListener("mousemove", this.onMouseMove);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
onMouseMove: function(event) {
|
|
|
|
let dragelement = document.getElementById('t-item-cdrag-' + this.value.id);
|
2023-05-17 21:19:14 +02:00
|
|
|
dragelement.style.position = 'fixed';
|
2024-06-05 22:22:19 +02:00
|
|
|
dragelement.style.left = event.clientX + 'px';
|
|
|
|
dragelement.style.top = event.clientY + 'px';
|
|
|
|
// Line will follow automatically
|
2023-07-18 13:19:48 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
onDrop(event) {
|
|
|
|
let fromid = event.data.id;
|
|
|
|
let toid = this.value.id;
|
2023-07-17 23:04:21 +02:00
|
|
|
this.redrawLines();
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_connect_studyitems',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {'from_id': fromid, 'to_id': toid}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].then((response)=>{
|
2023-08-06 23:17:36 +02:00
|
|
|
let conn = {'id': response.id, 'from_id': response.from_id, 'to_id': response.to_id};
|
2024-06-05 22:22:19 +02:00
|
|
|
ItemEventBus.$emit("createdConnection", conn);
|
2023-05-17 21:19:14 +02:00
|
|
|
this.value.connections.in.push(conn);
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
redrawLine(conn) {
|
2023-07-17 23:04:21 +02:00
|
|
|
const lineColor = "var(--success)";
|
|
|
|
const start = document.getElementById(`studyitem-${conn.from_id}`);
|
|
|
|
const end = document.getElementById(`studyitem-${conn.to_id}`);
|
2023-05-17 21:19:14 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// Delete old line
|
|
|
|
if (this.lines[conn.to_id]) {
|
2023-09-08 12:47:29 +02:00
|
|
|
this.lines[conn.to_id].remove();
|
2023-07-17 23:04:21 +02:00
|
|
|
delete this.lines[conn.to_id];
|
2023-09-08 12:47:29 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
// Create a new line if the start and finish items are visible
|
|
|
|
if (start !== null && end !== null && isVisible(start) && isVisible(end)) {
|
|
|
|
this.lines[conn.to_id] = new SimpleLine(start, end, {
|
2023-08-04 22:54:32 +02:00
|
|
|
color: lineColor,
|
|
|
|
gravity: {
|
|
|
|
start: LINE_GRAVITY,
|
|
|
|
end: LINE_GRAVITY,
|
|
|
|
},
|
|
|
|
});
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2023-07-17 23:04:21 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
deleteLine(conn) {
|
2023-05-17 21:19:14 +02:00
|
|
|
const self = this;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_disconnect_studyitems',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {'from_id': conn.from_id, 'to_id': conn.to_id}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].then((response)=>{
|
2024-06-05 22:22:19 +02:00
|
|
|
if (response.success) {
|
2023-05-17 21:19:14 +02:00
|
|
|
this.removeLine(conn);
|
2024-06-05 22:22:19 +02:00
|
|
|
// Send disconnect event on message bus, so the connection on the other end can delete it too
|
|
|
|
ItemEventBus.$emit("connectionDisconnected", conn);
|
2023-05-17 21:19:14 +02:00
|
|
|
// Remove connection from our outgoing list
|
|
|
|
let index = self.value.connections.out.indexOf(conn);
|
|
|
|
self.value.connections.out.splice(index, 1);
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
highlight(conn) {
|
|
|
|
if (this.lines[conn.to_id]) {
|
|
|
|
this.lines[conn.to_id].setConfig({color: "var(--danger)"});
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
normalize(conn) {
|
|
|
|
if (this.lines[conn.to_id]) {
|
|
|
|
this.lines[conn.to_id].setConfig({color: "var(--success)"});
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
updateItem() {
|
|
|
|
call([{
|
2024-07-10 09:08:12 +02:00
|
|
|
methodname: 'local_treestudyplan_edit_studyitem',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'id': this.value.id,
|
2023-09-08 12:47:29 +02:00
|
|
|
'conditions': this.value.conditions,
|
2024-06-05 22:22:19 +02:00
|
|
|
'continuation_id': this.value.continuation_id,
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
doShowContext(event) {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.hasContext) {
|
|
|
|
this.showContext = true;
|
2023-05-17 21:19:14 +02:00
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
redrawLines() {
|
|
|
|
if (this.value.connections && this.value.connections.out) {
|
|
|
|
for (let i in this.value.connections.out) {
|
2023-08-15 15:34:53 +02:00
|
|
|
let conn = this.value.connections.out[i];
|
|
|
|
this.redrawLine(conn);
|
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// EVENT LISTENERS
|
2024-06-05 22:22:19 +02:00
|
|
|
onCreatedConnection(conn) {
|
|
|
|
if (conn.from_id == this.value.id) {
|
2023-05-17 21:19:14 +02:00
|
|
|
this.value.connections.out.push(conn);
|
|
|
|
this.redrawLine(conn);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Listener for the signal that a connection was removed by the outgoing item
|
2024-06-05 22:22:19 +02:00
|
|
|
onRemovedConnection(conn) {
|
|
|
|
if (this.value.connections && this.value.connections.out) {
|
|
|
|
for (let i in this.value.connections.in) {
|
|
|
|
let cin = this.value.connections.in[i];
|
|
|
|
if (conn.id == cin.id) {
|
2023-08-15 15:34:53 +02:00
|
|
|
self.value.connections.out.splice(i, 1);
|
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Listener for reposition events
|
|
|
|
// When an item in the list is repositioned, all lines need to be redrawn
|
2024-06-05 22:22:19 +02:00
|
|
|
onRePositioned() {
|
2023-11-11 20:17:45 +01:00
|
|
|
this.redrawLines();
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
// When an item is disPositioned - (temporarily) removed from the list,
|
|
|
|
// all connections need to be deleted.
|
2024-06-05 22:22:19 +02:00
|
|
|
onDisPositioned(reid) {
|
|
|
|
if (this.value.connections && this.value.connections.out) {
|
|
|
|
for (let i in this.value.connections.out) {
|
2023-08-15 15:34:53 +02:00
|
|
|
let conn = this.value.connections.out[i];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (conn.to_id == reid) {
|
2023-08-15 15:34:53 +02:00
|
|
|
this.removeLine(conn);
|
2023-09-08 12:47:29 +02:00
|
|
|
}
|
2023-08-15 15:34:53 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-09-08 12:47:29 +02:00
|
|
|
// When an item is deleted
|
2023-05-17 21:19:14 +02:00
|
|
|
// all connections to/from that item need to be cleaned up
|
2024-06-05 22:22:19 +02:00
|
|
|
onItemDeleted(itemid) {
|
2023-05-17 21:19:14 +02:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.value.connections && this.value.connections.out) {
|
|
|
|
for (const i in this.value.connections.out) {
|
2023-08-15 15:34:53 +02:00
|
|
|
let conn = this.value.connections.out[i];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (conn.to_id == itemid) {
|
2023-08-15 15:34:53 +02:00
|
|
|
self.removeLine(conn);
|
|
|
|
self.value.connections.out.splice(i, 1);
|
2023-09-08 12:47:29 +02:00
|
|
|
}
|
2023-08-15 15:34:53 +02:00
|
|
|
}
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.value.connections && this.value.connections.in) {
|
|
|
|
for (const i in this.value.connections.in) {
|
2023-08-15 15:34:53 +02:00
|
|
|
let conn = this.value.connections.in[i];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (conn.from_id == itemid) {
|
2023-08-15 15:34:53 +02:00
|
|
|
self.value.connections.out.splice(i, 1);
|
2023-09-08 12:47:29 +02:00
|
|
|
}
|
2023-08-15 15:34:53 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
onRedrawLines() {
|
2023-05-17 21:19:14 +02:00
|
|
|
this.redrawLines();
|
|
|
|
},
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
removeLine(conn) {
|
|
|
|
if (this.lines[conn.to_id]) {
|
2023-07-17 23:04:21 +02:00
|
|
|
this.lines[conn.to_id].remove();
|
|
|
|
delete this.lines[conn.to_id];
|
2023-09-08 12:47:29 +02:00
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
deleteItem() {
|
2023-09-02 23:25:21 +02:00
|
|
|
const self = this;
|
|
|
|
const msgparams = {
|
|
|
|
item: this.text['type_' + this.value.type].toLocaleLowerCase(),
|
2024-06-05 22:22:19 +02:00
|
|
|
name: (this.value.type == 'course') ? this.value.course.displayname : "",
|
2023-09-02 23:25:21 +02:00
|
|
|
line: (this.line) ? this.line.name : "",
|
|
|
|
period: (this.period) ? this.period.fullname : this.plan.name,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$bvModal.msgBoxConfirm(strformat(this.text.item_delete_message, msgparams), {
|
2024-06-05 22:22:19 +02:00
|
|
|
okVariant: 'danger',
|
|
|
|
okTitle: this.text.ok,
|
2023-09-02 23:25:21 +02:00
|
|
|
cancelTitle: this.text.cancel,
|
|
|
|
}).then(value => {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (value) {
|
2023-09-02 23:25:21 +02:00
|
|
|
// Confirmed to delete.
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_delete_studyitem',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'id': self.value.id,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
|
|
|
if (response.success == true) {
|
|
|
|
self.$emit("deleted", {data: self.value});
|
2023-09-02 23:25:21 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-09-02 23:25:21 +02:00
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-09-02 23:25:21 +02:00
|
|
|
}).catch(err => {
|
|
|
|
debug.console.error(err);
|
|
|
|
});
|
|
|
|
}
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
hasConnectionsOut() {
|
2024-06-05 22:22:19 +02:00
|
|
|
return !(["finish"].includes(this.value.type));
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
hasConnectionsIn() {
|
2024-06-05 22:22:19 +02:00
|
|
|
return !(["start"].includes(this.value.type));
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
hasContext() {
|
2024-06-05 22:22:19 +02:00
|
|
|
return ['start', 'junction', 'finish'].includes(this.value.type);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
created() {
|
2023-05-17 21:19:14 +02:00
|
|
|
// Add event listeners on the message bus
|
|
|
|
// But only if not in "dummy" mode - mode which is used for droplist placeholders
|
|
|
|
// Since an item is "fully made" with all references, not specifying dummy mode really messes things up
|
2024-06-05 22:22:19 +02:00
|
|
|
if (!this.dummy) {
|
2023-05-17 21:19:14 +02:00
|
|
|
// Listener for the signal that a new connection was made and needs to be drawn
|
|
|
|
// Sent by the incoming item - By convention, outgoing items are responsible for drawing the lines
|
|
|
|
ItemEventBus.$on('createdConnection', this.onCreatedConnection);
|
|
|
|
// Listener for the signal that a connection was removed by the outgoing item
|
|
|
|
ItemEventBus.$on('removedConnection', this.onRemovedConnection);
|
|
|
|
// Listener for reposition events
|
|
|
|
// When an item in the list is repositioned, all lines need to be redrawn
|
|
|
|
ItemEventBus.$on('rePositioned', this.onRePositioned);
|
|
|
|
// When an item is disPositioned - (temporarily) removed from the list,
|
|
|
|
// all connections need to be deleted.
|
|
|
|
ItemEventBus.$on('disPositioned', this.onDisPositioned);
|
2023-09-08 12:47:29 +02:00
|
|
|
// When an item is deleted
|
2023-05-17 21:19:14 +02:00
|
|
|
// all connections to/from that item need to be cleaned up
|
|
|
|
ItemEventBus.$on('itemDeleted', this.onItemDeleted);
|
|
|
|
ItemEventBus.$on('redrawLines', this.onRedrawLines);
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
mounted() {
|
2023-05-17 21:19:14 +02:00
|
|
|
// Initialize connection lines when mounting
|
|
|
|
// But only if not in "dummy" mode - mode which is used for droplist placeholders
|
|
|
|
// Since an item is "fully made" with all references, not specifying dummy mode really messes things up
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
if (!this.dummy) {
|
2023-05-17 21:19:14 +02:00
|
|
|
this.redrawLines();
|
|
|
|
setTimeout(()=>{
|
2024-06-05 22:22:19 +02:00
|
|
|
ItemEventBus.$emit("rePositioned", this.value.id);
|
|
|
|
}, 10);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
beforeDestroy() {
|
|
|
|
if (!this.dummy) {
|
|
|
|
for (let i in this.value.connections.out) {
|
2023-05-17 21:19:14 +02:00
|
|
|
let conn = this.value.connections.out[i];
|
|
|
|
this.removeLine(conn);
|
|
|
|
}
|
2024-06-05 22:22:19 +02:00
|
|
|
ItemEventBus.$emit("disPositioned", this.value.id);
|
2023-05-17 21:19:14 +02:00
|
|
|
|
|
|
|
// Remove event listeners
|
|
|
|
ItemEventBus.$off('createdConnection', this.onCreatedConnection);
|
|
|
|
ItemEventBus.$off('removedConnection', this.onRemovedConnection);
|
|
|
|
ItemEventBus.$off('rePositioned', this.onRePositioned);
|
|
|
|
ItemEventBus.$off('disPositioned', this.onDisPositioned);
|
|
|
|
ItemEventBus.$off('itemDeleted', this.onItemDeleted);
|
|
|
|
ItemEventBus.$off('redrawLines', this.onRedrawLines);
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
updated() {
|
|
|
|
if (!this.dummy) {
|
2023-05-17 21:19:14 +02:00
|
|
|
this.redrawLines();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<div class="t-item-base" :id="'studyitem-'+value.id">
|
2023-09-08 12:47:29 +02:00
|
|
|
<t-item-course
|
2023-09-02 23:25:21 +02:00
|
|
|
v-if="value.type == 'course'"
|
|
|
|
@deleterq="deleteItem"
|
|
|
|
v-model="value"
|
|
|
|
:plan='plan'
|
2024-01-26 23:43:02 +01:00
|
|
|
:line='line'
|
2023-09-02 23:25:21 +02:00
|
|
|
:page='page'
|
|
|
|
:period='period'
|
|
|
|
:maxspan='maxspan'
|
|
|
|
></t-item-course>
|
|
|
|
<t-item-junction
|
|
|
|
v-if="value.type == 'junction'"
|
|
|
|
@deleterq="deleteItem"
|
|
|
|
v-model="value"
|
|
|
|
></t-item-junction>
|
|
|
|
<t-item-start
|
|
|
|
v-if="value.type == 'start'"
|
|
|
|
@deleterq="deleteItem"
|
|
|
|
v-model="value"
|
|
|
|
></t-item-start>
|
|
|
|
<t-item-finish
|
|
|
|
v-if="value.type == 'finish'"
|
|
|
|
@deleterq="deleteItem"
|
|
|
|
v-model="value"
|
|
|
|
></t-item-finish>
|
|
|
|
<t-item-badge
|
|
|
|
v-if="value.type == 'badge'"
|
|
|
|
@deleterq="deleteItem"
|
|
|
|
v-model="value"
|
|
|
|
></t-item-badge>
|
|
|
|
<t-item-invalid
|
|
|
|
v-if="value.type == 'invalid'"
|
|
|
|
@deleterq="deleteItem"
|
|
|
|
v-model="value"
|
|
|
|
></t-item-invalid>
|
2023-05-17 21:19:14 +02:00
|
|
|
<drop v-if='!dummy && hasConnectionsIn' accepts-type="linestart"
|
|
|
|
:id="'t-item-cend-'+value.id"
|
|
|
|
class="t-item-connector-end"
|
|
|
|
mode="copy"
|
|
|
|
@drop="onDrop"
|
|
|
|
><svg width='5px' height='10px'><rect ry="1px" rx="1px" y="0px" x="0px" height="10px" width="5px"/></svg></drop>
|
|
|
|
<drag v-if='!dummy && hasConnectionsOut' type="linestart"
|
|
|
|
:id="'t-item-cstart-'+value.id"
|
|
|
|
:class="'t-item-connector-start ' + ((deleteMode&&value.connections.out.length)?'deleteMode':'')"
|
|
|
|
:data="value"
|
|
|
|
@dragstart="dragStart"
|
|
|
|
@dragend="dragEnd"
|
2024-03-04 22:39:29 +01:00
|
|
|
@click.prevent="deleteMode = (value.connections.out.length)?(!deleteMode):false"
|
2023-05-17 21:19:14 +02:00
|
|
|
>
|
|
|
|
<svg width='5px' height='10px'><rect ry="1px" rx="1px" y="0px" x="0px" height="10px" width="5px"/></svg>
|
|
|
|
<template v-slot:drag-image="{data}"> <i :id="'t-item-cdrag-'+value.id" class="fa"></i>
|
|
|
|
</template>
|
|
|
|
</drag>
|
|
|
|
<div class="deletebox" v-if="deleteMode && value.connections.out.length > 0"
|
|
|
|
>
|
|
|
|
<a v-for="conn in value.connections.out"
|
2024-03-04 22:39:29 +01:00
|
|
|
@click.prevent="deleteLine(conn)"
|
2023-05-17 21:19:14 +02:00
|
|
|
@mouseenter="highlight(conn)"
|
|
|
|
@mouseleave="normalize(conn)"
|
|
|
|
class="t-connection-delete text-danger"
|
|
|
|
:title="conn.id">
|
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<a v-if="hasContext" class="t-item-config"
|
|
|
|
v-b-modal="'t-item-config-'+value.id" href="#" @click.prevent=""><i class="fa fa-gear"></i></a>
|
2023-09-02 23:25:21 +02:00
|
|
|
<b-modal no-body class=""
|
2023-05-17 21:19:14 +02:00
|
|
|
:id="'t-item-config-'+value.id"
|
|
|
|
:title="text['item_configuration']"
|
|
|
|
scrollable
|
|
|
|
ok-only
|
2023-09-02 23:25:21 +02:00
|
|
|
class="t-item-contextview b-modal-justify-footer-between"
|
2023-05-17 21:19:14 +02:00
|
|
|
>
|
|
|
|
<b-form-group
|
2023-09-02 23:25:21 +02:00
|
|
|
v-if="value.type != 'start'"
|
2023-05-17 21:19:14 +02:00
|
|
|
:label="text.select_conditions"
|
|
|
|
>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-form-select size="sm"
|
|
|
|
@input="updateItem"
|
|
|
|
v-model="value.conditions"
|
2024-06-05 22:22:19 +02:00
|
|
|
:options="conditionOptions"
|
2023-05-17 21:19:14 +02:00
|
|
|
></b-form-select>
|
|
|
|
</b-form-group>
|
2023-09-02 23:25:21 +02:00
|
|
|
|
|
|
|
<template #modal-footer="{ ok, cancel, hide }" >
|
2024-03-04 22:39:29 +01:00
|
|
|
<a href='#' @click.prevent='deleteItem()' class="text-danger"
|
2023-09-02 23:25:21 +02:00
|
|
|
><i class="fa fa-trash"></i>
|
|
|
|
{{ text.delete }}
|
|
|
|
</a>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-button size="sm" variant="primary" @click.prevent="ok()">
|
2023-09-02 23:25:21 +02:00
|
|
|
{{ text.ok }}
|
|
|
|
</b-button>
|
|
|
|
</template>
|
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
</b-modal>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
Vue.component('t-item-invalid', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'value': {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
text: strings.invalid,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
},
|
|
|
|
template: `
|
2023-08-22 16:47:37 +02:00
|
|
|
<div class="t-item-invalid">
|
|
|
|
<b-card no-body >
|
2023-05-17 21:19:14 +02:00
|
|
|
<b-row no-gutters>
|
|
|
|
<b-col md="1">
|
|
|
|
<span class="t-timing-indicator timing-invalid"></span>
|
|
|
|
</b-col>
|
|
|
|
<b-col md="11">
|
|
|
|
<b-card-body class="align-items-center">
|
|
|
|
<i class="fa fa-exclamation"></i> {{text.error}}
|
2024-03-04 22:39:29 +01:00
|
|
|
<a href='#' @click.prevent='$emit("deleterq")' class="text-danger"
|
2023-09-02 23:25:21 +02:00
|
|
|
><i class="fa fa-trash"></i></a>
|
2023-05-17 21:19:14 +02:00
|
|
|
</b-card-body>
|
|
|
|
</b-col>
|
|
|
|
</b-row>
|
|
|
|
</b-card>
|
2023-08-22 16:47:37 +02:00
|
|
|
</div>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// TAG: Course item
|
2023-05-17 21:19:14 +02:00
|
|
|
Vue.component('t-item-course', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
plan: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
line: {
|
2024-01-26 23:43:02 +01:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2024-01-26 23:43:02 +01:00
|
|
|
},
|
2023-08-06 23:17:36 +02:00
|
|
|
page: {
|
|
|
|
type: Object, // PAge data
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
}
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
|
|
|
period: {
|
|
|
|
type: Object, // Period data
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
}
|
2023-08-06 23:17:36 +02:00
|
|
|
},
|
|
|
|
maxspan: {
|
|
|
|
type: Number,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return 0;
|
|
|
|
}
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 22:22:19 +02:00
|
|
|
conditionOptions: stringKeys.conditions,
|
|
|
|
text: strings.itemCourseText,
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
useItemConditions() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.plan && this.plan.aggregation_info && this.plan.aggregation_info.useItemConditions !== undefined) {
|
2023-05-17 21:19:14 +02:00
|
|
|
return this.plan.aggregation_info.useItemConditions;
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2023-05-17 21:19:14 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2023-06-16 23:12:17 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
configurationState() {
|
|
|
|
if (this.hasGrades() || this.hasCompletions() || this.hasCompetencies()) {
|
2023-06-16 23:12:17 +02:00
|
|
|
return "t-configured-ok";
|
|
|
|
} else {
|
|
|
|
return "t-configured-alert";
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
configurationIcon() {
|
|
|
|
if (this.hasGrades() || this.hasCompletions() || this.hasCompetencies()) {
|
2023-06-16 23:12:17 +02:00
|
|
|
return "check";
|
|
|
|
} else {
|
|
|
|
return "exclamation-circle";
|
|
|
|
}
|
2023-07-28 23:43:11 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
startdate() {
|
2024-06-03 23:24:16 +02:00
|
|
|
return formatDate(this.value.course.startdate);
|
2023-07-28 23:43:11 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
enddate() {
|
|
|
|
if (this.value.course.enddate > 0) {
|
2024-06-03 23:24:16 +02:00
|
|
|
return formatDate(this.value.course.enddate);
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2023-07-28 23:43:11 +02:00
|
|
|
return this.text.noenddate;
|
|
|
|
}
|
2024-02-07 22:33:16 +01:00
|
|
|
},
|
|
|
|
wwwroot() {
|
|
|
|
return Config.wwwroot;
|
2023-06-16 23:12:17 +02:00
|
|
|
}
|
2023-07-28 23:43:11 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2023-06-16 23:12:17 +02:00
|
|
|
hasGrades() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.value.course.grades && this.value.course.grades.length > 0) {
|
|
|
|
for (const g of this.value.course.grades) {
|
|
|
|
if (g.selected) {
|
2023-06-16 23:12:17 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2023-09-08 12:47:29 +02:00
|
|
|
}
|
2023-06-16 23:12:17 +02:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
hasCompletions() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.value.course.completion && this.value.course.completion.conditions) {
|
|
|
|
for (const cgroup of this.value.course.completion.conditions) {
|
|
|
|
if (cgroup.items && cgroup.items.length > 0) {
|
2023-06-16 23:12:17 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2023-11-23 07:44:04 +01:00
|
|
|
hasCompetencies() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.value.course.competency && this.value.course.competency.competencies) {
|
2023-11-23 07:44:04 +01:00
|
|
|
return (this.value.course.competency.competencies.length > 0);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
includeChanged(newValue, g) {
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_include_grade',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'grade_id': g.id,
|
2023-09-08 12:47:29 +02:00
|
|
|
'item_id': this.value.id,
|
2023-05-17 21:19:14 +02:00
|
|
|
'include': newValue,
|
|
|
|
'required': g.required,
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
requiredChanged(newValue, g) {
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_include_grade',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'grade_id': g.id,
|
2023-09-08 12:47:29 +02:00
|
|
|
'item_id': this.value.id,
|
2023-05-17 21:19:14 +02:00
|
|
|
'include': g.selected,
|
|
|
|
'required': newValue,
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
updateConditions() {
|
|
|
|
call([{
|
2024-07-10 09:08:12 +02:00
|
|
|
methodname: 'local_treestudyplan_edit_studyitem',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'id': this.value.id,
|
2023-09-08 12:47:29 +02:00
|
|
|
'conditions': this.value.conditions,
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
template: `
|
2024-05-23 23:32:59 +02:00
|
|
|
<div class="t-item-course card">
|
|
|
|
<div class='t-item-course-cardwrapper mr-0 ml-0 h-100 '>
|
|
|
|
<div
|
|
|
|
:title="text['coursetiming_'+value.course.timing]"
|
|
|
|
v-b-popover.hover.top="startdate+' - '+enddate"
|
|
|
|
:class="'h-100 t-timing-indicator timing-'+value.course.timing"
|
|
|
|
></div>
|
|
|
|
<div class="t-item-course-title card-body h-100">
|
2024-06-03 23:24:16 +02:00
|
|
|
<fittext maxsize="12pt" minsize="9pt">
|
2024-05-23 23:32:59 +02:00
|
|
|
<a v-b-modal="'t-item-course-config-'+value.id"
|
|
|
|
:id="'t-item-course-details-'+value.id"
|
|
|
|
:href="wwwroot+'/course/view.php?id='+value.course.id"
|
2024-05-27 22:11:32 +02:00
|
|
|
@click.prevent.stop="">{{ value.course.displayname }}</a>
|
2024-05-23 23:32:59 +02:00
|
|
|
</fittext>
|
2023-08-04 16:54:41 +02:00
|
|
|
</div>
|
2024-05-23 23:32:59 +02:00
|
|
|
<div class="h-100 t-item-course-indicator ">
|
|
|
|
<a class="t-item-course-config"
|
|
|
|
v-b-modal="'t-item-course-config-'+value.id"
|
|
|
|
href="#" @click.prevent=""
|
|
|
|
><i :class="'fa fa-'+configurationIcon+' ' + configurationState"></i></a>
|
2023-08-04 16:54:41 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-02 23:25:21 +02:00
|
|
|
<b-modal class=""
|
2023-09-08 12:47:29 +02:00
|
|
|
:id="'t-item-course-config-'+value.id"
|
|
|
|
:title="value.course.displayname + ' - ' + value.course.fullname"
|
2023-05-17 21:19:14 +02:00
|
|
|
ok-only
|
2023-06-16 23:12:17 +02:00
|
|
|
size="lg"
|
2023-05-17 21:19:14 +02:00
|
|
|
scrollable
|
2023-09-02 23:25:21 +02:00
|
|
|
class="b-modal-justify-footer-between"
|
2023-05-17 21:19:14 +02:00
|
|
|
>
|
|
|
|
<template #modal-header>
|
|
|
|
<div>
|
2024-02-07 22:33:16 +01:00
|
|
|
<h1><a :href="wwwroot+'/course/view.php?id='+value.course.id" target="_blank"
|
2023-06-16 23:12:17 +02:00
|
|
|
><i class="fa fa-graduation-cap"></i> {{ value.course.fullname }}</a>
|
2023-09-08 12:47:29 +02:00
|
|
|
<a v-if='!!value.course.completion'
|
2024-02-07 22:33:16 +01:00
|
|
|
:href="wwwroot+'/course/completion.php?id='+value.course.id" target="_blank"
|
2023-06-16 23:12:17 +02:00
|
|
|
:title="text.configure_completion"><i class="fa fa-gear"></i></a>
|
|
|
|
</h1>
|
2023-05-17 21:19:14 +02:00
|
|
|
{{ value.course.context.path.join(" / ")}} / {{value.course.shortname}}
|
|
|
|
</div>
|
|
|
|
<div class="r-course-detail-header-right">
|
|
|
|
<div :class="'r-timing-'+value.course.timing">
|
|
|
|
{{text['coursetiming_'+value.course.timing]}}<br>
|
2023-07-28 23:43:11 +02:00
|
|
|
{{ startdate }} - {{ enddate }}
|
2023-05-17 21:19:14 +02:00
|
|
|
</div>
|
2023-08-07 11:48:06 +02:00
|
|
|
<t-item-timing-checker
|
|
|
|
class="mt-1"
|
2023-08-06 23:17:36 +02:00
|
|
|
:maxspan="maxspan"
|
|
|
|
:page="page"
|
2024-01-26 23:43:02 +01:00
|
|
|
:line="line"
|
2023-08-06 23:17:36 +02:00
|
|
|
:period="period"
|
|
|
|
v-model="value"
|
|
|
|
></t-item-timing-checker>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2024-06-05 23:27:00 +02:00
|
|
|
<s-course-extrafields
|
|
|
|
v-if="value.course.extrafields"
|
2023-12-11 22:30:30 +01:00
|
|
|
v-model="value.course.extrafields"
|
|
|
|
position="above"
|
|
|
|
></s-course-extrafields>
|
2023-09-08 12:47:29 +02:00
|
|
|
<t-item-course-grades
|
|
|
|
v-if='!!value.course.grades && value.course.grades.length > 0'
|
2023-06-16 23:12:17 +02:00
|
|
|
v-model='value' :plan="plan"
|
|
|
|
></t-item-course-grades>
|
|
|
|
<t-item-course-completion
|
2023-09-08 12:47:29 +02:00
|
|
|
v-if='!!value.course.completion'
|
2023-06-16 23:12:17 +02:00
|
|
|
v-model='value.course.completion'
|
|
|
|
:course='value.course'
|
|
|
|
></t-item-course-completion>
|
2023-11-23 07:44:04 +01:00
|
|
|
<t-item-course-competency
|
|
|
|
v-if='!!value.course.competency'
|
|
|
|
v-model='value.course.competency'
|
2023-11-26 22:58:26 +01:00
|
|
|
:item='value'
|
2023-11-23 07:44:04 +01:00
|
|
|
></t-item-course-competency>
|
2024-06-05 23:27:00 +02:00
|
|
|
<s-course-extrafields
|
|
|
|
v-if="value.course.extrafields"
|
2023-12-11 22:30:30 +01:00
|
|
|
v-model="value.course.extrafields"
|
|
|
|
position="below"
|
|
|
|
></s-course-extrafields>
|
2023-09-02 23:25:21 +02:00
|
|
|
<template #modal-footer="{ ok, cancel, hide }" >
|
2024-03-04 22:39:29 +01:00
|
|
|
<a href='#' @click.prevent='$emit("deleterq")' class="text-danger"
|
2023-09-02 23:25:21 +02:00
|
|
|
><i class="fa fa-trash"></i>
|
|
|
|
{{ text.delete }}
|
|
|
|
</a>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-button size="sm" variant="primary" @click.prevent="ok()">
|
2023-09-02 23:25:21 +02:00
|
|
|
{{ text.ok }}
|
|
|
|
</b-button>
|
|
|
|
</template>
|
2023-05-17 21:19:14 +02:00
|
|
|
</b-modal>
|
2024-05-23 23:32:59 +02:00
|
|
|
</div>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2023-06-16 23:12:17 +02:00
|
|
|
|
|
|
|
Vue.component('t-item-course-grades', {
|
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'value': {
|
2023-06-16 23:12:17 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
'plan': {
|
2023-06-16 23:12:17 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
},
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 22:22:19 +02:00
|
|
|
conditionOptions: stringKeys.conditions,
|
|
|
|
text: strings.itemCourseText,
|
2023-06-16 23:12:17 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
useRequiredGrades() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.plan && this.plan.aggregation_info && this.plan.aggregation_info.useRequiredGrades !== undefined) {
|
2023-06-16 23:12:17 +02:00
|
|
|
return this.plan.aggregation_info.useRequiredGrades;
|
2024-06-05 22:22:19 +02:00
|
|
|
} else {
|
2023-06-16 23:12:17 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
selectedgrades() {
|
2023-06-16 23:12:17 +02:00
|
|
|
let list = [];
|
2024-06-05 22:22:19 +02:00
|
|
|
for (let ix in this.value.course.grades) {
|
2023-06-16 23:12:17 +02:00
|
|
|
let g = this.value.course.grades[ix];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (g.selected) {
|
2023-06-16 23:12:17 +02:00
|
|
|
list.push(g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list;
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
includeChanged(newValue, g) {
|
2023-06-16 23:12:17 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_include_grade',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'grade_id': g.id,
|
2023-09-08 12:47:29 +02:00
|
|
|
'item_id': this.value.id,
|
2023-06-16 23:12:17 +02:00
|
|
|
'include': newValue,
|
|
|
|
'required': g.required,
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
requiredChanged(newValue, g) {
|
2023-06-16 23:12:17 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_include_grade',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'grade_id': g.id,
|
2023-09-08 12:47:29 +02:00
|
|
|
'item_id': this.value.id,
|
2023-06-16 23:12:17 +02:00
|
|
|
'include': g.selected,
|
|
|
|
'required': newValue,
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-09-08 12:47:29 +02:00
|
|
|
},
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<div>
|
|
|
|
<b-form-group
|
|
|
|
:label="text.select_grades"
|
|
|
|
><ul class="t-item-module-children">
|
|
|
|
<li class="t-item-course-gradeinfo">
|
|
|
|
<span class='t-item-course-chk-lbl'>{{text.grade_include}}</span
|
|
|
|
><span v-if="useRequiredGrades" class='t-item-course-chk-lbl'>{{text.grade_require}}</span>
|
|
|
|
</li>
|
|
|
|
<li class="t-item-course-gradeinfo" v-for="g in value.course.grades">
|
|
|
|
<b-form-checkbox inline
|
|
|
|
@change="includeChanged($event,g)" v-model="g.selected"
|
|
|
|
></b-form-checkbox>
|
|
|
|
<b-form-checkbox v-if="useRequiredGrades" inline :disabled="!g.selected"
|
|
|
|
@change="requiredChanged($event,g)" v-model="g.required"
|
|
|
|
></b-form-checkbox>
|
|
|
|
<span :title="g.typename" v-html="g.icon"></span>
|
2023-09-08 12:47:29 +02:00
|
|
|
<s-edit-mod
|
2023-06-16 23:12:17 +02:00
|
|
|
:title="value.course.fullname"
|
|
|
|
@saved="(fd) => g.name = fd.get('name')"
|
2023-09-08 12:47:29 +02:00
|
|
|
v-if="g.cmid > 0"
|
|
|
|
:cmid="g.cmid"
|
2023-06-16 23:12:17 +02:00
|
|
|
:coursectxid="value.course.ctxid"
|
2023-10-07 23:19:54 +02:00
|
|
|
genericonly><span v-html="g.name"></span></s-edit-mod>
|
2023-06-16 23:12:17 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</b-form-group>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-item-course-completion', {
|
2023-06-16 23:12:17 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-06-16 23:12:17 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
guestmode: {
|
|
|
|
type: Boolean,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': false,
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
course: {
|
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
text: strings.completion,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
hasCompletions() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.value.conditions) {
|
|
|
|
for (const cgroup of this.value.conditions) {
|
|
|
|
if (cgroup.items && cgroup.items.length > 0) {
|
2023-06-16 23:12:17 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2024-02-07 22:33:16 +01:00
|
|
|
wwwroot() {
|
|
|
|
return Config.wwwroot;
|
|
|
|
}
|
2023-06-16 23:12:17 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
completionIcon(completion) {
|
|
|
|
switch (completion) {
|
2023-06-16 23:12:17 +02:00
|
|
|
case "progress":
|
|
|
|
return "exclamation-circle";
|
|
|
|
case "complete":
|
|
|
|
return "check-circle";
|
|
|
|
case "complete-pass":
|
|
|
|
return "check-circle";
|
|
|
|
case "complete-fail":
|
|
|
|
return "times-circle";
|
2024-06-05 22:22:19 +02:00
|
|
|
default: // Case "incomplete"
|
2023-06-16 23:12:17 +02:00
|
|
|
return "circle-o";
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
completionTag(cgroup) {
|
|
|
|
return cgroup.completion ? 'completed' : 'incomplete';
|
2023-06-16 23:12:17 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<table class="r-item-course-grade-details">
|
|
|
|
<tr v-if="hasCompletions">
|
|
|
|
<td colspan='2'><span v-if="value.aggregation == 'all'">{{ text.aggregation_overall_all}}</span
|
|
|
|
><span v-else>{{ text.aggregation_overall_any}}</span></td>
|
|
|
|
</tr>
|
|
|
|
<tr v-else>
|
|
|
|
<td colspan='2'>{{text.completion_not_configured}}!
|
2024-02-07 22:33:16 +01:00
|
|
|
<br/><a :href="wwwroot+'/course/completion.php?id='+course.id" target='_blank'>{{text.configure_completion}}</a>
|
2023-06-16 23:12:17 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<template v-for='cgroup in value.conditions'>
|
|
|
|
<tr>
|
|
|
|
<th colspan='2'><span v-if="cgroup.items.length > 1"
|
|
|
|
><span v-if="cgroup.aggregation == 'all'">{{ text.aggregation_all}}</span
|
|
|
|
><span v-else>{{ text.aggregation_any}}</span></span>
|
|
|
|
{{cgroup.title}}</th>
|
|
|
|
</tr>
|
|
|
|
<tr v-for='ci in cgroup.items'>
|
|
|
|
<td><span v-html='ci.details.criteria'></span>
|
|
|
|
</td>
|
|
|
|
<td v-if="ci.details.requirement" class="font-italic">
|
|
|
|
{{ci.details.requirement}}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</table>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
// TAG: Course competency
|
|
|
|
Vue.component('t-item-course-competency', {
|
2023-11-23 07:44:04 +01:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-11-23 07:44:04 +01:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-11-23 07:44:04 +01:00
|
|
|
},
|
|
|
|
guestmode: {
|
|
|
|
type: Boolean,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': false,
|
2023-11-23 07:44:04 +01:00
|
|
|
},
|
2023-11-26 22:58:26 +01:00
|
|
|
item: {
|
2023-11-23 07:44:04 +01:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {id: null};
|
|
|
|
},
|
2023-11-26 22:58:26 +01:00
|
|
|
}
|
2023-11-23 07:44:04 +01:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
text: strings.competency,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
hasCompletions() {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.value.conditions) {
|
|
|
|
for (const cgroup of this.value.conditions) {
|
|
|
|
if (cgroup.items && cgroup.items.length > 0) {
|
2023-11-23 07:44:04 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2024-02-07 22:33:16 +01:00
|
|
|
wwwroot() {
|
|
|
|
return Config.wwwroot;
|
|
|
|
}
|
2023-11-23 07:44:04 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2023-11-24 23:00:53 +01:00
|
|
|
pathtags(competency) {
|
2023-11-23 07:44:04 +01:00
|
|
|
const path = competency.path;
|
|
|
|
let s = "";
|
|
|
|
for (const ix in path) {
|
|
|
|
const p = path[ix];
|
2024-06-05 22:22:19 +02:00
|
|
|
if (ix > 0) {
|
2023-11-23 07:44:04 +01:00
|
|
|
s += " / ";
|
|
|
|
}
|
2023-11-24 23:00:53 +01:00
|
|
|
let url;
|
2024-06-05 23:27:00 +02:00
|
|
|
if (p.type == 'competency') {
|
2023-11-24 23:00:53 +01:00
|
|
|
url = `/admin/tool/lp/competencies.php?competencyid=${p.id}`;
|
|
|
|
} else {
|
|
|
|
url = `/admin/tool/lp/competencies.php?competencyframeworkid=${p.id}&pagecontextid=${p.contextid}`;
|
|
|
|
}
|
|
|
|
s += `<a href="${url}">${p.title}</a>`;
|
2023-11-23 07:44:04 +01:00
|
|
|
}
|
2023-11-24 23:00:53 +01:00
|
|
|
return s;
|
2023-11-23 07:44:04 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
requiredChanged(newValue, c) {
|
2023-11-26 22:58:26 +01:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_require_competency',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'competency_id': c.id,
|
2023-11-26 22:58:26 +01:00
|
|
|
'item_id': this.item.id,
|
|
|
|
'required': newValue,
|
|
|
|
}
|
2023-12-13 23:49:06 +01:00
|
|
|
}])[0].catch(notification.exception);
|
2023-11-26 22:58:26 +01:00
|
|
|
},
|
2023-11-23 07:44:04 +01:00
|
|
|
},
|
|
|
|
template: `
|
2023-11-26 22:58:26 +01:00
|
|
|
<table class="t-item-course-competency-list">
|
2023-11-23 07:44:04 +01:00
|
|
|
<tr v-if="value.competencies.length == 0">
|
2024-01-26 12:26:01 +01:00
|
|
|
<td colspan='2'>{{text.competency_not_configured}}
|
2024-02-07 22:33:16 +01:00
|
|
|
<br><a :href="wwwroot+'/admin/tool/lp/coursecompetencies.php?courseid='+item.course.id" target='_blank'>{{text.configure_competency}}</a>
|
2023-11-23 07:44:04 +01:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<template v-else>
|
2023-11-26 22:58:26 +01:00
|
|
|
<tr class='t-item-course-competency-headers'>
|
|
|
|
<th>{{text.heading}}</th>
|
|
|
|
<th></th>
|
|
|
|
<th>{{text.required}}</th>
|
|
|
|
</tr>
|
2023-11-23 07:44:04 +01:00
|
|
|
<tr v-for='c in value.competencies'>
|
2023-11-26 22:58:26 +01:00
|
|
|
<td :colspan="(c.details)?1:2"><a href='#' v-b-modal="'modal-competency-id-'+c.id"><span v-html='c.title'></span></a></td>
|
|
|
|
<td class='details' v-if="c.details">
|
|
|
|
<a href='#' v-b-modal="'modal-competency-id-'+c.id"><span v-html='c.details'></span></a>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<b-form-checkbox inline
|
|
|
|
@change="requiredChanged($event,c)"
|
|
|
|
v-model="c.required"
|
|
|
|
>{{ text.required }}</b-form-checkbox>
|
2023-11-23 07:44:04 +01:00
|
|
|
</td>
|
|
|
|
<b-modal :id="'modal-competency-id-'+c.id"
|
|
|
|
size="lg"
|
|
|
|
ok-only
|
|
|
|
centered
|
|
|
|
scrollable
|
|
|
|
>
|
|
|
|
<template #modal-header>
|
|
|
|
<div>
|
2023-11-24 23:00:53 +01:00
|
|
|
<h1><i class="fa fa-puzzle-piece"></i>
|
2024-02-07 22:33:16 +01:00
|
|
|
<a :href="wwwroot+'/admin/tool/lp/competencies.php?competencyid='+c.id" target="_blank"
|
2023-11-24 23:00:53 +01:00
|
|
|
>{{c.title}} {{c.details}} </a
|
2023-11-23 07:44:04 +01:00
|
|
|
></h1>
|
2023-11-24 23:00:53 +01:00
|
|
|
<div><span v-html="pathtags(c)"></span></div>
|
2023-11-23 07:44:04 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
2023-11-26 22:58:26 +01:00
|
|
|
<div class="mb-2" v-if="c.description"><span v-html='c.description'></span></div>
|
|
|
|
|
|
|
|
<template v-if="c.rule && c.children">
|
|
|
|
<div>{{ c.ruleoutcome }} {{ text.when}} <span v-html="c.rule.toLocaleLowerCase()"></span></div>
|
|
|
|
<table v-if="c.children" class='t-item-course-competency-list'>
|
|
|
|
<tr class='t-item-course-competency-headers'>
|
|
|
|
<th>{{text.heading}}</th>
|
|
|
|
<th></th>
|
|
|
|
<th>{{text.required}}</th>
|
|
|
|
</tr>
|
|
|
|
<tr v-for="cc in c.children">
|
|
|
|
<td :colspan="(c.details)?1:2" ><span v-html='cc.title'></span></td>
|
|
|
|
<td class='details' v-if="cc.details"><span v-html='cc.details'></span></td>
|
|
|
|
<td><span class="text-info">{{ cc.points }} {{ text.points }}</span></td>
|
|
|
|
<td><span class="text-danger" v-if='cc.required'>{{ text.required }}</span></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</template>
|
2023-11-23 07:44:04 +01:00
|
|
|
</b-modal>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</table>
|
|
|
|
`,
|
|
|
|
});
|
2024-06-05 22:22:19 +02:00
|
|
|
/* **********************************
|
2023-05-17 21:19:14 +02:00
|
|
|
* *
|
2023-08-04 11:54:16 +02:00
|
|
|
* Toolbox list components *
|
2023-05-17 21:19:14 +02:00
|
|
|
* *
|
|
|
|
************************************/
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-item-junction', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 22:22:19 +02:00
|
|
|
conditionOptions: stringKeys.conditions,
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
},
|
|
|
|
template: `
|
2023-09-08 12:47:29 +02:00
|
|
|
<div class='t-item-junction t-item-filter'>
|
2023-05-17 21:19:14 +02:00
|
|
|
<i class="fa fa-check-circle"></i>
|
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-item-finish', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
},
|
|
|
|
template: `
|
2023-09-08 12:47:29 +02:00
|
|
|
<div class='t-item-finish t-item-filter'>
|
2023-05-17 21:19:14 +02:00
|
|
|
<i class="fa fa-stop-circle"></i>
|
2023-09-08 12:47:29 +02:00
|
|
|
</div>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-item-start', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
2024-06-05 22:22:19 +02:00
|
|
|
return {};
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
},
|
|
|
|
template: `
|
2023-09-08 12:47:29 +02:00
|
|
|
<div class='t-item-start t-item-filter'>
|
2023-05-17 21:19:14 +02:00
|
|
|
<i class="fa fa-play-circle"></i>
|
2023-09-08 12:47:29 +02:00
|
|
|
</div>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-item-badge', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {
|
|
|
|
badge: {}
|
|
|
|
};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-06-03 00:01:18 +02:00
|
|
|
txt: strings,
|
2024-06-05 22:22:19 +02:00
|
|
|
text: strings.itemText,
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
},
|
|
|
|
template: `
|
2023-09-08 12:47:29 +02:00
|
|
|
<div class='t-item-badge t-item-filter' v-b-tooltip.hover :title="value.badge.name">
|
2023-06-03 00:01:18 +02:00
|
|
|
<svg class="t-badge-backdrop " width='50px' height='50px' viewBox="0 0 100 100">
|
|
|
|
<title>{{value.badge.name}}</title>
|
2023-09-08 12:47:29 +02:00
|
|
|
<circle cx="50" cy="50" r="46"
|
2023-06-03 00:01:18 +02:00
|
|
|
style="stroke: currentcolor; stroke-width: 4; fill: currentcolor; fill-opacity: 0.5;"/>
|
|
|
|
<image class="badge-image" clip-path="circle() fill-box"
|
|
|
|
:href="value.badge.imageurl" x="12" y="12" width="76" height="76"/>
|
2023-05-17 21:19:14 +02:00
|
|
|
</svg>
|
2023-06-03 00:01:18 +02:00
|
|
|
<a class="t-item-config badge"
|
|
|
|
v-b-modal="'t-item-badge-details-'+value.id" href="#" @click.prevent=""><i class="fa fa-gear"></i></a>
|
2023-09-02 23:25:21 +02:00
|
|
|
<b-modal class=""
|
2023-09-08 12:47:29 +02:00
|
|
|
:id="'t-item-badge-details-'+value.id"
|
|
|
|
:title="value.badge.name"
|
2023-06-03 00:01:18 +02:00
|
|
|
size="lg"
|
|
|
|
ok-only
|
|
|
|
centered
|
|
|
|
scrollable
|
2023-09-02 23:25:21 +02:00
|
|
|
class="b-modal-justify-footer-between"
|
2023-06-03 00:01:18 +02:00
|
|
|
>
|
|
|
|
<template #modal-header>
|
|
|
|
<div>
|
|
|
|
<h1><i class="fa fa-certificate"></i>
|
|
|
|
<a :href="value.badge.infolink" target="_blank"
|
|
|
|
>{{ value.badge.name }}</a
|
|
|
|
></h1>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<b-container fluid>
|
|
|
|
<b-row><b-col cols="3">
|
|
|
|
<img :src="value.badge.imageurl"/>
|
|
|
|
</b-col><b-col cols="9">
|
|
|
|
<p>{{value.badge.description}}</p>
|
|
|
|
<ul class="list-unstyled w-100 border-grey border-top border-bottom pt-1 pb-1 mb-1"
|
|
|
|
v-if="value.badge.criteria"><li v-for="crit in value.badge.criteria"
|
|
|
|
><span v-html='crit'></span></li></ul>
|
|
|
|
<p><strong><i class="fa fa-link"></i>
|
|
|
|
<a :href="value.badge.infolink">{{ txt.badge.badgeinfo }}</a></strong></p>
|
|
|
|
</b-col></b-row>
|
|
|
|
</b-container>
|
2023-09-02 23:25:21 +02:00
|
|
|
<template #modal-footer="{ ok, cancel, hide }" >
|
2024-03-04 22:39:29 +01:00
|
|
|
<a href='#' @click.prevent='$emit("deleterq")' class="text-danger"
|
2023-09-02 23:25:21 +02:00
|
|
|
><i class="fa fa-trash"></i>
|
|
|
|
{{ text.delete }}
|
|
|
|
</a>
|
2024-03-04 22:39:29 +01:00
|
|
|
<b-button size="sm" variant="primary" @click.prevent="ok()">
|
2023-09-02 23:25:21 +02:00
|
|
|
{{ text.ok }}
|
|
|
|
</b-button>
|
2023-09-08 12:47:29 +02:00
|
|
|
</template>
|
2023-06-03 00:01:18 +02:00
|
|
|
</b-modal>
|
|
|
|
|
2023-09-08 12:47:29 +02:00
|
|
|
</div>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-coursecat-list', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Array,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<ul class="t-coursecat-list">
|
2023-09-08 12:47:29 +02:00
|
|
|
<t-coursecat-list-item
|
|
|
|
v-for="coursecat,idx in value"
|
|
|
|
v-model="value[idx]"
|
2023-05-17 21:19:14 +02:00
|
|
|
:key="coursecat.id"></t-coursecat-list-item>
|
2023-09-08 12:47:29 +02:00
|
|
|
</ul>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-coursecat-list-item', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loading: false,
|
|
|
|
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
showSpinner() {
|
|
|
|
return this.canLoadMore();
|
|
|
|
},
|
|
|
|
hasDetails() {
|
|
|
|
return (this.value.haschildren || this.value.hascourses);
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
canLoadMore() {
|
2024-06-05 22:22:19 +02:00
|
|
|
return (this.value.haschildren && (!this.value.children)) ||
|
|
|
|
(this.value.hascourses && (!this.value.courses));
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
onShowDetails() {
|
2023-05-17 21:19:14 +02:00
|
|
|
const self = this;
|
2024-06-05 22:22:19 +02:00
|
|
|
if (this.canLoadMore()) {
|
2023-05-17 21:19:14 +02:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_get_category',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
"id": this.value.id,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2023-05-17 21:19:14 +02:00
|
|
|
self.$emit('input', response);
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2023-12-13 23:49:06 +01:00
|
|
|
}).catch(notification.exception);
|
2023-05-17 21:19:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<li class="t-coursecat-list-item">
|
|
|
|
<span v-if="hasDetails" v-b-toggle="'coursecat-'+value.id">
|
2024-02-03 23:50:58 +01:00
|
|
|
<i class="when-closed fa fa-caret-right t-caret"></i>
|
|
|
|
<i class="when-open fa fa-caret-down t-caret"></i>
|
2023-05-17 21:19:14 +02:00
|
|
|
<span class="t-coursecat-heading">
|
|
|
|
<i class="t-coursecat-list-item fa fa-tasks"></i>
|
|
|
|
{{ value.category.name }}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<span v-else>
|
2024-02-03 23:50:58 +01:00
|
|
|
<i class="when-closed fa t-caret" style="visibility: hidden"></i>
|
2023-05-17 21:19:14 +02:00
|
|
|
<span class="t-coursecat-heading">
|
|
|
|
<i class="t-coursecat-list-item fa fa-tasks"></i>
|
|
|
|
{{ value.category.name }}
|
|
|
|
</span>
|
|
|
|
</span>
|
2023-09-08 12:47:29 +02:00
|
|
|
<b-collapse v-if="hasDetails" :id="'coursecat-'+value.id"
|
2023-05-17 21:19:14 +02:00
|
|
|
@show="onShowDetails" :visible="!!(value.children) || !!(value.courses)">
|
|
|
|
<b-spinner class="ml-4" v-if="showSpinner" small variant="primary"></b-spinner>
|
|
|
|
<t-coursecat-list v-if="value.children" v-model="value.children"></t-coursecat-list>
|
|
|
|
<t-course-list v-if="value.courses" v-model="value.courses"></t-course-list>
|
|
|
|
</b-collapse>
|
|
|
|
</li>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-course-list', {
|
2023-05-17 21:19:14 +02:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2023-05-17 21:19:14 +02:00
|
|
|
type: Array,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return {};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2024-06-05 22:22:19 +02:00
|
|
|
makeType() {
|
2023-08-04 11:54:16 +02:00
|
|
|
return {
|
|
|
|
item: false,
|
|
|
|
component: true,
|
2024-06-05 22:22:19 +02:00
|
|
|
span: 1, // TODO: Detect longer courses and give them an appropriate span
|
2023-08-04 11:54:16 +02:00
|
|
|
type: 'gradable',
|
|
|
|
};
|
|
|
|
},
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<ul class="t-course-list">
|
|
|
|
<li class="t-course-list-item" v-for="course in value" :key="course.id">
|
2024-04-21 23:08:03 +02:00
|
|
|
<span class='t-course-heading'>
|
2023-09-08 12:47:29 +02:00
|
|
|
<drag
|
|
|
|
class="draggable-course"
|
|
|
|
:data="course"
|
2023-08-04 11:54:16 +02:00
|
|
|
:type="makeType()"
|
2023-05-17 21:19:14 +02:00
|
|
|
@cut=""
|
|
|
|
>
|
|
|
|
<i class="t-course-list-item fa fa-book"></i> {{ course.shortname }} - {{ course.fullname }}
|
|
|
|
</drag>
|
2024-04-21 23:08:03 +02:00
|
|
|
</span>
|
2023-05-17 21:19:14 +02:00
|
|
|
</li>
|
2023-09-08 12:47:29 +02:00
|
|
|
</ul>
|
2023-05-17 21:19:14 +02:00
|
|
|
`,
|
|
|
|
});
|
2023-09-08 12:47:29 +02:00
|
|
|
|
2024-06-05 22:22:19 +02:00
|
|
|
Vue.component('t-toolbox', {
|
2024-03-09 08:23:42 +01:00
|
|
|
props: {
|
2024-06-05 22:22:19 +02:00
|
|
|
value: {
|
2024-03-09 08:23:42 +01:00
|
|
|
type: Boolean,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': true,
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
|
|
|
activepage: {
|
|
|
|
type: Object,
|
2024-06-05 22:22:19 +02:00
|
|
|
default() {
|
|
|
|
return null;
|
|
|
|
}
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
2024-03-09 22:51:34 +01:00
|
|
|
coaching: {
|
2024-03-09 08:23:42 +01:00
|
|
|
type: Boolean,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': false,
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
2024-03-09 23:29:58 +01:00
|
|
|
studyplanid: {
|
|
|
|
type: Number,
|
2024-06-03 23:24:16 +02:00
|
|
|
'default': 0,
|
2024-03-09 23:29:58 +01:00
|
|
|
}
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-06-05 23:27:00 +02:00
|
|
|
toolboxright: !(settings("toolboxleft")),
|
2024-03-09 08:23:42 +01:00
|
|
|
text: strings.toolbox,
|
|
|
|
relatedbadges: [],
|
|
|
|
systembadges: [],
|
|
|
|
courses: [],
|
|
|
|
filters: {
|
2024-03-11 23:21:59 +01:00
|
|
|
courses: "",
|
2024-03-09 08:23:42 +01:00
|
|
|
systembadges: "",
|
|
|
|
relatedbadges: "",
|
|
|
|
},
|
|
|
|
loadingcourses: false,
|
2024-03-11 23:21:59 +01:00
|
|
|
loadingcategories: [],
|
2024-05-31 22:32:43 +02:00
|
|
|
badgelistshown: {
|
|
|
|
relatedbadges: true,
|
|
|
|
systembadges: false,
|
|
|
|
}
|
2024-03-09 08:23:42 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
2024-06-05 22:22:19 +02:00
|
|
|
// Whenever activepage changes, this function will run
|
|
|
|
activepage(/* Params newVal, oldVal */) {
|
|
|
|
this.filterRelatedbadges();
|
2024-03-09 08:23:42 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2024-05-31 22:32:43 +02:00
|
|
|
const self = this;
|
2024-03-09 08:23:42 +01:00
|
|
|
this.initialize();
|
2024-05-31 22:32:43 +02:00
|
|
|
|
|
|
|
this.$root.$on('bv::collapse::state', (collapseId, isJustShown) => {
|
|
|
|
self.badgelistshown[collapseId] = !!isJustShown;
|
|
|
|
});
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
|
|
|
computed: {
|
2024-06-05 22:22:19 +02:00
|
|
|
filterComponentType() {
|
2024-03-09 08:23:42 +01:00
|
|
|
return {
|
|
|
|
item: false,
|
|
|
|
component: true,
|
|
|
|
span: 1,
|
|
|
|
type: 'filter',
|
|
|
|
};
|
|
|
|
},
|
2024-03-11 23:21:59 +01:00
|
|
|
filteredCourses() {
|
2024-06-05 22:22:19 +02:00
|
|
|
const self = this;
|
2024-03-11 23:21:59 +01:00
|
|
|
if (self.filters.courses) {
|
|
|
|
return self.filterCategories(self.courses);
|
|
|
|
} else {
|
|
|
|
return self.courses;
|
|
|
|
}
|
|
|
|
}
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2024-05-27 22:11:32 +02:00
|
|
|
hivizdrop() {
|
|
|
|
return settings("hivizdropslots");
|
|
|
|
},
|
2024-03-11 23:21:59 +01:00
|
|
|
filterCategories(catlist) {
|
|
|
|
const self = this;
|
|
|
|
const list = [];
|
2024-06-05 22:22:19 +02:00
|
|
|
const search = new RegExp(`.*?${self.filters.courses}.*?`, "ig");
|
2024-03-11 23:21:59 +01:00
|
|
|
for (const cat of catlist) {
|
2024-06-05 22:22:19 +02:00
|
|
|
const clone = Object.assign({}, cat);
|
2024-03-11 23:21:59 +01:00
|
|
|
clone.courses = [];
|
|
|
|
|
2024-06-05 23:27:00 +02:00
|
|
|
if (cat.courses) {
|
2024-03-11 23:21:59 +01:00
|
|
|
for (const course of cat.courses) {
|
2024-06-05 22:22:19 +02:00
|
|
|
if (search.test(course.shortname) || search.test(course.fullname)) {
|
2024-03-11 23:21:59 +01:00
|
|
|
clone.courses.push(course);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (cat.hascourses && !(self.loadingcategories.includes(cat.id))) {
|
|
|
|
self.loadingcategories.push(cat.id);
|
2024-06-05 22:22:19 +02:00
|
|
|
debug.info(`Loading from category ${cat.category.name}`, cat);
|
2024-03-11 23:21:59 +01:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_get_category',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
"id": cat.id
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2024-03-11 23:21:59 +01:00
|
|
|
// Add reactive array 'children' to cat
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$set(cat, "children", response.children);
|
|
|
|
self.$set(cat, "courses", response.courses);
|
|
|
|
self.loadingcategories.splice(self.loadingcategories.indexOf(cat.id), 1);
|
|
|
|
return;
|
2024-03-11 23:21:59 +01:00
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
2024-06-05 23:27:00 +02:00
|
|
|
|
2024-03-11 23:21:59 +01:00
|
|
|
if (cat.children) {
|
|
|
|
clone.children = self.filterCategories(cat.children);
|
|
|
|
} else if (cat.haschildren && !(self.loadingcategories.includes(cat.id))) {
|
|
|
|
self.loadingcategories.push(cat.id);
|
2024-06-05 22:22:19 +02:00
|
|
|
debug.info(`Loading from category ${cat.category.name}`, cat);
|
2024-03-11 23:21:59 +01:00
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_get_category',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
"id": cat.id,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2024-03-11 23:21:59 +01:00
|
|
|
// Add reactive array 'children' to cat
|
2024-06-05 22:22:19 +02:00
|
|
|
self.$set(cat, "children", response.children);
|
|
|
|
self.loadingcategories.splice(self.loadingcategories.indexOf(cat.id), 1);
|
|
|
|
return;
|
2024-03-11 23:21:59 +01:00
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
2024-06-05 23:27:00 +02:00
|
|
|
|
2024-03-11 23:21:59 +01:00
|
|
|
if ((clone.children && clone.children.length) || clone.courses.length) {
|
|
|
|
list.push(clone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
},
|
|
|
|
|
2024-03-09 08:23:42 +01:00
|
|
|
initialize() {
|
|
|
|
const self = this;
|
|
|
|
self.loadingcourses = true;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_map_categories',
|
2024-06-05 22:22:19 +02:00
|
|
|
args: {
|
|
|
|
'studyplan_id': self.studyplanid,
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2024-03-09 08:23:42 +01:00
|
|
|
self.courses = response;
|
|
|
|
self.loadingcourses = false;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2024-03-09 08:23:42 +01:00
|
|
|
}).catch(notification.exception);
|
2024-06-05 22:22:19 +02:00
|
|
|
this.filterSystembadges();
|
|
|
|
this.filterRelatedbadges();
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
filterSystembadges() {
|
2024-03-09 08:23:42 +01:00
|
|
|
const self = this;
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_search_badges',
|
2024-06-05 23:27:00 +02:00
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
search: this.filters.systembadges || "",
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2024-03-09 08:23:42 +01:00
|
|
|
self.systembadges = response;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2024-03-09 08:23:42 +01:00
|
|
|
}).catch(notification.exception);
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
filterRelatedbadges() {
|
2024-03-09 08:23:42 +01:00
|
|
|
const self = this;
|
|
|
|
if (this.activepage) {
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_search_related_badges',
|
2024-06-05 23:27:00 +02:00
|
|
|
args: {
|
2024-06-05 22:22:19 +02:00
|
|
|
'page_id': this.activepage.id,
|
|
|
|
search: this.filters.relatedbadges || ""
|
|
|
|
}
|
|
|
|
}])[0].then((response) => {
|
2024-03-09 08:23:42 +01:00
|
|
|
self.relatedbadges = response;
|
2024-06-05 22:22:19 +02:00
|
|
|
return;
|
2024-03-09 08:23:42 +01:00
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
resetSystembadges() {
|
2024-03-09 08:23:42 +01:00
|
|
|
this.filters.systembadges = "";
|
2024-06-05 22:22:19 +02:00
|
|
|
this.filterSystembadges();
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
2024-06-05 22:22:19 +02:00
|
|
|
resetRelatedbadges() {
|
2024-03-09 08:23:42 +01:00
|
|
|
this.filters.relatedbadges = "";
|
2024-06-05 22:22:19 +02:00
|
|
|
this.filterRelatedbadges();
|
2024-03-09 08:23:42 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
template: `
|
|
|
|
<div class="t-toolbox">
|
2024-04-21 23:08:03 +02:00
|
|
|
<p-sidebar
|
2024-05-31 22:32:43 +02:00
|
|
|
class="t-toolbox-sidebar"
|
2024-03-09 08:23:42 +01:00
|
|
|
:right='toolboxright'
|
|
|
|
shadow
|
|
|
|
v-model="value"
|
2024-04-21 23:08:03 +02:00
|
|
|
offsetRef="#page"
|
2024-03-09 08:23:42 +01:00
|
|
|
>
|
|
|
|
<div class="m-3 border-bottom-1 border-primary"><h3>{{text.toolbox}}</h3></div>
|
|
|
|
<div class='t-toolbox-preface'>
|
|
|
|
<b-form-checkbox v-model="toolboxright" switch>{{text.toolbarRight}}</b-form-checkbox>
|
|
|
|
</div>
|
2024-05-31 22:32:43 +02:00
|
|
|
<b-tabs content-class='mt-3' class="t-toolbox-tabs">
|
|
|
|
<b-tab :title="text.courses" class="t-toolbox-tab">
|
2024-03-09 08:23:42 +01:00
|
|
|
<div v-if="loadingcourses"
|
|
|
|
><div class="spinner-border text-primary" role="status"></div
|
|
|
|
></div>
|
2024-05-31 22:32:43 +02:00
|
|
|
<div v-else class="ml-2 t-toolbox-courses">
|
|
|
|
<div class="flex-grow-0">
|
|
|
|
<input v-model="filters.courses" :placeholder="text.filter"></input>
|
|
|
|
<a @click="filters.courses = ''" v-if="filters.courses" href='#'
|
|
|
|
><i class='fa fa-times'></i></a
|
|
|
|
><b-spinner small v-if="loadingcategories.length > 0" variant="primary"></b-spinner>
|
|
|
|
</div>
|
|
|
|
<div class="t-toolbox-courselist">
|
|
|
|
<t-coursecat-list v-model="filteredCourses"></t-coursecat-list>
|
|
|
|
</div>
|
2024-03-11 23:21:59 +01:00
|
|
|
</div>
|
2024-03-09 08:23:42 +01:00
|
|
|
</b-tab>
|
2024-05-31 22:32:43 +02:00
|
|
|
<b-tab :title="text.flow" class="t-toolbox-tab">
|
2024-05-31 22:33:10 +02:00
|
|
|
<ul class="t-flow">
|
2024-03-09 08:23:42 +01:00
|
|
|
<li><drag
|
|
|
|
:type="filterComponentType"
|
|
|
|
:data="{type: 'junction'}"
|
|
|
|
@cut=""
|
|
|
|
><t-item-junction></t-item-junction>{{ text.toolJunction }}
|
|
|
|
<template v-slot:drag-image="{data}"><t-item-junction></t-item-junction></template>
|
|
|
|
</drag></li>
|
|
|
|
<li><drag
|
|
|
|
:type="filterComponentType"
|
|
|
|
:data="{type: 'finish'}"
|
|
|
|
@cut=""
|
|
|
|
><t-item-finish></t-item-finish>{{ text.toolFinish }}
|
|
|
|
<template v-slot:drag-image="{data}"><t-item-finish></t-item-finish></template>
|
|
|
|
</drag></li>
|
|
|
|
<li><drag
|
|
|
|
:type="filterComponentType"
|
|
|
|
:data="{type: 'start'}"
|
|
|
|
@cut=""
|
|
|
|
><t-item-start></t-item-start>{{ text.toolStart }}
|
|
|
|
<template v-slot:drag-image="{data}"><t-item-start></t-item-start></template>
|
|
|
|
</drag></li>
|
|
|
|
</ul>
|
|
|
|
</b-tab>
|
2024-05-31 22:32:43 +02:00
|
|
|
<b-tab :title="text.badges" class="t-toolbox-tab">
|
2024-06-05 23:27:00 +02:00
|
|
|
|
2024-05-31 22:32:43 +02:00
|
|
|
<b-tabs content-class='mt-2 ml-2' class="t-toolbox-badges">
|
|
|
|
<b-tab :title="text.relatedbages">
|
|
|
|
<div class="t-toolbox-badges-filter">
|
2024-06-05 22:22:19 +02:00
|
|
|
<input v-model="filters.relatedbadges" @input="filterRelatedbadges" :placeholder="text.filter"></input>
|
|
|
|
<a @click="resetRelatedbadges" v-if="filters.relatedbadges" href='#'
|
2024-05-31 22:32:43 +02:00
|
|
|
><i class='fa fa-times'></i></a>
|
|
|
|
</div>
|
|
|
|
<div class="t-toolbox-badges-list">
|
2024-03-09 08:23:42 +01:00
|
|
|
<ul class="t-badges">
|
|
|
|
<li v-for="b in relatedbadges"><drag
|
|
|
|
class="t-badge-drag"
|
|
|
|
:type="filterComponentType"
|
|
|
|
:data="{type: 'badge', badge: b}"
|
|
|
|
@cut=""
|
2024-06-05 23:27:00 +02:00
|
|
|
><img :class="(!b.active)?'disabled':''" :src="b.imageurl" :alt="b.name">
|
2024-03-09 08:23:42 +01:00
|
|
|
<span :class="(!b.active)?'disabled':''">{{b.name}}</span>
|
|
|
|
<template v-slot:drag-image="{data}"
|
|
|
|
><img :class="(!b.active)?'disabled':''" :src="b.imageurl" :alt="b.name"
|
|
|
|
></template>
|
|
|
|
</drag></li>
|
|
|
|
</ul>
|
2024-05-31 22:32:43 +02:00
|
|
|
</div>
|
|
|
|
</b-tab>
|
|
|
|
<b-tab :title="text.sitebadges" v-if="!coaching">
|
|
|
|
<div class="t-toolbox-badges-filter">
|
2024-06-05 22:22:19 +02:00
|
|
|
<input v-model="filters.systembadges" @input="filterSystembadges" :placeholder="text.filter"></input>
|
|
|
|
<a @click="resetSystembadges" v-if="filters.systembadges" href='#'
|
2024-05-31 22:32:43 +02:00
|
|
|
><i class='fa fa-times'></i></a>
|
|
|
|
</div>
|
|
|
|
<div class="t-toolbox-badges-list">
|
2024-03-09 08:23:42 +01:00
|
|
|
<ul class="t-badges">
|
|
|
|
<li v-for="b in systembadges"><drag
|
|
|
|
class="t-badge-drag"
|
|
|
|
:type="filterComponentType"
|
|
|
|
:data="{type: 'badge', badge: b}"
|
|
|
|
@cut=""
|
2024-06-05 23:27:00 +02:00
|
|
|
><img :class="(!b.active)?'disabled':''" :src="b.imageurl" :alt="b.name">
|
2024-03-09 08:23:42 +01:00
|
|
|
<span :class="(!b.active)?'disabled':''">{{b.name}}</span>
|
|
|
|
<template v-slot:drag-image="{data}"
|
|
|
|
><img :class="(!b.active)?'disabled':''" :src="b.imageurl" :alt="b.name"
|
|
|
|
></template>
|
|
|
|
</drag></li>
|
|
|
|
</ul>
|
2024-05-31 22:32:43 +02:00
|
|
|
</div>
|
|
|
|
</b-tab>
|
|
|
|
</b-tabs>
|
2024-03-09 08:23:42 +01:00
|
|
|
</b-tab>
|
|
|
|
</b-tabs>
|
2024-04-21 23:08:03 +02:00
|
|
|
</p-sidebar>
|
2024-03-09 08:23:42 +01:00
|
|
|
</div>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
},
|
2024-06-05 23:27:00 +02:00
|
|
|
|
2023-05-17 21:19:14 +02:00
|
|
|
};
|