diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 843f7b545eb..9c4c0aab3b2 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -20,6 +20,7 @@ - Fixed warnings about missing SVG files that were logged by Control Panel requests. - Fixed a bug where the `|date` filter would ignore date formatting characters that don’t have ICU counterparts. ([#2867](https://github.com/craftcms/cms/issues/2867)) - Fixed a bug where the global `currentUser` Twig variable could be set to `null` and global sets and could be missing some custom field values when a user was logged-in, if a plugin was loading Twig during or immediately after plugin instantiation. ([#2866](https://github.com/craftcms/cms/issues/2866)) +- Fixed a bug where the table field's min rows setting would disable the add row button when it should not have. ([#2864](https://github.com/craftcms/cms/issues/2864)) ## 3.0.6 - 2018-05-08 diff --git a/src/web/assets/cp/dist/js/Craft.js b/src/web/assets/cp/dist/js/Craft.js index 80cb0ac4e22..b49da062278 100644 --- a/src/web/assets/cp/dist/js/Craft.js +++ b/src/web/assets/cp/dist/js/Craft.js @@ -1,4 +1,4 @@ -/*! - 2018-05-05 */ +/*! - 2018-05-10 */ (function($){ /** global: Craft */ @@ -12709,7 +12709,7 @@ Craft.EditableTable = Garnish.Base.extend( } if (this.settings.minRows && this.rowCount < this.settings.minRows) { - for (var i = 1; i < this.settings.minRows; i++) { + for (var i = this.rowCount; i < this.settings.minRows; i++) { this.addRow() } } @@ -12747,10 +12747,7 @@ Craft.EditableTable = Garnish.Base.extend( } }, updateAddRowButton: function() { - if ( - (this.settings.maxRows && this.rowCount >= this.settings.maxRows) || - (this.settings.minRows && this.rowCount < this.settings.minRows) - ) { + if (this.settings.maxRows && this.rowCount >= this.settings.maxRows) { this.$addRowBtn.css('opacity', '0.2'); this.$addRowBtn.css('pointer-events', 'none'); } else { @@ -12762,31 +12759,29 @@ Craft.EditableTable = Garnish.Base.extend( return (this.rowCount > this.settings.minRows); }, deleteRow: function(row) { - if (this.settings.maxRows && this.settings.minRows) { - if (!this.canDeleteRow()) { - return; - } + if (!this.canDeleteRow()) { + return; } this.sorter.removeItems(row.$tr); row.$tr.remove(); - if (this.settings.minRows && this.settings.maxRows) { - this.rowCount--; - } + this.rowCount--; this.updateAddRowButton(); // onDeleteRow callback this.settings.onDeleteRow(row.$tr); }, canAddRow: function() { - return (this.rowCount < this.settings.maxRows); + if (this.settings.maxRows) { + return (this.rowCount < this.settings.maxRows); + } + + return true; }, addRow: function() { - if (this.settings.minRows && this.settings.maxRows) { - if (!this.canAddRow()) { - return; - } + if (!this.canAddRow()) { + return; } var rowId = this.settings.rowIdPrefix + (this.biggestId + 1), diff --git a/src/web/assets/cp/dist/js/Craft.min.js b/src/web/assets/cp/dist/js/Craft.min.js index 9aa93d37331..cda2fe02e0c 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,asciiCharMap:{a:["à","á","ả","ã","ạ","ă","ắ","ằ","ẳ","ẵ","ặ","â","ấ","ầ","ẩ","ẫ","ậ","ä","ā","ą","å","α","ά","ἀ","ἁ","ἂ","ἃ","ἄ","ἅ","ἆ","ἇ","ᾀ","ᾁ","ᾂ","ᾃ","ᾄ","ᾅ","ᾆ","ᾇ","ὰ","ά","ᾰ","ᾱ","ᾲ","ᾳ","ᾴ","ᾶ","ᾷ","а","أ"],b:["б","β","Ъ","Ь","ب"],c:["ç","ć","č","ĉ","ċ"],d:["ď","ð","đ","ƌ","ȡ","ɖ","ɗ","ᵭ","ᶁ","ᶑ","д","δ","د","ض"],e:["é","è","ẻ","ẽ","ẹ","ê","ế","ề","ể","ễ","ệ","ë","ē","ę","ě","ĕ","ė","ε","έ","ἐ","ἑ","ἒ","ἓ","ἔ","ἕ","ὲ","έ","е","ё","э","є","ə"],f:["ф","φ","ف"],g:["ĝ","ğ","ġ","ģ","г","ґ","γ","ج"],h:["ĥ","ħ","η","ή","ح","ه"],i:["í","ì","ỉ","ĩ","ị","î","ï","ī","ĭ","į","ı","ι","ί","ϊ","ΐ","ἰ","ἱ","ἲ","ἳ","ἴ","ἵ","ἶ","ἷ","ὶ","ί","ῐ","ῑ","ῒ","ΐ","ῖ","ῗ","і","ї","и"],j:["ĵ","ј","Ј"],k:["ķ","ĸ","к","κ","Ķ","ق","ك"],l:["ł","ľ","ĺ","ļ","ŀ","л","λ","ل"],m:["м","μ","م"],n:["ñ","ń","ň","ņ","ʼn","ŋ","ν","н","ن"],o:["ó","ò","ỏ","õ","ọ","ô","ố","ồ","ổ","ỗ","ộ","ơ","ớ","ờ","ở","ỡ","ợ","ø","ō","ő","ŏ","ο","ὀ","ὁ","ὂ","ὃ","ὄ","ὅ","ὸ","ό","ö","о","و","θ"],p:["п","π"],r:["ŕ","ř","ŗ","р","ρ","ر"],s:["ś","š","ş","с","σ","ș","ς","س","ص"],t:["ť","ţ","т","τ","ț","ت","ط"],u:["ú","ù","ủ","ũ","ụ","ư","ứ","ừ","ử","ữ","ự","ü","û","ū","ů","ű","ŭ","ų","µ","у"],v:["в"],w:["ŵ","ω","ώ"],x:["χ"],y:["ý","ỳ","ỷ","ỹ","ỵ","ÿ","ŷ","й","ы","υ","ϋ","ύ","ΰ","ي"],z:["ź","ž","ż","з","ζ","ز"],aa:["ع"],ae:["æ"],ch:["ч"],dj:["ђ","đ"],dz:["џ"],gh:["غ"],kh:["х","خ"],lj:["љ"],nj:["њ"],oe:["œ"],ps:["ψ"],sh:["ш"],shch:["щ"],ss:["ß"],th:["þ","ث","ذ","ظ"],ts:["ц"],ya:["я"],yu:["ю"],zh:["ж"],"(c)":["©"],A:["Á","À","Ả","Ã","Ạ","Ă","Ắ","Ằ","Ẳ","Ẵ","Ặ","Â","Ấ","Ầ","Ẩ","Ẫ","Ậ","Ä","Å","Ā","Ą","Α","Ά","Ἀ","Ἁ","Ἂ","Ἃ","Ἄ","Ἅ","Ἆ","Ἇ","ᾈ","ᾉ","ᾊ","ᾋ","ᾌ","ᾍ","ᾎ","ᾏ","Ᾰ","Ᾱ","Ὰ","Ά","ᾼ","А"],B:["Б","Β"],C:["Ć","Č","Ĉ","Ċ"],D:["Ď","Ð","Đ","Ɖ","Ɗ","Ƌ","ᴅ","ᴆ","Д","Δ"],E:["É","È","Ẻ","Ẽ","Ẹ","Ê","Ế","Ề","Ể","Ễ","Ệ","Ë","Ē","Ę","Ě","Ĕ","Ė","Ε","Έ","Ἐ","Ἑ","Ἒ","Ἓ","Ἔ","Ἕ","Έ","Ὲ","Е","Ё","Э","Є","Ə"],F:["Ф","Φ"],G:["Ğ","Ġ","Ģ","Г","Ґ","Γ"],H:["Η","Ή"],I:["Í","Ì","Ỉ","Ĩ","Ị","Î","Ï","Ī","Ĭ","Į","İ","Ι","Ί","Ϊ","Ἰ","Ἱ","Ἳ","Ἴ","Ἵ","Ἶ","Ἷ","Ῐ","Ῑ","Ὶ","Ί","И","І","Ї"],K:["К","Κ"],L:["Ĺ","Ł","Л","Λ","Ļ"],M:["М","Μ"],N:["Ń","Ñ","Ň","Ņ","Ŋ","Н","Ν"],O:["Ó","Ò","Ỏ","Õ","Ọ","Ô","Ố","Ồ","Ổ","Ỗ","Ộ","Ơ","Ớ","Ờ","Ở","Ỡ","Ợ","Ö","Ø","Ō","Ő","Ŏ","Ο","Ό","Ὀ","Ὁ","Ὂ","Ὃ","Ὄ","Ὅ","Ὸ","Ό","О","Θ","Ө"],P:["П","Π"],R:["Ř","Ŕ","Р","Ρ"],S:["Ş","Ŝ","Ș","Š","Ś","С","Σ"],T:["Ť","Ţ","Ŧ","Ț","Т","Τ"],U:["Ú","Ù","Ủ","Ũ","Ụ","Ư","Ứ","Ừ","Ử","Ữ","Ự","Û","Ü","Ū","Ů","Ű","Ŭ","Ų","У"],V:["В"],W:["Ω","Ώ"],X:["Χ"],Y:["Ý","Ỳ","Ỷ","Ỹ","Ỵ","Ÿ","Ῠ","Ῡ","Ὺ","Ύ","Ы","Й","Υ","Ϋ"],Z:["Ź","Ž","Ż","З","Ζ"],AE:["Æ"],CH:["Ч"],DJ:["Ђ"],DZ:["Џ"],KH:["Х"],LJ:["Љ"],NJ:["Њ"],PS:["Ψ"],SH:["Ш"],SHCH:["Щ"],SS:["ẞ"],TH:["Þ"],TS:["Ц"],YA:["Я"],YU:["Ю"],ZH:["Ж"]," ":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "]},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={};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('