diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md index e6d3e0b64a4..e45d223959c 100644 --- a/CHANGELOG-WIP.md +++ b/CHANGELOG-WIP.md @@ -3,6 +3,8 @@ ### Content Management - Element conditions can now have a “Not Related To” rule. ([#15496](https://github.com/craftcms/cms/pull/15496)) - Asset chips and cards no longer include the “Replace file” action. ([#15498](https://github.com/craftcms/cms/issues/15498)) +- Category slugs are now inline-editable from the Categories index page. ([#15560](https://github.com/craftcms/cms/pull/15560)) +- Entry post dates, expiry dates, slugs, and authors are now inline-editable from the Entries index page. ([#15560](https://github.com/craftcms/cms/pull/15560)) ### Accessibility - Improved the accessibility of Tags fields. diff --git a/src/elements/Category.php b/src/elements/Category.php index e60605e1d79..9a0c0bf6769 100644 --- a/src/elements/Category.php +++ b/src/elements/Category.php @@ -735,6 +735,22 @@ public function getGroup(): CategoryGroup // Indexes, etc. // ------------------------------------------------------------------------- + /** + * @inheritdoc + */ + protected function inlineAttributeInputHtml(string $attribute): string + { + switch ($attribute) { + case 'slug': + return Cp::textHtml([ + 'name' => 'slug', + 'value' => $this->slug, + ]); + default: + return parent::inlineAttributeInputHtml($attribute); + } + } + /** * @inheritdoc * @since 3.3.0 diff --git a/src/elements/Entry.php b/src/elements/Entry.php index 1a742fb87e3..e70826e21cb 100644 --- a/src/elements/Entry.php +++ b/src/elements/Entry.php @@ -1934,6 +1934,53 @@ protected function attributeHtml(string $attribute): string } } + /** + * @inheritdoc + */ + protected function inlineAttributeInputHtml(string $attribute): string + { + switch ($attribute) { + case 'postDate': + return Cp::dateTimeFieldHtml([ + 'name' => 'postDate', + 'value' => $this->postDate, + ]); + case 'expiryDate': + return Cp::dateTimeFieldHtml([ + 'name' => 'expiryDate', + 'value' => $this->expiryDate, + ]); + case 'slug': + return Cp::textHtml([ + 'name' => 'slug', + 'value' => $this->slug, + ]); + case 'authors': + $authors = $this->getAuthors(); + $section = $this->getSection(); + return Cp::elementSelectHtml([ + 'status' => $this->getAttributeStatus('authorIds'), + 'label' => Craft::t('app', '{max, plural, =1{Author} other {Authors}}', [ + 'max' => $section->maxAuthors, + ]), + 'id' => 'authorIds', + 'name' => 'authorIds', + 'elementType' => User::class, + 'selectionLabel' => Craft::t('app', 'Choose'), + 'criteria' => [ + 'can' => "viewEntries:$section->uid", + ], + 'single' => false, + 'elements' => $authors ?: null, + 'disabled' => false, + 'errors' => $this->getErrors('authorIds'), + 'limit' => $section->maxAuthors, + ]); + default: + return parent::inlineAttributeInputHtml($attribute); + } + } + /** * @inheritdoc */ diff --git a/src/web/assets/cp/dist/cp.js b/src/web/assets/cp/dist/cp.js index 6d8d13a0224..c503559a73b 100644 --- a/src/web/assets/cp/dist/cp.js +++ b/src/web/assets/cp/dist/cp.js @@ -1,3 +1,3 @@ /*! For license information please see cp.js.LICENSE.txt */ -(function(){var __webpack_modules__={463:function(){Craft.Accordion=Garnish.Base.extend({$trigger:null,targetSelector:null,_$target:null,init:function(t){var e=this;this.$trigger=$(t),this.$trigger.data("accordion")&&(console.warn("Double-instantiating an accordion trigger on an element"),this.$trigger.data("accordion").destroy()),this.$trigger.data("accordion",this),this.targetSelector=this.$trigger.attr("aria-controls")?"#".concat(this.$trigger.attr("aria-controls")):null,this.targetSelector&&(this._$target=$(this.targetSelector)),this.addListener(this.$trigger,"click","onTriggerClick"),this.addListener(this.$trigger,"keypress",(function(t){var n=t.keyCode;n!==Garnish.SPACE_KEY&&n!==Garnish.RETURN_KEY||(t.preventDefault(),e.onTriggerClick())}))},onTriggerClick:function(){"true"===this.$trigger.attr("aria-expanded")?this.hideTarget(this._$target):this.showTarget(this._$target)},showTarget:function(t){var e=this;if(t&&t.length){this.showTarget._currentHeight=t.height(),t.removeClass("hidden"),this.$trigger.removeClass("collapsed").addClass("expanded").attr("aria-expanded","true");for(var n=0;n=this.settings.maxItems)){var e=$(t).appendTo(this.$tbody),n=e.find(".delete");this.settings.sortable&&this.sorter.addItems(e),this.$deleteBtns=this.$deleteBtns.add(n),this.addListener(n,"click","handleDeleteBtnClick"),this.totalItems++,this.updateUI()}},reorderItems:function(){var t=this;if(this.settings.sortable){for(var e=[],n=0;n=this.settings.maxItems?$(this.settings.newItemBtnSelector).addClass("hidden"):$(this.settings.newItemBtnSelector).removeClass("hidden"))}},{defaults:{tableSelector:null,noItemsSelector:null,newItemBtnSelector:null,idAttribute:"data-id",nameAttribute:"data-name",sortable:!1,allowDeleteAll:!0,minItems:0,maxItems:null,reorderAction:null,deleteAction:null,reorderSuccessMessage:Craft.t("app","New order saved."),reorderFailMessage:Craft.t("app","Couldn’t save new order."),confirmDeleteMessage:Craft.t("app","Are you sure you want to delete “{name}”?"),deleteSuccessMessage:Craft.t("app","“{name}” deleted."),deleteFailMessage:Craft.t("app","Couldn’t delete “{name}”."),onReorderItems:$.noop,onDeleteItem:$.noop}})},6872:function(){Craft.AssetImageEditor=Garnish.Modal.extend({$body:null,$footer:null,$imageTools:null,$buttons:null,$cancelBtn:null,$replaceBtn:null,$saveBtn:null,$focalPointBtn:null,$editorContainer:null,$straighten:null,$croppingCanvas:null,$spinner:null,$constraintContainer:null,$constraintRadioInputs:null,$customConstraints:null,canvas:null,image:null,viewport:null,focalPoint:null,grid:null,croppingCanvas:null,clipper:null,croppingRectangle:null,cropperHandles:null,cropperGrid:null,croppingShade:null,imageStraightenAngle:0,viewportRotation:0,originalWidth:0,originalHeight:0,imageVerticeCoords:null,zoomRatio:1,animationInProgress:!1,currentView:"",assetId:null,cacheBust:null,draggingCropper:!1,scalingCropper:!1,draggingFocal:!1,previousMouseX:0,previousMouseY:0,shiftKeyHeld:!1,editorHeight:0,editorWidth:0,cropperState:!1,scaleFactor:1,flipData:{},focalPointState:!1,maxImageSize:null,lastLoadedDimensions:null,imageIsLoading:!1,mouseMoveEvent:null,croppingConstraint:!1,constraintOrientation:"landscape",showingCustomConstraint:!1,saving:!1,renderImage:null,renderCropper:null,_queue:null,init:function(t,e){var n=this;this._queue=new Craft.Queue,this.cacheBust=Date.now(),this.setSettings(e,Craft.AssetImageEditor.defaults),null===this.settings.allowDegreeFractions&&(this.settings.allowDegreeFractions=Craft.isImagick),Garnish.prefersReducedMotion()&&(this.settings.animationDuration=1),this.assetId=t,this.flipData={x:0,y:0},this.$container=$('').appendTo(Garnish.$bod),this.$body=$('
').appendTo(this.$container),this.$footer=$('