Ticket #22654: 22654.2.diff
| File 22654.2.diff, 6.4 KB (added by koopersmith, 6 months ago) |
|---|
-
wp-includes/js/media-editor.js
205 205 args.post__not_in = attrs.exclude.split(','); 206 206 207 207 if ( ! args.post__in ) 208 args. parent= attrs.id;208 args.uploadedTo = attrs.id; 209 209 210 210 // Collect the attributes that were not included in `args`. 211 211 others = _.omit( attrs, 'id', 'ids', 'include', 'exclude', 'orderby', 'order' ); … … 228 228 // the collection will already reflect those properties. 229 229 attrs.ids = attachments.pluck('id'); 230 230 231 // Copy the ` parent` post ID.232 if ( props. parent)233 attrs.id = props. parent;231 // Copy the `uploadedTo` post ID. 232 if ( props.uploadedTo ) 233 attrs.id = props.uploadedTo; 234 234 235 235 // If the `ids` attribute is set and `orderby` attribute 236 236 // is the default value, clear it for cleaner output. -
wp-includes/js/media-models.js
316 316 this.filters = options.filters || {}; 317 317 318 318 // Bind default `change` events to the `props` model. 319 this.props.on( 'change', this._changeFilteredProps, this ); 320 319 321 this.props.on( 'change:order', this._changeOrder, this ); 320 322 this.props.on( 'change:orderby', this._changeOrderby, this ); 321 323 this.props.on( 'change:query', this._changeQuery, this ); 322 this.props.on( 'change:search', this._changeSearch, this );323 this.props.on( 'change:type', this._changeType, this );324 324 325 325 // Set the `props` model and fill the default property values. 326 326 this.props.set( _.defaults( options.props || {} ) ); … … 359 359 } 360 360 }, 361 361 362 _changeFilteredProp : function( prop, model, term) {362 _changeFilteredProps: function( model, options ) { 363 363 // If this is a query, updating the collection will be handled by 364 364 // `this._requery()`. 365 365 if ( this.props.get('query') ) 366 366 return; 367 367 368 if ( term && ! this.filters[ prop ] ) 369 this.filters[ prop ] = Attachments.filters[ prop ]; 370 else if ( ! term && this.filters[ prop ] === Attachments.filters[ prop ] ) 371 delete this.filters[ prop ]; 368 var changed = _.chain( options.changes ).map( function( t, prop ) { 369 var filter = Attachments.filters[ prop ], 370 term = model.get( prop ); 372 371 372 if ( ! filter ) 373 return; 374 375 if ( term && ! this.filters[ prop ] ) 376 this.filters[ prop ] = filter; 377 else if ( ! term && this.filters[ prop ] === filter ) 378 delete this.filters[ prop ]; 379 else 380 return; 381 382 // Record the change. 383 return true; 384 }, this ).any().value(); 385 386 if ( ! changed ) 387 return; 388 373 389 // If no `Attachments` model is provided to source the searches 374 390 // from, then automatically generate a source from the existing 375 391 // models. … … 379 395 this.reset( this._source.filter( this.validator, this ) ); 380 396 }, 381 397 382 _changeSearch: function( model, term ) {383 return this._changeFilteredProp( 'search', model, term );384 },385 386 _changeType: function( model, term ) {387 return this._changeFilteredProp( 'type', model, term );388 },389 390 398 validator: function( attachment ) { 391 399 return _.all( this.filters, function( filter, key ) { 392 400 return !! filter.call( this, attachment ); … … 531 539 532 540 type: function( attachment ) { 533 541 var type = this.props.get('type'); 534 if ( ! type ) 542 return ! type || -1 !== type.indexOf( attachment.get('type') ); 543 }, 544 545 uploadedTo: function( attachment ) { 546 var uploadedTo = this.props.get('uploadedTo'); 547 if ( _.isUndefined( uploadedTo ) ) 535 548 return true; 536 549 537 return -1 !== type.indexOf( attachment.get('type'));550 return uploadedTo === attachment.get('uploadedTo'); 538 551 } 539 552 } 540 553 }); … … 597 610 // Only observe when a limited number of query args are set. There 598 611 // are no filters for other properties, so observing will result in 599 612 // false positives in those queries. 600 allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type' ];613 allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent' ]; 601 614 if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) 602 615 this.observe( wp.Uploader.queue ); 603 616 }, … … 670 683 propmap: { 671 684 'search': 's', 672 685 'type': 'post_mime_type', 673 'parent': 'post_parent',674 686 'perPage': 'posts_per_page', 675 'menuOrder': 'menu_order' 687 'menuOrder': 'menu_order', 688 'uploadedTo': 'post_parent' 676 689 }, 677 690 678 691 // Caches query objects so queries can be easily reused. -
wp-includes/js/media-views.js
2920 2920 all: { 2921 2921 text: l10n.allMediaItems, 2922 2922 props: { 2923 parent:null,2923 uploadedTo: null, 2924 2924 orderby: 'date', 2925 2925 order: 'DESC' 2926 2926 }, … … 2930 2930 uploaded: { 2931 2931 text: l10n.uploadedToThisPost, 2932 2932 props: { 2933 parent:media.view.settings.postId,2933 uploadedTo: media.view.settings.postId, 2934 2934 orderby: 'menuOrder', 2935 2935 order: 'ASC' 2936 2936 }, … … 2948 2948 text: text, 2949 2949 props: { 2950 2950 type: key, 2951 parent:null,2951 uploadedTo: null, 2952 2952 orderby: 'date', 2953 2953 order: 'DESC' 2954 2954 } … … 2959 2959 text: l10n.allMediaItems, 2960 2960 props: { 2961 2961 type: null, 2962 parent:null,2962 uploadedTo: null, 2963 2963 orderby: 'date', 2964 2964 order: 'DESC' 2965 2965 }, … … 2970 2970 text: l10n.uploadedToThisPost, 2971 2971 props: { 2972 2972 type: null, 2973 parent:media.view.settings.postId,2973 uploadedTo: media.view.settings.postId, 2974 2974 orderby: 'menuOrder', 2975 2975 order: 'ASC' 2976 2976 }, -
wp-includes/js/plupload/wp-plupload.js
155 155 file: file, 156 156 uploading: true, 157 157 date: new Date(), 158 filename: file.name 158 filename: file.name, 159 menuOrder: 0, 160 uploadedTo: media.model.settings.postId 159 161 }, _.pick( file, 'loaded', 'size', 'percent' ) ); 160 162 161 163 // Handle early mime type scanning for images.
