Skip to content

Commit

Permalink
Improving save action to update load projects list
Browse files Browse the repository at this point in the history
  • Loading branch information
pieman72 committed Jul 22, 2014
1 parent 927f2c6 commit daf174d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion adhoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3390,8 +3390,39 @@ Event.observe(window, 'load', function(){
adhoc.error(t.responseText);
}
,onSuccess: function(t){
// Disable the button until a change is made
// Update the 'load' menu with any changes
adhoc.setting('projectId', t.responseText);
var projOpt = $$('#projectSelect .nxj_selectOption[data-value='+adhoc.setting('projectId')+']')
$$('#projectSelect .nxj_selectDisplay').each(function(display){
display.addClassName('default').update(display.getAttribute('placeholder'));
});

// The project is already in the menu
if(projOpt.length){
projOpt = projOpt[0];
projOpt.select('span').each(function(span){
if(span.hasClassName('projectOption')){
span.update(adhoc.setting('projectName'));
}else if(span.hasClassName('projectDate')){
span.update('Just now');
}
});
// It's a new project
}else{
projOpt = $(document.createElement('div'));
projOpt.addClassName('nxj_selectOption');
var span1 = $(document.createElement('div').addClassName('projectOption'));
var span2 = $(document.createElement('div').addClassName('projectDate'));
span1.update(adhoc.setting('projectName'));
span2.update('Just now');
projOpt.appendChild(span1);
projOpt.appendChild(span2);
}
projOpt.setAttribute('data-value', adhoc.setting('projectId'));
var inner = $$('#projectSelect .nxj_selectInner')[0];
inner.insertBefore(projOpt, inner.firstChild);

// Disable the 'save' button until a change is made
$('savePackageButton').addClassName('disabled');
}
});
Expand Down
2 changes: 1 addition & 1 deletion ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function selectbox($params) {
<div id=\"".$params['id']."\"
class=\"nxj_select".(isset($params['float']) ? ' float'.ucfirst($params['float']) : '').(isset($params['class']) ? ' '.$params['class'] : '')."\"
style=\"width:".($params['width']-2)."px;".(isset($params['zindex']) ? ' z-index:'.$params['zindex'].';' : '')."\">
<div class=\"nxj_selectDisplay default\">".(isset($params['defaultText']) ? $params['defaultText'] : '')."</div>
<div class=\"nxj_selectDisplay default\"".(isset($params['defaultText']) ? ' placeholder="'.$params['defaultText'].'"' : '').">".(isset($params['defaultText']) ? $params['defaultText'] : '')."</div>
<div class=\"nxj_selectArrow\"></div>
<div class=\"nxj_selectInner\">";

Expand Down

0 comments on commit daf174d

Please sign in to comment.