Skip to content

Commit

Permalink
ftr/PartsInGoToMenu: implement movementwise and preference for parts …
Browse files Browse the repository at this point in the history
…in goto-menu in sourceview

this commit updates the handling of parts in goto-menu. i added movementwise and a preference to edirom-prefs.xml
Closes Issue Edirom#13 and PR Edirom#271
  • Loading branch information
Tobias Bachmann committed Dec 4, 2024
1 parent 9617525 commit b3d6b43
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 57 deletions.
1 change: 1 addition & 0 deletions add/data/prefs/edirom-prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
<entry key="image_server" value="digilib"/>
<entry key="edition_path" value="/db/apps/contents"/>
<entry key="start_documents_uri" value=""/>
<entry key="gotomenu_display" value="partwise"/>
</entries>
</prefs>
88 changes: 31 additions & 57 deletions app/view/window/source/SourceView.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,94 +209,68 @@ Ext.define('EdiromOnline.view.window.source.SourceView', {

setMovements: function(movements) {
var me = this;
var gotomenu_display = getPreference('gotomenu_display');

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 = [];
var partList = [];
var partNames =[];

movements.data.each(function(movement){

if (movement.data.parts === null){
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){
} else {
if(gotomenu_display == 'partwise') {
movement.data.parts.forEach(function(part) {
var exists = partNames.indexOf(part.name);
var obj = {
text: part.name,
menu: []
};
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);
/*}*/
}
var menu_mov = {
text: movement.get('name'),
handler: Ext.bind(me.gotoMovement, me, part.id, true)
}

partList[exists].menu.push(menu_mov);
});
}
else
{
} 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)
});
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 ]
});
}
});

movementItems.push({
text: movement.get('name'),
menu: partItems
});
}
}

});
if(partwise) {
partList.forEach(function(item){

if(gotomenu_display == '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 b3d6b43

Please sign in to comment.