Filter components can be added again

This commit is contained in:
PMKuipers 2023-08-15 15:34:53 +02:00
parent 91f325ffd4
commit 9e59c4cdcb
9 changed files with 52 additions and 11941 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -176,8 +176,8 @@ export function init(contextid,categoryid) {
}, },
filterComponentType(){ filterComponentType(){
return { return {
item: true, item: false,
component: false, component: true,
span: 1, span: 1,
type: 'filter', type: 'filter',
}; };

View file

@ -1981,7 +1981,7 @@ export default {
onDrop(event) { onDrop(event) {
this.hover.component = null; this.hover.component = null;
this.hover.type = null; this.hover.type = null;
debug.info(event);
const self = this; const self = this;
if(event.type.item) { if(event.type.item) {
let item = event.data; let item = event.data;
@ -2003,7 +2003,7 @@ export default {
}); });
} }
else if(event.type.component){ else if(event.type.component){
debug.info("Adding new component");
if(event.type.type == "gradable"){ if(event.type.type == "gradable"){
call([{ call([{
methodname: 'local_treestudyplan_add_studyitem', methodname: 'local_treestudyplan_add_studyitem',
@ -2037,6 +2037,7 @@ export default {
}).fail(notification.exception); }).fail(notification.exception);
} }
else if(event.type.type == "filter") { else if(event.type.type == "filter") {
debug.info("Adding new filter compenent");
call([{ call([{
methodname: 'local_treestudyplan_add_studyitem', methodname: 'local_treestudyplan_add_studyitem',
args: { args: {
@ -2050,6 +2051,7 @@ export default {
}])[0].done((response) => { }])[0].done((response) => {
let item = response; let item = response;
self.relocateStudyItem(item).done(()=>{ self.relocateStudyItem(item).done(()=>{
item.layer = this.layer;
self.value.push(item); self.value.push(item);
self.$emit("input",self.value); self.$emit("input",self.value);
}); });
@ -2580,9 +2582,11 @@ export default {
} }
}, },
redrawLines(){ redrawLines(){
for(let i in this.value.connections.out){ if(this.value.connections && this.value.connections.out){
let conn = this.value.connections.out[i]; for(let i in this.value.connections.out){
this.redrawLine(conn); let conn = this.value.connections.out[i];
this.redrawLine(conn);
}
} }
}, },
@ -2595,29 +2599,35 @@ export default {
}, },
// Listener for the signal that a connection was removed by the outgoing item // Listener for the signal that a connection was removed by the outgoing item
onRemovedConnection(conn){ onRemovedConnection(conn){
for(let i in this.value.connections.in){ if(this.value.connections && this.value.connections.out){
let c_in = this.value.connections.in[i]; for(let i in this.value.connections.in){
if(conn.id == c_in.id){ let c_in = this.value.connections.in[i];
self.value.connections.out.splice(i, 1); if(conn.id == c_in.id){
self.value.connections.out.splice(i, 1);
}
} }
} }
}, },
// Listener for reposition events // Listener for reposition events
// When an item in the list is repositioned, all lines need to be redrawn // When an item in the list is repositioned, all lines need to be redrawn
onRePositioned(){ onRePositioned(){
for(let i in this.value.connections.out){ if(this.value.connections && this.value.connections.out){
let conn = this.value.connections.out[i]; for(let i in this.value.connections.out){
this.redrawLine(conn); let conn = this.value.connections.out[i];
this.redrawLine(conn);
}
} }
}, },
// When an item is disPositioned - (temporarily) removed from the list, // When an item is disPositioned - (temporarily) removed from the list,
// all connections need to be deleted. // all connections need to be deleted.
onDisPositioned(re_id){ onDisPositioned(re_id){
for(let i in this.value.connections.out){ if(this.value.connections && this.value.connections.out){
let conn = this.value.connections.out[i]; for(let i in this.value.connections.out){
if(conn.to_id == re_id){ let conn = this.value.connections.out[i];
this.removeLine(conn); if(conn.to_id == re_id){
} this.removeLine(conn);
}
}
} }
}, },
@ -2625,19 +2635,23 @@ export default {
// all connections to/from that item need to be cleaned up // all connections to/from that item need to be cleaned up
onItemDeleted(item_id){ onItemDeleted(item_id){
const self = this; const self = this;
for(const i in this.value.connections.out){ if(this.value.connections && this.value.connections.out){
let conn = this.value.connections.out[i]; for(const i in this.value.connections.out){
if(conn.to_id == item_id){ let conn = this.value.connections.out[i];
self.removeLine(conn); if(conn.to_id == item_id){
self.value.connections.out.splice(i, 1); self.removeLine(conn);
} self.value.connections.out.splice(i, 1);
}
}
}
if(this.value.connections && this.value.connections.in){
for(const i in this.value.connections.in){
let conn = this.value.connections.in[i];
if(conn.from_id == item_id){
self.value.connections.out.splice(i, 1);
}
}
} }
for(const i in this.value.connections.in){
let conn = this.value.connections.in[i];
if(conn.from_id == item_id){
self.value.connections.out.splice(i, 1);
}
}
}, },
onRedrawLines(){ onRedrawLines(){

File diff suppressed because one or more lines are too long