Skip to content

Commit

Permalink
Hide the status menu for sources that define a status
Browse files Browse the repository at this point in the history
Resolves #4249
  • Loading branch information
brandonkelly committed May 13, 2019
1 parent ef349e0 commit 973cd76
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Changed
- Craft no longer shows the status menu for element sources that define a status. ([#4249](https://github.com/craftcms/cms/issues/4249))

### Fixed
- Fixed a bug where rebuilding the project config could set an incorrect value for the user field layout.
- Fixed a bug Craft wouldn’t allow users to edit their own photos if they didn’t have upload/remove asset permissions.
Expand Down
1 change: 1 addition & 0 deletions src/templates/_elements/sources.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{%- if source.structureId is defined %} data-has-structure{% endif %}
{%- if source.defaultSort is defined %}{% set defaultSort = source.defaultSort %} data-default-sort="{{ defaultSort is iterable ? defaultSort|join(':') : defaultSort }}"{% endif %}
{%- if source.sites is defined %} data-sites="{{ source.sites|join(',') }}"{% endif %}
{%- if source.criteria.status is defined %} data-override-status{% endif %}
{%- if source.data is defined -%}
{% for dataKey, dataVal in source.data %} data-{{ dataKey }}="{{ dataVal }}"{% endfor %}
{%- endif %}>
Expand Down
26 changes: 22 additions & 4 deletions src/web/assets/cp/dist/js/Craft.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! - 2019-05-09 */
/*! - 2019-05-13 */
(function($){

/** global: Craft */
Expand Down Expand Up @@ -1734,6 +1734,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
$clearSearchBtn: null,

$statusMenuBtn: null,
$statusMenuContainer: null,
statusMenu: null,
status: null,

Expand Down Expand Up @@ -1798,6 +1799,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.$toolbar = this.$container.find('.toolbar:first');
this.$toolbarFlexContainer = this.$toolbar.children('.flex');
this.$statusMenuBtn = this.$toolbarFlexContainer.find('.statusmenubtn:first');
this.$statusMenuContainer = this.$statusMenuBtn.parent();
this.$siteMenuBtn = this.$container.find('.sitemenubtn:first');
this.$sortMenuBtn = this.$toolbarFlexContainer.find('.sortmenubtn:first');
this.$search = this.$toolbarFlexContainer.find('.search:first input:first');
Expand Down Expand Up @@ -2238,13 +2240,18 @@ Craft.BaseElementIndex = Garnish.Base.extend(
* when loading elements.
*/
getViewParams: function() {
var criteria = $.extend({
status: this.status,
var criteria = {
siteId: this.siteId,
search: this.searchText,
limit: this.settings.batchSize,
trashed: this.trashed ? 1 : 0
}, this.settings.criteria);
};

if (!Garnish.hasAttr(this.$source, 'data-override-status')) {
criteria.status = this.status;
}

$.extend(criteria, this.settings.criteria);

var params = {
context: this.settings.context,
Expand Down Expand Up @@ -2550,6 +2557,17 @@ Craft.BaseElementIndex = Garnish.Base.extend(

this.setStoredSortOptionsForSource();

// Status menu
// ----------------------------------------------------------------------

if (this.$statusMenuBtn.length) {
if (Garnish.hasAttr(this.$source, 'data-override-status')) {
this.$statusMenuContainer.addClass('hidden');
} else {
this.$statusMenuContainer.removeClass('hidden');
}
}

// View mode buttons
// ----------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/js/Craft.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/js/Craft.min.js.map

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
$clearSearchBtn: null,

$statusMenuBtn: null,
$statusMenuContainer: null,
statusMenu: null,
status: null,

Expand Down Expand Up @@ -109,6 +110,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.$toolbar = this.$container.find('.toolbar:first');
this.$toolbarFlexContainer = this.$toolbar.children('.flex');
this.$statusMenuBtn = this.$toolbarFlexContainer.find('.statusmenubtn:first');
this.$statusMenuContainer = this.$statusMenuBtn.parent();
this.$siteMenuBtn = this.$container.find('.sitemenubtn:first');
this.$sortMenuBtn = this.$toolbarFlexContainer.find('.sortmenubtn:first');
this.$search = this.$toolbarFlexContainer.find('.search:first input:first');
Expand Down Expand Up @@ -549,13 +551,18 @@ Craft.BaseElementIndex = Garnish.Base.extend(
* when loading elements.
*/
getViewParams: function() {
var criteria = $.extend({
status: this.status,
var criteria = {
siteId: this.siteId,
search: this.searchText,
limit: this.settings.batchSize,
trashed: this.trashed ? 1 : 0
}, this.settings.criteria);
};

if (!Garnish.hasAttr(this.$source, 'data-override-status')) {
criteria.status = this.status;
}

$.extend(criteria, this.settings.criteria);

var params = {
context: this.settings.context,
Expand Down Expand Up @@ -861,6 +868,17 @@ Craft.BaseElementIndex = Garnish.Base.extend(

this.setStoredSortOptionsForSource();

// Status menu
// ----------------------------------------------------------------------

if (this.$statusMenuBtn.length) {
if (Garnish.hasAttr(this.$source, 'data-override-status')) {
this.$statusMenuContainer.addClass('hidden');
} else {
this.$statusMenuContainer.removeClass('hidden');
}
}

// View mode buttons
// ----------------------------------------------------------------------

Expand Down

0 comments on commit 973cd76

Please sign in to comment.