Skip to content

Commit

Permalink
ftr/PartsInGoToMenu: migrate OPERAs handling of parts in goto-menu
Browse files Browse the repository at this point in the history
needs some cleanup: just copied the whole code section that was intended to handle partwise and movementwise but probably was never finished.
tested with open-faust A3 and A2.
  • Loading branch information
Tobias Bachmann committed Dec 2, 2024
1 parent 8b7c184 commit 9617525
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controller/window/source/SourceView.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Ext.define('EdiromOnline.controller.window.source.SourceView', {
var data = response.responseText;

var movements = Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
fields: ['id', 'name', 'parts'],
data: Ext.JSON.decode(data)
});

Expand Down
87 changes: 82 additions & 5 deletions app/view/window/source/SourceView.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,90 @@ Ext.define('EdiromOnline.view.window.source.SourceView', {
me.movements = movements;
me.measureBasedView.setMovements(movements);

/* copy from OPERA
* TODO: cleanup and make partwise global option; probably implement possibility to order parts */
var partwise = true;

var movementItems = [];
movements.each(function(movement) {
movementItems.push({
text: movement.get('name'),
handler: Ext.bind(me.gotoMovement, me, movement.get('id'), true)
});
var partList = [];
var partNames =[];

movements.data.each(function(movement){

if (movement.data.parts === null){
movementItems.push({
text: movement.get('name'),
handler: Ext.bind(me.gotoMovement, me, movement.get('id'), true)
});
}
else
{
if (partwise)
{
movement.data.parts.forEach(function(part){
var exists = partNames.indexOf(part.name);
var obj = {
text: part.name,
menu: []
};
if (exists === -1) {
partNames.push(part.name);
partList.push(obj);
exists = partNames.length - 1;
} /*else {*/
var menu_mov = {
text: movement.get('name'),
handler: Ext.bind(me.gotoMovement, me, part.id, true)
}

partList[exists].menu.push(menu_mov);
/*}*/
});
}
else
{
var parts = [];

movement.data.parts.forEach(function(part){
parts.push(part);
});

if (movement.data.parts === null)
{
movementItems.push({
text: movement.get('name'),
handler: Ext.bind(me.gotoMovement, me, movement.get('id'), true)
});
partList.forEach(function(item){
movementItems.push(item);
});
}
else
{

var partItems = [];
parts.forEach(function(part){
partItems.push({
text: part.name,
handler: Ext.bind(me.gotoMovement, me, part.id, true)
});
});
movementItems.push({
text: movement.get('name'),
menu: [ partItems ]
});
}
}
}

});

if(partwise) {
partList.forEach(function(item){
movementItems.push(item);
});
}
/* end OPERA stuff */

me.gotoMenu.menu.add({
id: me.id + '_gotoMovement',
Expand Down

0 comments on commit 9617525

Please sign in to comment.