mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-26 02:50:26 +00:00
Feat: save search as smart playlist #38
This commit is contained in:
parent
e550601aa8
commit
ffb0b72e6e
@ -467,6 +467,7 @@
|
||||
<div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="searchAddAllSongsDropdown">
|
||||
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to playlist</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm btn-block">Save as smart playlist</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -646,6 +647,30 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modalSaveSmartPlaylist" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><span class="material-icons title-icon">playlist_add</span>Save smart playlist</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="needs-validation" id="saveSmartPlaylistFrm" novalidate>
|
||||
<div class="form-group">
|
||||
<label for="saveSmartPlaylistName">Name</label>
|
||||
<input type="text" class="form-control" id="saveSmartPlaylistName" value="myMPDsmart-"/>
|
||||
<div class="invalid-feedback">Invalid filename.</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-success" data-href='{"cmd": "saveSmartPlaylist", "options": []}'>Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modalSettings" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
|
@ -97,6 +97,7 @@ var modalSongDetails = new Modal(document.getElementById('modalSongDetails'));
|
||||
var modalAddToPlaylist = new Modal(document.getElementById('modalAddToPlaylist'));
|
||||
var modalRenamePlaylist = new Modal(document.getElementById('modalRenamePlaylist'));
|
||||
var modalUpdateDB = new Modal(document.getElementById('modalUpdateDB'));
|
||||
var modalSaveSmartPlaylist = new Modal(document.getElementById('modalSaveSmartPlaylist'));
|
||||
//var mainMenu = new Dropdown(document.getElementById('mainMenu'));
|
||||
//var volumeMenu = new Dropdown(document.getElementById('volumeIcon'));
|
||||
|
||||
@ -487,6 +488,9 @@ function appInit() {
|
||||
else if (event.target.innerText == 'Add all to playlist') {
|
||||
showAddToPlaylist('SEARCH');
|
||||
}
|
||||
else if (event.target.innerText == 'Save as smart playlist') {
|
||||
showSaveSmartPlaylist();
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
|
||||
@ -1596,6 +1600,29 @@ function toggleAddToPlaylistFrm() {
|
||||
}
|
||||
}
|
||||
|
||||
function showSaveSmartPlaylist() {
|
||||
var nameEl = document.getElementById('saveSmartPlaylistName');
|
||||
nameEl.value = 'myMPDsmart-';
|
||||
nameEl.classList.remove('is-invalid');
|
||||
document.getElementById('saveSmartPlaylistFrm').classList.remove('was-validated');
|
||||
modalSaveSmartPlaylist.show();
|
||||
nameEl.focus();
|
||||
}
|
||||
|
||||
function saveSmartPlaylist() {
|
||||
var value = document.getElementById('saveSmartPlaylistName').value;
|
||||
var valid = value.replace(/[\w\-]/g, '');
|
||||
if (value != '' && valid == '') {
|
||||
sendAPI({"cmd": "MPD_API_SMARTPLS_SAVE", "data": {"playlist": value, "tag": app.current.filter, "searchstr": app.current.search}});
|
||||
modalSaveSmartPlaylist.hide();
|
||||
showNotification('Saved smart playlist ' + value, '', '', 'success');
|
||||
}
|
||||
else {
|
||||
document.getElementById('saveSmartPlaylistName').classList.add('is-invalid');
|
||||
document.getElementById('saveSmartPlaylistFrm').classList.add('was-validated');
|
||||
}
|
||||
}
|
||||
|
||||
function showAddToPlaylist(uri) {
|
||||
document.getElementById('addToPlaylistUri').value = uri;
|
||||
document.getElementById('addToPlaylistPlaylist').innerHTML = '';
|
||||
|
Loading…
Reference in New Issue
Block a user