diff --git a/CHANGELOG-v2.md b/CHANGELOG-v2.md index bdf086e5b4e..fc00b0195e3 100644 --- a/CHANGELOG-v2.md +++ b/CHANGELOG-v2.md @@ -4,6 +4,7 @@ ### Fixed - Fixed a SQL error that could occur when merging two elements together if MySQL was set to a case-sensitive collation. ([#3539](https://github.com/craftcms/cms/issues/3539)) +- Fixed a bug where element indexes wouldn’t return to the previous sort selection after the search input was cleared. ([#3548](https://github.com/craftcms/cms/issues/3548)) ## 2.7.4 - 2018-11-27 diff --git a/src/web/assets/cp/dist/js/Craft.js b/src/web/assets/cp/dist/js/Craft.js index 80a61295ba9..fdf0f28e31e 100644 --- a/src/web/assets/cp/dist/js/Craft.js +++ b/src/web/assets/cp/dist/js/Craft.js @@ -1,4 +1,4 @@ -/*! - 2018-10-12 */ +/*! - 2018-12-12 */ (function($){ /** global: Craft */ @@ -2247,7 +2247,7 @@ Craft.BaseElementIndex = Garnish.Base.extend( source: this.instanceState.selectedSource, criteria: criteria, disabledElementIds: this.settings.disabledElementIds, - viewState: this.getSelectedSourceState() + viewState: $.extend({}, this.getSelectedSourceState()) }; // Possible that the order/sort isn't entirely accurate if we're sorting by Score @@ -2612,14 +2612,10 @@ Craft.BaseElementIndex = Garnish.Base.extend( }, setStoredSortOptionsForSource: function() { - // Default to whatever's first - this.setSortAttribute(); - this.setSortDirection('asc'); - var sortAttr = this.getSelectedSourceState('order'), sortDir = this.getSelectedSourceState('sort'); - if (!sortAttr) { + if (!sortAttr || !sortDir) { // Get the default sortAttr = this.getDefaultSort(); diff --git a/src/web/assets/cp/dist/js/Craft.min.js b/src/web/assets/cp/dist/js/Craft.min.js index 50a440acaa4..f1ad59bd45b 100644 --- a/src/web/assets/cp/dist/js/Craft.min.js +++ b/src/web/assets/cp/dist/js/Craft.min.js @@ -1,2 +1,2 @@ -!function(p){p.extend(Craft,{navHeight:48,t:function(t,e,i){if(void 0!==Craft.translations[t]&&void 0!==Craft.translations[t][e]&&(e=Craft.translations[t][e]),i)for(var s in i)i.hasOwnProperty(s)&&(e=e.replace("{"+s+"}",i[s]));return e},formatDate:function(t){return"object"!=typeof t&&(t=new Date(t)),p.datepicker.formatDate(Craft.datepickerOptions.dateFormat,t)},formatNumber:function(t,e){return void 0===e&&(e=",.0f"),d3.formatLocale(d3FormatLocaleDefinition).format(e)(t)},escapeHtml:function(t){return p("
").text(t).html()},getText:function(t){return p("
").html(t).text()},encodeUriComponent:function(t){t=encodeURIComponent(t);var e={"!":"%21","*":"%2A","'":"%27","(":"%28",")":"%29"};for(var i in e){var s=new RegExp("\\"+i,"g");t=t.replace(s,e[i])}return t},selectFullValue:function(t){var e=p(t),i=e.val();if(void 0!==e[0].setSelectionRange){var s=2*i.length;e[0].setSelectionRange(0,s)}else e.val(i)},formatInputId:function(t){return this.rtrim(t.replace(/[\[\]\\]+/g,"-"),"-")},getUrl:function(t,e,i){if("string"!=typeof t&&(t=""),-1!==t.search("://")||"/"===t[0])return t;t=Craft.trim(t,"/");var s="";if(p.isPlainObject(e)){var n=[];for(var a in e)if(e.hasOwnProperty(a)){var r=e[a];"#"===a?s=r:null!==r&&""!==r&&n.push(a+"="+r)}e=n}e=Garnish.isArray(e)?e.join("&"):Craft.trim(e,"&?");var o,l=t.indexOf("?");if(-1!==l&&(e=t.substr(l+1)+(e?"&"+e:""),t=t.substr(0,l)),i){if(o=i,t){var h=o.match(/[&\?]p=[^&]+/);h&&(o=o.replace(h[0],h[0]+"/"+t),t="")}}else o=Craft.baseUrl;if(-1!==(l=o.indexOf("?"))&&(e=o.substr(l+1)+(e?"&"+e:""),o=o.substr(0,l)),!Craft.omitScriptNameInUrls&&t)if(Craft.usePathInfo)-1===o.search(Craft.scriptName)&&(o=Craft.rtrim(o,"/")+"/"+Craft.scriptName);else{if(e&&"p="===e.substr(0,2)){var d,c=e.indexOf("&");-1!==c?(d=e.substring(2,c),e=e.substr(c+1)):(d=e.substr(2),e=null),t=(d=Craft.rtrim(d))+(t?"/"+t:"")}e="p="+t+(e?"&"+e:""),t=null}return t&&(o=Craft.rtrim(o,"/")+"/"+t),e&&(o+="?"+e),s&&(o+="#"+s),o},getCpUrl:function(t,e){return this.getUrl(t,e,Craft.baseCpUrl)},getSiteUrl:function(t,e){return this.getUrl(t,e,Craft.baseSiteUrl)},getActionUrl:function(t,e){return Craft.getUrl(t,e,Craft.actionUrl)},redirectTo:function(t){document.location.href=this.getUrl(t)},getCsrfInput:function(){return Craft.csrfTokenName?'':""},postActionRequest:function(t,e,i,s){"function"==typeof e&&(s=i,i=e,e={});var n={"X-Registered-Asset-Bundles":Object.keys(Craft.registeredAssetBundles).join(","),"X-Registered-Js-Files":Object.keys(Craft.registeredJsFiles).join(",")};Craft.csrfTokenValue&&Craft.csrfTokenName&&(n["X-CSRF-Token"]=Craft.csrfTokenValue);var a=p.ajax(p.extend({url:Craft.getActionUrl(t),type:"POST",dataType:"json",headers:n,data:e,success:i,error:function(t,e){i&&i(null,e,t)},complete:function(t,e){"success"!==e&&(void 0!==Craft.cp?Craft.cp.displayError():alert(Craft.t("app","An unknown error occurred.")))}},s));return s&&"function"==typeof s.send&&s.send(a),a},_waitingOnAjax:!1,_ajaxQueue:[],queueActionRequest:function(t,e,i,s){"function"==typeof e&&(s=i,i=e,e=void 0),Craft._ajaxQueue.push([t,e,i,s]),Craft._waitingOnAjax||Craft._postNextActionRequestInQueue()},_postNextActionRequestInQueue:function(){Craft._waitingOnAjax=!0;var s=Craft._ajaxQueue.shift();Craft.postActionRequest(s[0],s[1],function(t,e,i){s[2]&&"function"==typeof s[2]&&s[2](t,e,i),Craft._ajaxQueue.length?Craft._postNextActionRequestInQueue():Craft._waitingOnAjax=!1},s[3])},stringToArray:function(t){if("string"!=typeof t)return t;for(var e=t.split(","),i=0;i]*href="(?:'+i.join("|")+')".*?><\/script>',"g");t=t.replace(a,"")}p("head").append(t)}},appendFootHtml:function(t){if(t){var e=p("script[src]");if(e.length){for(var i=[],s=0;s]*src="(?:'+i.join("|")+')".*?><\/script>',"g");t=t.replace(a,"")}Garnish.$bod.append(t)}},initUiElements:function(t){p(".grid",t).grid(),p(".info",t).infoicon(),p(".checkbox-select",t).checkboxselect(),p(".fieldtoggle",t).fieldtoggle(),p(".lightswitch",t).lightswitch(),p(".nicetext",t).nicetext(),p(".pill",t).pill(),p(".formsubmit",t).formsubmit(),p(".menubtn",t).menubtn()},_elementIndexClasses:{},_elementSelectorModalClasses:{},_elementEditorClasses:{},registerElementIndexClass:function(t,e){if(void 0!==this._elementIndexClasses[t])throw"An element index class has already been registered for the element type “"+t+"”.";this._elementIndexClasses[t]=e},registerElementSelectorModalClass:function(t,e){if(void 0!==this._elementSelectorModalClasses[t])throw"An element selector modal class has already been registered for the element type “"+t+"”.";this._elementSelectorModalClasses[t]=e},registerElementEditorClass:function(t,e){if(void 0!==this._elementEditorClasses[t])throw"An element editor class has already been registered for the element type “"+t+"”.";this._elementEditorClasses[t]=e},createElementIndex:function(t,e,i){return new(void 0!==this._elementIndexClasses[t]?this._elementIndexClasses[t]:Craft.BaseElementIndex)(t,e,i)},createElementSelectorModal:function(t,e){return new(void 0!==this._elementSelectorModalClasses[t]?this._elementSelectorModalClasses[t]:Craft.BaseElementSelectorModal)(t,e)},createElementEditor:function(t,e,i){return new(void 0!==this._elementEditorClasses[t]?this._elementEditorClasses[t]:Craft.BaseElementEditor)(e,i)},getLocalStorage:function(t,e){return t="Craft-"+Craft.systemUid+"."+t,"undefined"!=typeof localStorage&&void 0!==localStorage[t]?JSON.parse(localStorage[t]):e},setLocalStorage:function(t,e){if("undefined"!=typeof localStorage){t="Craft-"+Craft.systemUid+"."+t;try{localStorage[t]=JSON.stringify(e)}catch(t){}}},getElementInfo:function(t){var e=p(t);return e.hasClass("element")||(e=e.find(".element:first")),{id:e.data("id"),siteId:e.data("site-id"),label:e.data("label"),status:e.data("status"),url:e.data("url"),hasThumb:e.hasClass("hasthumb"),$element:e}},setElementSize:function(t,e){var i=p(t);if("small"!==e&&"large"!==e&&(e="small"),!i.hasClass(e)){var s="small"===e?"large":"small";if(i.addClass(e).removeClass(s),i.hasClass("hasthumb")){var n=i.find("> .elementthumb > img"),a=p("",{sizes:("small"===e?"30":"100")+"px",srcset:n.attr("srcset")||n.attr("data-pfsrcset")});n.replaceWith(a),picturefill({elements:[a[0]]})}}}}),p.extend(p.fn,{animateLeft:function(t,e,i,s){return"ltr"===Craft.orientation?this.velocity({left:t},e,i,s):this.velocity({right:t},e,i,s)},animateRight:function(t,e,i,s){return"ltr"===Craft.orientation?this.velocity({right:t},e,i,s):this.velocity({left:t},e,i,s)},disable:function(){return this.each(function(){var t=p(this);t.addClass("disabled"),t.data("activatable")&&t.removeAttr("tabindex")})},enable:function(){return this.each(function(){var t=p(this);t.removeClass("disabled"),t.data("activatable")&&t.attr("tabindex","0")})},grid:function(){return this.each(function(){var t=p(this),e={};t.data("item-selector")&&(e.itemSelector=t.data("item-selector")),t.data("cols")&&(e.cols=parseInt(t.data("cols"))),t.data("max-cols")&&(e.maxCols=parseInt(t.data("max-cols"))),t.data("min-col-width")&&(e.minColWidth=parseInt(t.data("min-col-width"))),t.data("mode")&&(e.mode=t.data("mode")),t.data("fill-mode")&&(e.fillMode=t.data("fill-mode")),t.data("col-class")&&(e.colClass=t.data("col-class")),t.data("snap-to-grid")&&(e.snapToGrid=!!t.data("snap-to-grid")),new Craft.Grid(this,e)})},infoicon:function(){return this.each(function(){new Craft.InfoIcon(this)})},checkboxselect:function(){return this.each(function(){p.data(this,"checkboxselect")||new Garnish.CheckboxSelect(this)})},fieldtoggle:function(){return this.each(function(){p.data(this,"fieldtoggle")||new Craft.FieldToggle(this)})},lightswitch:function(e,t,i){return"settings"===e?("string"==typeof t?(e={})[t]=i:e=t,this.each(function(){var t=p.data(this,"lightswitch");t&&t.setSettings(e)})):(p.isPlainObject(e)||(e={}),this.each(function(){var t=p.extend({},e);Garnish.hasAttr(this,"data-value")&&(t.value=p(this).attr("data-value")),p.data(this,"lightswitch")||new Craft.LightSwitch(this,t)}))},nicetext:function(){return this.each(function(){p.data(this,"nicetext")||new Garnish.NiceText(this)})},pill:function(){return this.each(function(){p.data(this,"pill")||new Garnish.Pill(this)})},formsubmit:function(){this.on("click",function(t){var e=p(t.currentTarget);if(!e.attr("data-confirm")||confirm(e.attr("data-confirm"))){var i=e.data("menu")?e.data("menu").$anchor:e,s=i.attr("data-form")?p("#"+i.attr("data-form")):i.closest("form");e.attr("data-action")&&p('').val(e.attr("data-action")).appendTo(s),e.attr("data-redirect")&&p('').val(e.attr("data-redirect")).appendTo(s),e.attr("data-param")&&p('').attr({name:e.attr("data-param"),value:e.attr("data-value")}).appendTo(s),s.trigger("submit")}})},menubtn:function(){return this.each(function(){var t=p(this);if(!t.data("menubtn")&&t.next().hasClass("menu")){var e={};t.data("menu-anchor")&&(e.menuAnchor=t.data("menu-anchor")),new Garnish.MenuBtn(t,e)}})}}),Garnish.$doc.ready(function(){Craft.initUiElements()}),Craft.BaseElementEditor=Garnish.Base.extend({$element:null,elementId:null,siteId:null,$form:null,$fieldsContainer:null,$cancelBtn:null,$saveBtn:null,$spinner:null,$siteSelect:null,$siteSpinner:null,hud:null,init:function(t,e){void 0===e&&p.isPlainObject(t)&&(e=t,t=null),this.$element=p(t),this.setSettings(e,Craft.BaseElementEditor.defaults),this.loadHud()},setElementAttribute:function(t,e){this.settings.attributes||(this.settings.attributes={}),null===e?delete this.settings.attributes[t]:this.settings.attributes[t]=e},getBaseData:function(){var t=p.extend({},this.settings.params);return this.settings.siteId?t.siteId=this.settings.siteId:this.$element&&this.$element.data("site-id")&&(t.siteId=this.$element.data("site-id")),this.settings.elementId?t.elementId=this.settings.elementId:this.$element&&this.$element.data("id")&&(t.elementId=this.$element.data("id")),this.settings.elementType&&(t.elementType=this.settings.elementType),this.settings.attributes&&(t.attributes=this.settings.attributes),t},loadHud:function(){this.onBeginLoading();var t=this.getBaseData();t.includeSites=this.settings.showSiteSwitcher,Craft.postActionRequest("elements/get-editor-html",t,p.proxy(this,"showHud"))},showHud:function(t,e){if(this.onEndLoading(),"success"===e){var i=p();if(t.sites){var s=p('
'),n=p('
').appendTo(s);this.$siteSelect=p("').appendTo(l),this.$spinner=p('