CC-84: Smart Playlists

-hides playlist content if dynamic instead of disabling
-show the user how many files match specified criteria
This commit is contained in:
denise 2012-07-19 14:52:39 -04:00
parent 0322e6b0c6
commit 9fcc851523
5 changed files with 94 additions and 18 deletions

View File

@ -232,9 +232,13 @@ class Application_Form_SmartPlaylistCriteria extends Zend_Form_SubForm
$shuffle->setDecorators(array('viewHelper')); $shuffle->setDecorators(array('viewHelper'));
$this->addElement($shuffle); $this->addElement($shuffle);
//getting playlist content candidate count that meets criteria
$pl = new Application_Model_Playlist($p_playlistId);
$files = $pl->getListofFilesMeetCriteria();
$this->setDecorators(array( $this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/smart-playlist-criteria.phtml', "openOption"=> $openSmartPlaylistOption, array('ViewScript', array('viewScript' => 'form/smart-playlist-criteria.phtml', "openOption"=> $openSmartPlaylistOption,
'criteriasLength' => count($criteriaOptions))) 'criteriasLength' => count($criteriaOptions), 'poolCount' => $files['count']))
)); ));
} }
} }

View File

@ -985,7 +985,11 @@ class Application_Model_Playlist
if ($result == 0) { if ($result == 0) {
$this->storeCriteriaIntoDb($data); $this->storeCriteriaIntoDb($data);
} }
return array("result"=>$result, "errors"=>$errors);
//get number of files that meet the criteria
$files = $this->getListofFilesMeetCriteria();
return array("result"=>$result, "errors"=>$errors, "poolCount"=>$files["count"]);
} }
public function storeCriteriaIntoDb($p_criteriaData){ public function storeCriteriaIntoDb($p_criteriaData){

View File

@ -4,21 +4,22 @@
<dl class='zend_form'> <dl class='zend_form'>
<div id='sp-success' class='success' style='display:none'></div> <div id='sp-success' class='success' style='display:none'></div>
<dd id='sp_type-element' class='radio-inline-list'> <dd id='sp_type-element' class='radio-inline-list'>
<label for='sp_type'> <label>
<?php echo $this->element->getElement('sp_type')->getLabel() ?> <?php echo $this->element->getElement('sp_type')->getLabel() ?>
<span class='playlist_type_help_icon'></span> <span class='playlist_type_help_icon'></span>
</label>
<?php $i=0; <?php $i=0;
$value = $this->element->getElement('sp_type')->getValue(); $value = $this->element->getElement('sp_type')->getValue();
foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?> foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?>
<input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if($i == $value){echo 'checked="checked"';}?> >
<?php echo $radio ?> <label for='sp_type-<?php echo $i?>'>
</input> <input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if($i == $value){echo 'checked="checked"';}?> ><?php echo $radio ?>
</label>
<?php $i = $i + 1; ?> <?php $i = $i + 1; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php echo $this->element->getElement('save_button') ?> <?php echo $this->element->getElement('save_button') ?>
<?php echo $this->element->getElement('generate_button') ?> <?php echo $this->element->getElement('generate_button') ?>
<?php echo $this->element->getElement('shuffle_button') ?> <?php echo $this->element->getElement('shuffle_button') ?>
</label>
</dd> </dd>
<dd id='sp_criteria-element'> <dd id='sp_criteria-element'>
@ -45,8 +46,35 @@
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span> <span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
<?php echo $this->element->getElement('sp_limit_value')?> <?php echo $this->element->getElement('sp_limit_value')?>
<?php echo $this->element->getElement('sp_limit_options') ?> <?php echo $this->element->getElement('sp_limit_options') ?>
<br /><br />
</dd> </dd>
<div class='sp_text_font sp_text_font_bold'>
<span id='sp_pool_count' class='sp_text_font sp_text_font_bold'>
<?php
if ($this->poolCount > 1) {
echo $this->poolCount;
?>
files meet the criteria
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else if ($this->poolCount == 1) {
echo $this->poolCount;
?>
file meets the criteria
</span>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php
} else {
?>
0 files meet the criteria
</span>
<span class='sp-warning-icon' id='sp_pool_count_icon'></span>
<?php
}
?>
</div>
</dl> </dl>
</fieldset> </fieldset>
</form> </form>

View File

@ -435,11 +435,15 @@ input.input_text.sp_extra_input_text{
} }
.sp_text_font{ .sp_text_font{
font-size:13px; font-size: 13px;
font-family:Helvetica, Arial, sans-serif; font-family: Helvetica, Arial, sans-serif;
color: #5B5B5B; color: #5B5B5B;
} }
.sp_text_font_bold{
font-weight: bold;
}
.sp-ui-button-icon-only { .sp-ui-button-icon-only {
position: relative; position: relative;
top: 5px; top: 5px;
@ -458,6 +462,21 @@ input.input_text.sp_extra_input_text{
margin-right: 0px !important; margin-right: 0px !important;
margin-left: 10px !important; margin-left: 10px !important;
} }
.sp-checked-icon{
width: 16px !important;
display: inline-block !important;
}
.sp-warning-icon{
margin: 0;
background-image: url(redmond/images/ui-icons_ff5d1a_256x240.png);
background-repeat: no-repeat;
background-position: 0px -140px;
height:16px;
width: 16px;
display: inline-block;
}
/***** SMART PLAYLIST SPECIFIC STYLES END *****/ /***** SMART PLAYLIST SPECIFIC STYLES END *****/
label { label {

View File

@ -105,8 +105,7 @@ function setSmartPlaylistEvents() {
}); });
form.find('button[id="save_button"]').live("click", function(event){ form.find('button[id="save_button"]').live("click", function(event){
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(), var data = $('form').serializeArray(),
data = $('form').serializeArray(),
save_action = 'Playlist/smart-playlist-criteria-save', save_action = 'Playlist/smart-playlist-criteria-save',
playlist_id = $('input[id="pl_id"]').val(); playlist_id = $('input[id="pl_id"]').val();
@ -116,8 +115,7 @@ function setSmartPlaylistEvents() {
}); });
form.find('button[id="generate_button"]').live("click", function(event){ form.find('button[id="generate_button"]').live("click", function(event){
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(), var data = $('form').serializeArray(),
data = $('form').serializeArray(),
generate_action = 'Playlist/smart-playlist-generate', generate_action = 'Playlist/smart-playlist-generate',
playlist_id = $('input[id="pl_id"]').val(); playlist_id = $('input[id="pl_id"]').val();
@ -127,8 +125,7 @@ function setSmartPlaylistEvents() {
}); });
form.find('button[id="shuffle_button"]').live("click", function(event){ form.find('button[id="shuffle_button"]').live("click", function(event){
var playlist_type = form.find('input:radio[name=sp_type]:checked').val(), var data = $('form').serializeArray(),
data = $('form').serializeArray(),
shuffle_action = 'Playlist/smart-playlist-shuffle', shuffle_action = 'Playlist/smart-playlist-shuffle',
playlist_id = $('input[id="pl_id"]').val(); playlist_id = $('input[id="pl_id"]').val();
@ -172,16 +169,20 @@ function setupUI() {
if (playlist_type == "0") { if (playlist_type == "0") {
$('button[id="generate_button"]').show(); $('button[id="generate_button"]').show();
$('button[id="shuffle_button"]').show(); $('button[id="shuffle_button"]').show();
$('#spl_sortable').unblock(); //$('#spl_sortable').unblock();
$('#spl_sortable').css("position", "static"); //$('#spl_sortable').css("position", "static");
$('#spl_sortable').show();
} else { } else {
$('button[id="generate_button"]').hide(); $('button[id="generate_button"]').hide();
$('button[id="shuffle_button"]').hide(); $('button[id="shuffle_button"]').hide();
/*
$('#spl_sortable').block({ $('#spl_sortable').block({
message: "", message: "",
theme: true, theme: true,
applyPlatformOpacityRules: false applyPlatformOpacityRules: false
}); });
*/
$('#spl_sortable').hide();
} }
$(".playlist_type_help_icon").qtip({ $(".playlist_type_help_icon").qtip({
@ -285,6 +286,26 @@ function callback(data, type) {
} else { } else {
form.find('.success').text('Criteria saved'); form.find('.success').text('Criteria saved');
form.find('.success').show(); form.find('.success').show();
/* Update number of files that meet criteria and
* change icon to success/warning as appropriate
*/
if (json.poolCount > 1) {
$('#sp_pool_count').text(json.poolCount+' files meet the criteria');
if ($('#sp_pool_count_icon').hasClass('sp-warning-icon')) {
$('#sp_pool_count_icon').removeClass('sp-warning-icon').addClass('checked-icon sp-checked-icon');
}
} else if (json.poolCount == 1) {
$('#sp_pool_count').text('1 file meets the criteria');
if ($('#sp_pool_count_icon').hasClass('sp-warning-icon')) {
$('#sp_pool_count_icon').removeClass('sp-warning-icon').addClass('checked-icon sp-checked-icon');
}
} else {
$('#sp_pool_count').text('0 files meet the criteria');
if ($('#sp_pool_count_icon').hasClass('checked-icon sp-checked-icon')) {
$('#sp_pool_count_icon').removeClass('checked-icon sp-checked-icon').addClass('sp-warning-icon');
}
}
} }
setTimeout('removeSuccessMsg()', 5000); setTimeout('removeSuccessMsg()', 5000);
} }