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,9 +2582,11 @@ export default {
}
},
redrawLines(){
for(let i in this.value.connections.out){
let conn = this.value.connections.out[i];
this.redrawLine(conn);
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);
}
}
},
@ -2595,29 +2599,35 @@ export default {
},
// Listener for the signal that a connection was removed by the outgoing item
onRemovedConnection(conn){
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);
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(){
for(let i in this.value.connections.out){
let conn = this.value.connections.out[i];
this.redrawLine(conn);
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){
for(let i in this.value.connections.out){
let conn = this.value.connections.out[i];
if(conn.to_id == re_id){
this.removeLine(conn);
}
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);
}
}
}
},
@ -2625,19 +2635,23 @@ export default {
// all connections to/from that item need to be cleaned up
onItemDeleted(item_id){
const self = this;
for(const i in this.value.connections.out){
let conn = this.value.connections.out[i];
if(conn.to_id == item_id){
self.removeLine(conn);
self.value.connections.out.splice(i, 1);
}
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){
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(){

File diff suppressed because one or more lines are too long