diff --git a/core/models/playlists_model.php b/core/models/playlists_model.php index 86649a37..58264028 100644 --- a/core/models/playlists_model.php +++ b/core/models/playlists_model.php @@ -299,7 +299,40 @@ public function search($query, $limit, $offset, $sort_by, $sort_dir, $my = false $where_strings = []; if ($query !== '' && $query !== false && $query !== null) { - $where_strings[] = '(name LIKE "%' . $this->db->escape($query) . '%" OR description LIKE "%' . $this->db->escape($query) . '%")'; + $query = trim($query); + $query_escape = $this->db->escape($query); + + $type_query = null; + $type_query_map = [ + 'b' => 'standard', + 'basic' => 'standard', + 'standard' => 'standard', + 'pl b' => 'standard', + 'playlist basic' => 'standard', + 'playlist standard' => 'standard', + 'a' => 'advanced', + 'advanced' => 'advanced', + 'pl a' => 'advanced', + 'playlist advanced' => 'advanced', + 'la' => 'live_assist', + 'live assist' => 'live_assist', + 'liveassist' => 'live_assist', + 'live_assist' => 'live_assist', + 'pl la' => 'live_assist', + 'playlist live assist' => 'live_assist', + ]; + + $query_normalized = strtolower($query); + if (isset($type_query_map[$query_normalized])) { + $type_query = $this->db->escape($type_query_map[$query_normalized]); + } + + $where = '(name LIKE "%' . $query_escape . '%" OR description LIKE "%' . $query_escape . '%")'; + if ($type_query !== null) { + $where .= ' OR type = "' . $type_query . '"'; + } + + $where_strings[] = '(' . $where . ')'; } if (!$this->user->check_permission('manage_playlists')) { $where_strings[] = '(status = "public" or status = "visible" or owner_id = "' . $this->db->escape($this->user->param('id')) . '")'; diff --git a/public/js/sidebar.js b/public/js/sidebar.js index 7565691b..299777b8 100644 --- a/public/js/sidebar.js +++ b/public/js/sidebar.js @@ -10,6 +10,7 @@ OB.Sidebar.init = function () { OB.Sidebar.mediaSearchQuery = ""; OB.Sidebar.playlistSearchQuery = ""; + OB.Sidebar.sidebarInit = function () { if (parseInt(OB.Account.userdata.sidebar_display_left)) { $("body").addClass("sidebar-left"); @@ -850,6 +851,29 @@ OB.Sidebar.playlistSearchSort = function (sortby) { OB.Sidebar.playlistSearch(); }; +OB.Sidebar.playlistTypeBadges = function (playlistType) { + if (!playlistType) playlistType = "standard"; + + var iconClass = "fa-list"; + var title = "Standard Playlist"; + + if (playlistType == "advanced") { + iconClass = "fa-cogs"; + title = "Advanced Playlist"; + } else if (playlistType == "live_assist") { + iconClass = "fa-microphone"; + title = "Live Assist Playlist"; + } + + return ( + '' + + '' + + "" + ); +}; + OB.Sidebar.playlistSearch = function (more) { // if not the result of pagination (new search), reset offset to 0 if (!more) { @@ -913,7 +937,10 @@ OB.Sidebar.playlistSearch = function (more) { playlist[i]["id"] + '" data-mode="playlist">\ ' + + OB.Sidebar.playlistTypeBadges(playlist[i]["type"]) + + '' + htmlspecialchars(playlist[i]["name"]) + + "" + '\ ' + playlist_description + @@ -948,6 +975,7 @@ OB.Sidebar.playlistSearch = function (more) { "data-can_edit", playlist[i]["can_edit"], ); + $("#sidebar_search_playlist_result_" + playlist[i]["id"]).attr("data-type", playlist[i]["type"]); // set up context menu var menuOptions = new Object(); diff --git a/public/scss/_sidebar.scss b/public/scss/_sidebar.scss index 4173a3a7..2b1cfa23 100755 --- a/public/scss/_sidebar.scss +++ b/public/scss/_sidebar.scss @@ -412,6 +412,36 @@ body.sidebar-left .sidebar_search_media_container_detailed #media_detailed_toggl width: 90px; } +.sidebar_search_playlist_name_text { + vertical-align: middle; +} + +.sidebar_search_playlist_type_badges { + display: inline-flex; + margin-right: 6px; + vertical-align: middle; +} + +.sidebar_search_playlist_type_badge { + display: inline-block; + padding: 0 2px; + font-size: 1.1rem; + text-align: center; +} + +.sidebar_search_playlist_type_badge_standard, +.sidebar_search_playlist_type_badge_basic { + color: #66d1b6; +} + +.sidebar_search_playlist_type_badge_advanced { + color: #87aeea; +} + +.sidebar_search_playlist_type_badge_live_assist { + color: #f0b36c; +} + .sidebar_search_playlist_description { width: 240px; /* see sidebar.js $(document).ready() */