Skip to content

Commit

Permalink
Fix issue processwire/processwire-issues#534 PageList narrow mode did…
Browse files Browse the repository at this point in the history
…n't show 'New' action for home, or 'Empty' action for trash
  • Loading branch information
ryancramerdesign committed Mar 15, 2018
1 parent d9b3016 commit eb95498
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions wire/modules/Process/ProcessPageList/ProcessPageList.js
Expand Up @@ -693,6 +693,13 @@ $(document).ready(function() {
var $lastAction = null;
var $extrasLink = null; // link that toggles extra actions
var extras = {}; // extra actions
var hasExtrasLink = false; // only referenced if options.useNarrowActions

if(options.useNarrowActions) {
for(var n = 0; n < links.length; n++) {
if(typeof links[n].extras != "undefined") hasExtrasLink = true;
}
}

$(links).each(function(n, action) {
var actionName;
Expand All @@ -702,7 +709,8 @@ $(document).ready(function() {
actionName = 'Select';
} else {
actionName = action.cn; // cn = className
if(options.useNarrowActions && (actionName != 'Edit' && actionName != 'View' && actionName != 'Extras')) {
if(options.useNarrowActions && hasExtrasLink
&& (actionName != 'Edit' && actionName != 'View' && actionName != 'Extras')) {
// move non-edit/view actions to extras when in narrow mode
extras[actionName] = action;
return;
Expand All @@ -719,13 +727,13 @@ $(document).ready(function() {
$a.addClass('pw-modal pw-modal-large pw-modal-longclick');
}
}

if(typeof action.extras != "undefined") {
for(var key in action.extras) {
extras[key] = action.extras[key];
}
$extrasLink = $a;
}

var $action = $("<li></li>").addClass('PageListAction' + actionName).append($a);
if(actionName == 'Extras') $lastAction = $action;
else $actions.append($action);
Expand Down

0 comments on commit eb95498

Please sign in to comment.