Make WordPress Core

Ticket #53171: 53171.diff

File 53171.diff, 2.1 KB (added by joedolson, 5 years ago)

First pass

  • src/js/media/models/attachments.js

     
    212212                this.observers.push( attachments );
    213213
    214214                attachments.on( 'add change remove', this._validateHandler, this );
     215                attachments.on( 'add', this._addToTotalAttachments, this );
     216                attachments.on( 'remove', this._removeFromTotalAttachments, this );
    215217                attachments.on( 'reset', this._validateAllHandler, this );
    216218                this.validateAll( attachments );
    217219                return this;
     
    237239                return this;
    238240        },
    239241        /**
     242         * Update total attachment count when items are added to a collection.
     243         *
    240244         * @access private
    241245         *
     246         * @since 5.8.0
     247         *
    242248         * @param {wp.media.model.Attachments} attachment
    243249         * @param {wp.media.model.Attachments} attachments
    244250         * @param {Object} options
     
    245251         *
    246252         * @return {wp.media.model.Attachments} Returns itself to allow chaining.
    247253         */
     254        _removeFromTotalAttachments: function( attachment, attachments, options ) {
     255                this.mirroring.totalAttachments = this.mirroring.totalAttachments - 1;
     256        },
     257        /**
     258         * Update total attachment count when items are added to a collection.
     259         *
     260         * @access private
     261         *
     262         * @since 5.8.0
     263         *
     264         * @param {wp.media.model.Attachments} attachment
     265         * @param {wp.media.model.Attachments} attachments
     266         * @param {Object} options
     267         *
     268         * @return {wp.media.model.Attachments} Returns itself to allow chaining.
     269         */
     270        _addToTotalAttachments: function( attachment, attachments, options ) {
     271                if ( this.mirroring ) {
     272                        this.mirroring.totalAttachments = this.mirroring.totalAttachments + 1;
     273                }
     274        },
     275        /**
     276         * @access private
     277         *
     278         * @param {wp.media.model.Attachments} attachment
     279         * @param {wp.media.model.Attachments} attachments
     280         * @param {Object} options
     281         *
     282         * @return {wp.media.model.Attachments} Returns itself to allow chaining.
     283         */
    248284        _validateHandler: function( attachment, attachments, options ) {
    249285                // If we're not mirroring this `attachments` collection,
    250286                // only retain the `silent` option.