diff --git a/htdocs/js/album.js b/htdocs/js/album.js index eae932f5c..089bfede9 100644 --- a/htdocs/js/album.js +++ b/htdocs/js/album.js @@ -5,40 +5,6 @@ /** @module album_js */ -/** - * Handles album filtered by tag - * @param {string} action action to perform - * @param {string} albumId the album id - * @param {string} tag MPD tag - * @param {string} value MPD tag value - * @returns {void} - */ -//eslint-disable-next-line no-unused-vars -function addAlbumTag(action, albumId, tag, value) { - switch(action) { - case 'appendQueue': - appendQueue(tag, [albumId, value]); - break; - case 'appendPlayQueue': - appendPlayQueue(tag, [albumId, value]); - break; - case 'insertAfterCurrentQueue': - insertAfterCurrentQueue(tag, [albumId, value]); - break; - case 'replaceQueue': - replaceQueue(tag, [albumId, value]); - break; - case 'replacePlayQueue': - replacePlayQueue(tag, [albumId, value]); - break; - case 'addPlaylist': - showAddToPlaylist(tag, [albumId, value]); - break; - default: - logError('Invalid action: ' + action); - } -} - /** * Resume album API implementation. * Load the album from last played song and start playing. diff --git a/htdocs/js/contextMenu.js b/htdocs/js/contextMenu.js index b5c14a801..6b1f6bbcd 100644 --- a/htdocs/js/contextMenu.js +++ b/htdocs/js/contextMenu.js @@ -208,19 +208,20 @@ function addMenuItemsAlbumTagActions(target, contextMenuTitle, contextMenuBody) const type = getData(dataNode, 'type'); const value = getData(dataNode, ucFirst(type)); const albumId = getData(dataNode, 'AlbumId'); + const albumName = getData(dataNode, 'name'); - addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["appendQueue", albumId, type, value]}, 'Append to queue'); - addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["appendPlayQueue", albumId, type, value]}, 'Append to queue and play'); + addMenuItem(contextMenuBody, {"cmd": "appendQueue", "options": [type, [albumId, value]]}, 'Append to queue'); + addMenuItem(contextMenuBody, {"cmd": "appendPlayQueue", "options": [type, [albumId, value]]}, 'Append to queue and play'); if (features.featWhence === true && currentState.currentSongId !== -1) { - addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["insertAfterCurrentQueue", albumId, type, value]}, 'Insert after current playing song'); + addMenuItem(contextMenuBody, {"cmd": "insertAfterCurrentQueue", "options": [type, [albumId, value]]}, 'Insert after current playing song'); } - addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["replaceQueue", albumId, type, value]}, 'Replace queue'); - addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["replacePlayQueue", albumId, type, value]}, 'Replace queue and play'); + addMenuItem(contextMenuBody, {"cmd": "replaceQueue", "options": [type, [albumId, value]]}, 'Replace queue'); + addMenuItem(contextMenuBody, {"cmd": "replacePlayQueue", "options": [type, [albumId, value]]}, 'Replace queue and play'); if (features.featPlaylists === true) { addDivider(contextMenuBody); - addMenuItem(contextMenuBody, {"cmd": "addAlbumTag", "options": ["addPlaylist", albumId, type, value]}, 'Add to playlist'); + addMenuItem(contextMenuBody, {"cmd": "showAddToPlaylist", "options": [type, [albumId, value], [albumName]]}, 'Add to playlist'); } } @@ -275,8 +276,15 @@ function addMenuItemsConsumeActions(contextMenuBody) { * @returns {void} */ function addMenuItemsAlbumActions(dataNode, contextMenuTitle, contextMenuBody, albumId) { + const albumName = []; if (dataNode !== null) { - albumId = getData(dataNode, 'AlbumId'); + if (albumId === undefined) { + albumId = getData(dataNode, 'AlbumId'); + } + const name = getData(dataNode, 'name'); + if (name !== null) { + albumName.push(name); + } } if (contextMenuTitle !== null) { contextMenuTitle.textContent = tn('Album'); @@ -294,7 +302,7 @@ function addMenuItemsAlbumActions(dataNode, contextMenuTitle, contextMenuBody, a } if (features.featPlaylists === true) { addDivider(contextMenuBody); - addMenuItem(contextMenuBody, {"cmd": "showAddToPlaylist", "options": ["album", [albumId]]}, 'Add to playlist'); + addMenuItem(contextMenuBody, {"cmd": "showAddToPlaylist", "options": ["album", [albumId], albumName]}, 'Add to playlist'); } addDivider(contextMenuBody); if (app.id !== 'BrowseDatabaseAlbumDetail') { @@ -322,10 +330,10 @@ function addMenuItemsAlbumActions(dataNode, contextMenuTitle, contextMenuBody, a ? getData(dataNode, 'name') : ''; const image = dataNode !== null - ? getData(dataNode, 'image') + ? getData(dataNode, 'cssImageUrl') : ''; addDivider(contextMenuBody); - addMenuItem(contextMenuBody, {"cmd": "addAlbumToHome", "options": [albumId, name, image]}, 'Add to homescreen'); + addMenuItem(contextMenuBody, {"cmd": "addAlbumToHome", "options": [albumId, name, image.substr(5,image.length-7)]}, 'Add to homescreen'); } } @@ -809,7 +817,7 @@ function createMenuHomeIcon(target, contextMenuTitle, contextMenuBody) { addMenuItemsSearchActions(contextMenuBody, href.options[1][0], href.options[1][1], href.options[1][2]); break; case 'album': - addMenuItemsAlbumActions(null, null, contextMenuBody, href.options[1][0]); + addMenuItemsAlbumActions(target, null, contextMenuBody, href.options[1][0]); break; case 'view': case 'externalLink': diff --git a/htdocs/js/modalPlaylistAddTo.js b/htdocs/js/modalPlaylistAddTo.js index 9522bc19a..f5a4ec803 100644 --- a/htdocs/js/modalPlaylistAddTo.js +++ b/htdocs/js/modalPlaylistAddTo.js @@ -18,9 +18,10 @@ function initModalPlaylistAddTo() { * Shows the add to playlist modal * @param {string} type one off album, disc, search, song, stream, searchdir * @param {Array} entities entities to add + * @param {Array} [entityNames] entity names to add (only for display) * @returns {void} */ -function showAddToPlaylist(type, entities) { +function showAddToPlaylist(type, entities, entityNames) { cleanupModalId('modalPlaylistAddTo'); setDataId('modalPlaylistAddToUrisInput', 'type', type); setDataId('modalPlaylistAddToUrisInput', 'entities', entities); @@ -41,7 +42,12 @@ function showAddToPlaylist(type, entities) { elHideId('modalPlaylistAddToAddStreamFrm'); elShowId('modalPlaylistAddToSrcRow'); const names = []; - if (type === 'searchdir') { + if (entityNames !== undefined && + entityNames.length > 0) + { + names.push(... entityNames); + } + else if (type === 'searchdir') { names.push(tn('Path') + ': ' + entities[0]); if (entities[1] !== '') { names.push(tn('Search') + ': ' + entities[1]); diff --git a/htdocs/js/selectActions.js b/htdocs/js/selectActions.js index b287c7c9f..726f87f32 100644 --- a/htdocs/js/selectActions.js +++ b/htdocs/js/selectActions.js @@ -167,6 +167,7 @@ function execSelectAction(type, action) { const parent = elGetById(app.id + 'List'); const attribute = getExecSelectActionAttribute(type, action); const data = getSelectionData(parent, attribute); + const names = getSelectionData(parent, 'name'); switch(action) { case 'appendQueue': appendQueue(type, data); @@ -190,7 +191,7 @@ function execSelectAction(type, action) { removeFromQueueIDs(data); break; case 'showAddToPlaylist': - showAddToPlaylist(type, data); + showAddToPlaylist(type, data, names); break; case 'showMoveToPlaylist': { const plist = getData(parent, 'uri'); diff --git a/htdocs/js/viewHome.js b/htdocs/js/viewHome.js index 0c6d9543a..a2e376932 100644 --- a/htdocs/js/viewHome.js +++ b/htdocs/js/viewHome.js @@ -217,6 +217,7 @@ function createHomeIcon(data, pos) { } setData(card, 'type', 'icon'); + setData(card, 'name', data.name); setData(card, 'href', {"cmd": data.cmd, "options": data.options}); setData(card, 'pos', pos); const cardTitle = elCreateText('div', {"class": ["card-title", "mi", "rounded", "clickable"]}, data.ligature); diff --git a/htdocs/js/viewsTables.js b/htdocs/js/viewsTables.js index 6443709c8..7c72a94da 100644 --- a/htdocs/js/viewsTables.js +++ b/htdocs/js/viewsTables.js @@ -155,10 +155,11 @@ function replaceTblRow(mode, row, el) { * Adds a row with discnumber to the table * @param {number} disc discnumber * @param {string} albumId the albumid + * @param {string} albumName the album name * @param {number} colspan column count * @returns {HTMLElement} the created row */ -function addDiscRow(disc, albumId, colspan) { +function addDiscRow(disc, albumId, albumName, colspan) { const actionTd = elCreateEmpty('td', {"data-col": "Action"}); addActionLinks(actionTd, 'disc'); const row = elCreateNodes('tr', {"class": ["not-clickable"]}, [ @@ -171,6 +172,7 @@ function addDiscRow(disc, albumId, colspan) { setData(row, 'Disc', disc); setData(row, 'AlbumId', albumId); setData(row, 'type', 'disc'); + setData(row, 'name', albumName + ' (' + tn('Disc') + ' ' + disc + ')'); return row; } @@ -188,10 +190,11 @@ function showWorkRow(view) { * Adds a row with the work to the table. * @param {string} work The work name * @param {string} albumId the albumid + * @param {string} albumName the album name * @param {number} colspan column count * @returns {HTMLElement} the created row */ -function addWorkRow(work, albumId, colspan) { +function addWorkRow(work, albumId, albumName, colspan) { const actionTd = elCreateEmpty('td', {"data-col": "Action"}); addActionLinks(actionTd, 'work'); const row = elCreateNodes('tr', {"class": ["not-clickable"]}, [ @@ -204,6 +207,7 @@ function addWorkRow(work, albumId, colspan) { setData(row, 'Work', work); setData(row, 'AlbumId', albumId); setData(row, 'type', 'work'); + setData(row, 'name', albumName + ' (' + work + ')'); return row; } @@ -249,7 +253,7 @@ function updateTable(obj, list, perRowCallback, createRowCellsCallback) { if (obj.result.Discs !== undefined && obj.result.Discs > 1) { - const row = addDiscRow(1, obj.result.AlbumId, colspan); + const row = addDiscRow(1, obj.result.AlbumId, obj.result.Album, colspan); if (z < tr.length) { replaceTblRow(mode, tr[z], row); } @@ -260,7 +264,7 @@ function updateTable(obj, list, perRowCallback, createRowCellsCallback) { } if (showWorkRow(list) && lastWork !== '') { - const row = addWorkRow(lastWork, obj.result.AlbumId, colspan); + const row = addWorkRow(lastWork, obj.result.AlbumId, obj.result.Album, colspan); if (z < tr.length) { replaceTblRow(mode, tr[z], row); } @@ -275,7 +279,7 @@ function updateTable(obj, list, perRowCallback, createRowCellsCallback) { if (obj.result.data[0].Disc !== undefined && lastDisc < Number(obj.result.data[i].Disc)) { - const row = addDiscRow(obj.result.data[i].Disc, obj.result.AlbumId, colspan); + const row = addDiscRow(obj.result.data[i].Disc, obj.result.AlbumId, obj.result.Album, colspan); if (i + z < tr.length) { replaceTblRow(mode, tr[i + z], row); } @@ -288,7 +292,7 @@ function updateTable(obj, list, perRowCallback, createRowCellsCallback) { if (showWorkRow(list) && obj.result.data[0].Work !== undefined && lastWork !== obj.result.data[i].Work) { - const row = addWorkRow(obj.result.data[i].Work, obj.result.AlbumId, colspan); + const row = addWorkRow(obj.result.data[i].Work, obj.result.AlbumId, obj.result.Album, colspan); if (i + z < tr.length) { replaceTblRow(mode, tr[i + z], row); } else {