This commit is contained in:
PMKuipers 2023-08-16 23:36:11 +02:00
parent cae51717a9
commit 490a71be3b
4 changed files with 41 additions and 17 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,8 @@ import {load_stringkeys, load_strings, format_date, datespaninfo} from './string
import {objCopy,transportItem} from './studyplan-processor'; import {objCopy,transportItem} from './studyplan-processor';
import Debugger from './debugger'; import Debugger from './debugger';
import {download,upload} from './downloader'; import {download,upload} from './downloader';
import {ProcessStudyplan} from './studyplan-processor';
const STUDYPLAN_EDITOR_FIELDS = const STUDYPLAN_EDITOR_FIELDS =
['name','shortname','description','idnumber','context_id', 'aggregation','aggregation_config']; ['name','shortname','description','idnumber','context_id', 'aggregation','aggregation_config'];
@ -650,10 +652,24 @@ export default {
const moved_to = response.context_id; const moved_to = response.context_id;
const moved = (moved_from != moved_to); const moved = (moved_from != moved_to);
objCopy(self.value,response,STUDYPLAN_EDITOR_FIELDS); if(response.pages[0].periods != self.value.pages[0].periods){
self.$emit('input',self.value); // reload the entire model
if(moved){ call([{
self.$emit('moved',self.value,moved_from, moved_to); methodname: 'local_treestudyplan_get_studyplan_map',
args: { id: self.value.id}
}])[0].done(function(response){
self.value = ProcessStudyplan(response,true);
debug.info('studyplan processed');
self.$emit('input',self.value);
}).fail(function(error){
notification.exception(error);
});
} else {
objCopy(self.value,response,STUDYPLAN_EDITOR_FIELDS);
self.$emit('input',self.value);
if(moved){
self.$emit('moved',self.value,moved_from, moved_to);
}
} }
} }
}).fail(notification.exception); }).fail(notification.exception);
@ -1324,19 +1340,22 @@ export default {
{ {
let maxLayer = -1; let maxLayer = -1;
for(let i = 0; i <= this.page.periods; i++){ for(let i = 0; i <= this.page.periods; i++){
const slot = line.slots[i]; if(line.slots[i]){
// Determine the amount of used layers in a studyline slit const slot = line.slots[i];
for(const ix in line.slots[i].competencies){ // Determine the amount of used layers in a studyline slit
const item = line.slots[i].competencies[ix]; for(const ix in line.slots[i].competencies){
if(item.layer > maxLayer){ const item = line.slots[i].competencies[ix];
maxLayer = item.layer; if(item.layer > maxLayer){
maxLayer = item.layer;
}
} }
} for(const ix in line.slots[i].filters){
for(const ix in line.slots[i].filters){ const item = line.slots[i].filters[ix];
const item = line.slots[i].filters[ix]; if(item.layer > maxLayer){
if(item.layer > maxLayer){ maxLayer = item.layer;
maxLayer = item.layer; }
} }
} }
} }
this.cache.linelayers[line.id] = { this.cache.linelayers[line.id] = {

View File

@ -37,6 +37,10 @@ class studyline {
return $this->studyplan; return $this->studyplan;
} }
public function page() : studyplanpage {
return $this->page;
}
public static function findById($id): self { public static function findById($id): self {
if(!array_key_exists($id,self::$STUDYLINE_CACHE)){ if(!array_key_exists($id,self::$STUDYLINE_CACHE)){
self::$STUDYLINE_CACHE[$id] = new self($id); self::$STUDYLINE_CACHE[$id] = new self($id);
@ -102,6 +106,7 @@ class studyline {
unset($model["sequence"]); unset($model["sequence"]);
} }
// TODO: Make this a little nicer
// Get the number of slots // Get the number of slots
// As a safety data integrity measure, if there are any items in a higher slot than currently allowed, // As a safety data integrity measure, if there are any items in a higher slot than currently allowed,
// make sure there are enought slots to account for them // make sure there are enought slots to account for them