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(){
return {
item: true,
component: false,
item: false,
component: true,
span: 1,
type: 'filter',
};

View file

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

File diff suppressed because one or more lines are too long